GateGuardian Posted June 25, 2008 Share Posted June 25, 2008 I get blank pages with my code: when a user logs in, its takes them to checklogin.php and just displays Connected to MySQL Connected to Database And nothing else If i go to members.php it displays the same thing Ive got this error before: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM userinfo .......... If i remove: //Main query for user info $query = "SELECT Username, Age, Sex, Location, Picture, Race, Class FROM usersinfo WHERE Username ='$usernamesession'"; $result = mysql_query($query) or die(mysql_error()); //Place query data into variables $row = mysql_fetch_assoc($result) or die(mysql_error()); //changed// extract($row, EXTR_PREFIX_SAME, "prefix123"); ?> In members.php it displays the table with lots of not found variable messages opendb.php <?php mysql_connect("localhost", "game", "test") or die(mysql_error()); echo "Connected to MySQL<br />"; mysql_select_db("Game") or die(mysql_error()); echo "Connected to Database<br />"; ?> checklogin.php <?php //Includes include 'Libary/opendb.php'; //Get user posted info $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection $myusername = stripslashes($myusername); $myusername = mysql_real_escape_string($myusername); $sql="SELECT * FROM usersinfo WHERE Username='$myusername' AND Password='$mypassword'"; $result=mysql_query($sql) or die(mysql_error()); // Mysql_num_row is counting rows returned $count=mysql_num_rows($result) or die(mysql_error()); ; // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "members.php" session_start(); session_register("myusername"); session_register("mypassword"); $_SESSION['Username']=$myusername; header("location:members.php"); } else { echo "Wrong Username or Password"; } ?> members.php <?php error_reporting(E_ALL); //session name grab and page auth session_start(); $usernamesession = $_SESSION['Username']; if(!session_is_registered('myusername')){ header("location:index.html"); } ?> <!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=iso-8859-1" /> <title>Members Page</title> <style type="text/css"> <!-- body { background-color: #666666; } --> </style></head> <body> <p> <?php //Includes include 'Libary/opendb.php'; //Main query for user info $query = "SELECT Username, Age, Sex, Location, Picture, Race, Class FROM usersinfo WHERE Username ='$usernamesession'"; $result = mysql_query($query) or die(mysql_error()); //Place query data into variables $row = mysql_fetch_assoc($result) or die(mysql_error()); //changed// extract($row, EXTR_PREFIX_SAME, "prefix123"); ?> </p> <table width="257" border="1"> <tr> <td colspan="2"><img src="<?php echo $Picture; ?>" alt="Profile Picture" /> </tr> <tr> <td width="133">Username</td> <td width="108"><?php echo $row['Username']; ?> </td><!-- This should echo out like this, and not a variable like before as the variable wasn't set--> </tr> <tr> <td>Age:</td> <td><?php echo $Age; ?> </td> </tr> <tr> <td>Sex:</td> <td><?php echo $Sex; ?> </td> </tr> <tr> <td>Location:</td> <td><?php echo $Location; ?> </td> </tr> <tr> <td>Race:</td> <td><?php echo $Race; ?> </td> </tr> <tr> <td>Class:</td> <td><?php echo $Class; ?> </td> </tr> </table> <?php include 'Libary/closedb.php'; ?> <p> </p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/111773-phpmysql-problem/ Share on other sites More sharing options...
teng84 Posted June 25, 2008 Share Posted June 25, 2008 $count=mysql_num_rows($result) or die(mysql_error()); ; Link to comment https://forums.phpfreaks.com/topic/111773-phpmysql-problem/#findComment-573842 Share on other sites More sharing options...
GateGuardian Posted June 25, 2008 Author Share Posted June 25, 2008 $count=mysql_num_rows($result) or die(mysql_error()); ; fixed it, still displays the same thing.. Link to comment https://forums.phpfreaks.com/topic/111773-phpmysql-problem/#findComment-573845 Share on other sites More sharing options...
GateGuardian Posted June 25, 2008 Author Share Posted June 25, 2008 Anyone? Link to comment https://forums.phpfreaks.com/topic/111773-phpmysql-problem/#findComment-574466 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.