PHP - Error In Code, Going To White Screen And Not Redirecting
Keep going over this and can't find the stupid error. Need some fresh eyes for some help. Thanks
Code: [Select] <?php ob_start(); session_start(); include("include/db_connect.php"); // Define $username and $password $username = $_REQUEST['username']; $password = $_REQUEST['password']; // To protect MySQL injection $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM login WHERE username = '$username' AND password = '$password'"; $result=mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched, table row must be 1 row if($count!=0) { // Register session variables and redirect to file "dashboard.php" $_SESSION['id'] = $row['id']; $_SESSION['franchise_id'] = $row['franchise_id']; $_SESSION['dealer_id'] = $row['dealer_id]'; $_SESSION['first'] = $row['first']; $_SESSION['last'] = $row['last']; header("location:dashboard.php"); } else { header("location:not_logged_in.php"); } ob_end_flush(); ?> Similar TutorialsHello everyone, When I submit my login form to go to my login page it goes to a white page and does not display an error. Code: [Select] <?php include("../secure/database.php"); if(!empty($_POST['loginsubmit'])){ if(!empty($_POST['email'])){ $email = securevar($_POST['email']); if(!empty($_POST['passconf'])){ $pass = securevar($_POST['passconf']); $q = "SELECT * FROM `accountinfo_db` WHERE `email` = '$email' AND `password` = '$pass'"; $res = mysql_query($q) or die(mysql_error()); $login = mysql_fetch_array($res); $id = $login['id']; $active = $login['active']; if($id>=1){ if($active==1){ $_SESSION['logged'] = $login['id']; $q = "UPDATE `accountinfo_db` SET `loggedtimes` = `loggedtimes`+'1' WHERE `id` = '$id'"; $res = mysql_query($q) or die(mysql_error()); $user = $login['username']; header("Location: ../mainframe.php?strmsg=Welcome Back $user"); }else{ header("Location: activate.php"); } }else{ header("Location: ../index.php?strmsg=Login Information Incorrect!"); } }else{ header("Location: ../index.php?strmsg=You did not enter a valid password!"); } }else{ header("Location: ../index.php?strmsg=You did not enter a valid email!"); } }else{ header("Location: ../index.php?strmsg=We are sorry but you are not allowed viewance of that directory!"); } ?> any help would be great. Brian Hello.
The first page works, but when form actioning to the next i just get a white screen.
This is the white screen page:
<?php session_start(); include 'details.php'; $username = $_POST['username']; $password = $_POST['password']; $pwswdrd = md5($password); if(!empty($_POST['username'])) { $query = mysqli_query($con, "SELECT * FROM users where name = '$username' AND pass = '$pwswdrd'") or die(mysqli_connect_error()); $row = mysqli_fetch_array($query); if(!empty($row['name']) AND !empty($row['pass'])) { $_SESSION['username'] = $row['username']; $_SESSION['id'] = $row['id']; header('Location: index.php'); } } else { echo "You failed to log in."; } ?> - details.php <?php $one=mysqli_connect('.......webhost.com','aee','aaa') or die("Failed to connect to MySQL: " . mysqli_error() ); $db=mysqli_select_db($one,'aee') or die("Failed to connect to MySQL: " . mysqli_error() ); ?> -- What can possibly be wrong?! Okay, I can't seem to figure out why the form isn't pulling up. Here's what I'm trying to do. Administrator clicks on Add New Item to Inventory, pulling up the shops that are available to add inventory to. (This part appears to be working, because it does list those shops available). Then, the administrator will click on a shop name, opening up a form that will allow them to type in the name of the item they want to add. Instead, it goes to a blank screen, no errors even with error reporting on. adminpanel.php is the main file that houses all these functions. If you're familiar with EZRPG, it's the same basic setup, just with these additions to the list. Any help would be greatly appreciated! Thank you!! function addinv() { $query = doquery("SELECT id,name FROM shop ORDER BY name", "shop"); $page = "<b><u>Add Inventory</u></b><br />Click to add an item to a shop's inventory.<br /><br /><table width=\"50%\">\n"; $count = 1; while ($row = mysql_fetch_array($query)) { if ($count == 1) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">".$row["id"]."</td><td style=\"background-color: #eeeeee;\"><a href=\"admin_panel.php?do=addshopinv:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 2; } else { $page .= "<tr><td width=\"8%\" style=\"background-color: #ffffff;\">".$row["id"]."</td><td style=\"background-color: #ffffff;\"><a href=\"admin_panel.php?do=addshopinv:".$row["id"]."\">".$row["name"]."</a></td></tr>\n"; $count = 1; } } if (mysql_num_rows($query) == 0) { $page .= "<tr><td width=\"8%\" style=\"background-color: #eeeeee;\">No items found.</td></tr>\n"; } $page .= "</table>"; admindisplay($page, "Add Shop Inventory"); } function addshopinv($name) { if (isset($_POST["submit"])) { extract($_POST); $errors = 0; $errorlist = ""; if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; } else if ($errors == 0) { $query1 = doquery("SELECT * FROM items WHERE name=$name"); $item_id = mysql_fetch_array($query1); $query = doquery("INSERT INTO `sale` SET shop_id=".$row["id"].", item_id='$item_id',"); admindisplay("Inventory Item Added.","Add New Inventory Item"); } else { admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Add New Item to Shop"); } } $name = $page = <<<END <b><u>Add New Inventory Item</u></b><br /><br /> <form action="admin_panel.php?do=addshopinv:$name" method="post"> <table width="90%"> <tr><td width="20%">Name:</td><td><input type="text" name="name" size="30" maxlength="255" value="" />*255 character max</td></tr> </table> <input type="submit" name="submit" value="Submit" /> <input type="reset" name="reset" value="Reset" /> </form> END; $page = parsetemplate($page, $row); admindisplay($page, "Add New Inventory Item"); } Hello! Incredibly new to PHP, so if this problem is a clear error i apologise. I am developing a page which will display a product based on what is clicked as a result of a search, my problem is that no matter that happens I cannot display anything from the Products table in my database: Code: [Select] <?php session_start(); include "connect.php"; $prodsql="SELECT product_ID, product_Name, Category, Price, Information from Product ;"; $prodresult = mysqli_query($_SESSION['conn'], $prodsql); while ($prow = mysql_fetch_array($prodresult, MYSQL_NUM)) { echo "<p> $prow['product_Name']"; } else{ } What am i missing? The connect.php works as I can successfully login and register members. Thank you Hi go easy on me please, I'm a PHP newbie. I've got a HTML form that posts information to a PHP page. This PHP page runs some code and has a counterInt that is = 1 if everything is okay, and is = 0 otherwise. I want the PHP page to automatically redirect to another PHP page if counterInt = 1. But using the header() redirect thing apparently doesn't let me already have code before it. How can I make it redirect at the appropriate point in my code, if and only if counterInt is 1? Thanks very much . Hello,
I am having some troubles and was hoping someone could guide me through it.
Q: When ever I try call my get_status function all I get is a white page of nothing, no errors to work from etc... Can anyone here see what I am doing wrong?
PATH: index.php
NOTICE //<<-- KILLS PAGE
<?php spl_autoload_register(function ($class) { include '/lib/' . $class . '.inc'; }); $servers = new servers; echo $servers->get_servers(); echo "STATUS: ".$servers->get_status("0.0.0.0",80); //<<-- KILLS PAGE ?>Page works fine until I want to use the status function, I get no errors or anything just a blank page. PATH: Lib/Servers.inc NOTICE //<<-- KILLS PAGE <?php ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(E_ALL); error_reporting(-1); include_once '../../Global-Includes/ServerStatus/db-connect.php'; //namespace xStatus; class servers { private $db_Hostname = HOSTNAME; private $db_Username = USERNAME; private $db_Password = PASSWORD; private $db_Database = DATABASE; private $dbSQL = ''; function __construct() { } // End Construct public function get_servers(){ $db = new mysqli($this->db_Hostname,$this->db_Username,$this->db_Password,$this->db_Database); $message = ''; // list current servers from database $sql = "SELECT * FROM tbl_servers"; $res = $db->query($sql); if ($res->num_rows > 0) { $message = '<h3>Current Servers</h3>'; while ($row = $res->fetch_assoc()) { $message .= $row['HostGame'] . '<br>'; $message .= $row['HostIP'] . '<br>'; $message .= $row['HostPort'] . '<br>'; $message .= $this->get_status($row['HostIP'],$row['HostPort']) . '<br>'; //<<-- KILLS PAGE! } } $message .= "<br>End of the \"Server List\" "; return $message; } public function get_status(&$ServerIP,&$ServerPort){ if(@stream_socket_client("tcp://".$this.$ServerIP.":".$this.$ServerPort."", $errno, $errstr, 1) !== false) { return "Online"; } else { return "Offline"; } return "Offline"; } } // End class ?>Kind regards and thank you. Why doesn't this code work? I can't figure it out. Database information: DB: abelltx table: homework Fields in table: id, pid, uid, name, url, approved, comment, SubmissionTime <?PHP $link = mysql_connect('xxxxxx', 'xxxxx', 'xxxxxxx') or die(mysql_error()); mysql_select_db("abelltx", $link) or die(mysql_error()); $uid=abelltx $query = "SELECT DISTINCT name FROM homework ORDER BY id ASC"; $result = query_db($query); while ($myrow = mysql_fetch_array($result)) { echo $myrow[name].", "; } ?> I get the following error: "Parse error: syntax error, unexpected T_VARIABLE in D:\Hosting\5366560\html\test.php on line 6" Fairly new to PHP and have the following code which should simply output into 3 columns - I have checked the query which does work - so I dont understand why I get this error mysql_fetch_array() expects parameter 1 to be resource,
// Create connection
// Check connection
$sql = “SELECT * FROM duration_matched WHERE groupm = '”.$coincidence ."’";
// set up loop counter
// start table and first tr ’;
while ($row=mysql_fetch_array($result)) {
’;
// always output the td
’;
// then close off the last row and the table ’ . $row[‘image’] . ‘ ’; $conn->close(); I have a website for ordering business cards, and have encountered an error with either the HTML or PHP coding. The website has a form with several text boxes and drop-down menus to fill in the order form, and at the end after clicking the "submit" button, it generates an e-mail through a PHP script that sends the order form to the printer of the business cards. For some reason, whenever a user has a "job title" with the word "specialist" in it, the e-mail never gets sent. I removed all job titles from the one drop-down menu, to try and fix the problem, but now when users type "specialist" in the comments box at the bottom of the form, that blocks the e-mail from being sent as well. I have tried looking online for possible reasons why this one word would cause such a problem, but have not found the answer yet. Does anyone on this forum know why the word "specialist" would cause this issue, or know where I can look for a solution? If you can help me, that would be greatly appreciated. Thanks! I'm getting an error with this code:
<?php $bbreplace = array ( '/(\[[Bb]\])(.+)(\[\/[Bb]\])/', '/(\[[Ii]\])(.+)(\[\/[Ii]\])/', '/(\[[Uu]\])(.+)(\[\/[Uu]\])/', '/(\[[Ss]\])(.+)(\[\/[Ss]\])/', '/(\[url=http://)(.+)(\])(.+)(\[\/url\])/', '/(\[img\])(.+)(\[\/img\])/', '/(\[IMG\])(.+)(\[\/IMG\])/', '/(\[COLOR=)(.+)(\])(.+)(\[\/COLOR\])/', '/(\[color=)(.+)(\])(.+)(\[\/color\])/', '/(\[SIZE=)(.+)(\])(.+)(\[\/SIZE\])/', '/(\[size=)(.+)(\])(.+)(\[\/size\])/', '/(\[list\](.+)(\[\/list\])/', '/(\[list=1\](.+)(\[\/list\])/', '/(\[lLIST\](.+)(\[\/LIST\])/', '/(\[LIST=1\](.+)(\[\/LIST\])/', '/(\[*\](.+)/' ); $bbreplacements = array ( '<b>\\2</b>', '<i>\\2</i>', '<u>\\2</u>', '<s>\\2</s>', '<a href="\\2">\\4</a>', '<img src="\\2">', '<img src="\\2">', '<font color="\\2">\\4</font>', '<font color="\\2">\\4</font>', '<font size="\\2">\\4</font>', '<font size="\\2">\\4</font>', '<ul>\\2</ul>', '<ol>\\2</ol>', '<ul>\\2</ul>', '<ol>\\2</ol>', '<li>\\2</li>' ); $PostText = preg_replace($bbreplace, $bbreplacements, $PostText); This is what I have to do BB Codes so Far. Now when I go to view the thread I get: Warning: preg_replace() [function.preg-replace]: Compilation failed: missing ) at offset 25 in /home/rayth/public_html/forum/viewthread.php on line 95 Line 95: $PostText = preg_replace($bbreplace, $bbreplacements, $PostText); From testing I didn't get this error untill I added the tags I have a page that displayes a table from my database. What I'm attempting to do is create a page where you can delete rows of that table. I'm creating 3 pages 1( select the student or row to delete) 2( comfirm whether you want to delete that student) and 3( where the student has been deleted) I'm already having trouble with my first page. This is my code to select the row or student you want to delete: <?php Code: [Select] <?php include 'includes/config.php'; $delete_sql ="SELECT sno,cname, sname FROM student ORDER BY sno DESC"; $delete_query = mysql_query($delete_sql) or die(mysql_error()); $rsDelete = mysql_fetch_assoc($delete_query); ?> <html> <head> </head> <body> <p> select student to delete </p> <?php do {?> <p><a href="deletecomfirm.php?sno= <?php echo $rsDelete['sno']; ?>"> <?php echo $rsDelete['cname']; ?> by <?php echo $rsDelete['fname']; ?> </a> </p> <?php} while ($rsDelete = mysql_fetch_assoc($delete_query)) ?> </body> </html>?> I keep getting this error: Parse error: syntax error, unexpected $end in C:\Program Files\EasyPHP-5.3.3\www\Project\selectdelstudent.php on line 32 I'm assuming this error indicates an improper closing tag or something? Though I can't see my mistake. Also if you have any tips on improving my code feel free to comment so I have been making a php chat service, and when i use this code:
Welcome <?php echo $_COOKIE["username"]; ?><br> chatroom: <?php echo $_COOKIE["chatroom"]; ?> <?php $phpfile=$_COOKIE["chatroom"]; $chpage = $phpfile .".php"; $chtext = $phpfile .".txt"; $filename = $_COOKIE["chatroom"] . ".txt"; $myfile = fopen($filename, "r") or die("Unable to open file!"); fopen($myfile); fclose($myfile); include $chtxt; ?> <form action="post.php" method="post"> message: <input type="text" name="msg"><br> <input type="submit"> </form>I get a 403 error. I does anyone know that is wrong with the code? there are more files that set the cookies but they work fine. I can't find anything wrong. please help. Hi, I still a noob in PHP programming I hope somebody in the forum can help me and give an ideas how to fixed to this problem, everytime I run localhost this message appear: ErrorException in Builder.php line 1023:count(): Parameter must be an array or an object that implements CountableBut if I type localhost/(anycharacter) the page appear but with error 404(kindly refer to image, all other buttons are working except the one indicated with the arrow( kindly refer on the last image, note: app_debug set to true), this problem keeps bugging me for a few weeks now that I still cannot find a way to fixed it. Thank you in advance. )
Hi, I wrote a simple code to check to see if the user filled in the name field, but when I uploaded the file, it just displays the code. here 's the code. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $errors=array(); if(isset($_POST['submit'])) { validate_input(); if(count($errors) !=0) { display_form(); } else { display_form(); } } function validate_input() { global $errors; if($_POST['name'] == " "){ $errors['name']="dipshit, put your name"; } ?> <form action="" method="post" name="test"> Name: <input name="name" type="text" size="10" maxlength="15" value="<?php echo $_POST[name]; ?>"/><br /> <?php echo $errors['name']; ?> <input name="submit" type="button" value="submit" /> </form> </body> </html> <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); include 'helpers.php'; $foldername = uniqid(); $destination = "vierkant/$foldername"; $locatie = "circles/$foldername"; createDirectory($locatie); createDirectory($destination); $upload_files = []; for ($i = 0; $i < count($_FILES['file']['name']); $i++) { move_uploaded_file( $_FILES['file']['tmp_name'][$i], $destination . '/' . $_FILES['file']['name'][$i] ); $target_name = $_FILES['file']['name'][$i]; // Remove the extension and replace it with .png. imagepng(imagecreatefromstring(file_get_contents($_FILES["file"]["tmp_name"] )), "output.png"); // One method for this is to use the "explode" function with a dot as a delimiter. // variable we are going to split print_r (explode(".",$target_name)); // Then replace the last part with png and then stick the string back together with "implode" $upload_files[] = [ 'square' => $destination . '/' . $_FILES['file']['name'][$i], 'circle' => $locatie . '/' . $_FILES['file']['name'][$i], ]; } foreach ($upload_files as $loopdata) { print_r($loopdata['circle']); toCircle($loopdata['square'],$loopdata['circle'],'450'); }
I have to do this but i get this error: https://ibb.co/mFzxqXL can anyone help me? // Remove the extension and replace it with .png.
// variable we are going to split: // Then replace the last part with png and then stick the string back together with "implode" I'm in the mist of doing a login script for a new site. I have the script working, just as long as you get it right the first time, because after that, it seems to hang on the delay. Script is below
$("#login_button").click(function() { $.post("inc/login.php", $("#loginForm").serialize(), function(data) { var login = data.login; var message = data.message; if(login == true) { $("#login").empty().delay(5000).fadeOut('slow'); } if(login == false) { $("#login_window").css('visibility','hidden'); $("#message").css('visibility','visible').html(message); $("#message").delay(4000).queue(function() { $("#message").empty().css('visibility','hidden'); $("#login_window").css('visibility','visible'); }); } }, "json"); });Basically, its supposed to show the returned error message for 4 seconds, then show the login form again. I'm using a regular button, not the submit type button. I don't have any errors in firebug. Anyone have any ideas? (i know about show and hide, but those caused entirely to many problems). Edited by richei, 14 May 2014 - 11:54 PM. Hey all, Basically I have this code which technically should work, but I have put an error in the logic somewhere and am really struggling to find it, I've been going over it for about an hour now :/ The error is that in the second part (// Enter them into the activities database if they're not already there), it won't enter them, and it won't show the word 'Randomevent1' either, so clearly somehow I have put in something to prevent it performing that step. Can anybody help me out? I'd be amazingly grateful, I have no clue how I've screwed it up. if(isset($_POST['submit'])){ $ownerid = $_SESSION['id']; // If completed = Y give an error $completeyn = "SELECT completed FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $completecheck=mysql_query($completeyn) or die(mysql_error()); while($row = mysql_fetch_array( $completecheck )) { if($row['completed'] == 'Y'){ echo 'Oops, you\'ve already done this twice today!';} else { // Enter them into the activities database if they're not already there $stepno2 = "SELECT playerno, timesdone FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $stepnoanswer2=mysql_query($stepno2) or die(mysql_error()); $num_rows2 = mysql_num_rows($stepnoanswer2); echo $num_rows2; if($num_rows2 == '0'){ $putintodb2 = mysql_query("INSERT INTO activities (playerno, activityno, timesdone) VALUES ('$ownerid', '1', '1')") or die("Error: ".mysql_error()); echo 'Randomevent1'; }else{ // If they are already there update their stepcount $updatestepcount2=("UPDATE activities SET timesdone=timesdone+'1' WHERE playerno='$ownerid' AND activityno = '1'"); $newstepcount2=mysql_query($updatestepcount2); echo 'Randomevent2';} // If this new stepcount is equal to 2, set completed to Y $checkstep = "SELECT timesdone FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $checkstepresult=mysql_query($checkstep) or die(mysql_error()); while($row = mysql_fetch_array( $checkstepresult )) { if($row['timesdone'] == '2'){ echo $row['timesdone']; $updatestepcount22=("UPDATE activities SET completed = 'Y' WHERE playerno='$ownerid' AND activityno = '1'"); $newstepcount22=mysql_query($updatestepcount22); } }}}} please can you help .. I'm passing a value from another page using $_SESSION and trying to then use it in a SELECT statement in SQL think I'm missing something ... if hard code the value it works , and I have also checked at the other end that the variable is being assigned ...
code is (its the = $_SESSION['g_district'] "); that's causing the issue
I'm getting Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /Applications/XAMPP/xamppfiles/htdocs/mytimekeeper/add/add.php on line 170 in the browser <div class="row s2 m2 l2"> <div> <label for="course_id">Choose the course raced:</label> <select name="course_id"> <?php // query to create course_id dropdown $resultset = $conn->query("SELECT `course_id`,`course_name` FROM `tbl_courses` WHERE `district`= $_SESSION['g_district'] "); while($row = $resultset->fetch_assoc()) { echo "<option value='{$row[course_id]}'>{$row['course_name']}</option>"; } ?> </select>
Hey guys, If my php looks like this: (notify if errors) <?php $user=$_POST['user']; $pass=$_POST['pass']; if(($user=="testing") && ($pass=="testing123")) echo "Access Granted"; if other echo "Access Denied!" ?> If after the "Access Granted" It could redirect the user to another webpage, index2.html for instance. Thanks in advance |