GateGuardian Posted June 22, 2008 Share Posted June 22, 2008 Now if someone finds that ive made really simple mistake im gonna laugh so much as me and my friends have been unable to work out why my queried data isnt been echo'd out! Heres a link to my full code (including SQL for table setup) http://www.mediafire.com/?z20w39ga1xw Thanks alot Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/ Share on other sites More sharing options...
GateGuardian Posted June 22, 2008 Author Share Posted June 22, 2008 Anyone? I can just post all the code if you don't want to download the files Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/#findComment-571635 Share on other sites More sharing options...
jj20051 Posted June 22, 2008 Share Posted June 22, 2008 Go Ahead. I'm Not Very Good, but I Ocasionally Find The Problem. Try To Only Post What you Think Has the Error... ( and A Little More Details About The Script ) Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/#findComment-571637 Share on other sites More sharing options...
peranha Posted June 22, 2008 Share Posted June 22, 2008 We also need to know the problem. is it supposed to echo something, what is it supposed to do. Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/#findComment-571638 Share on other sites More sharing options...
kenrbnsn Posted June 22, 2008 Share Posted June 22, 2008 Tell us what your code is supposed to do & what problem(s) you're having. The post the relevant sections of your code. Ken Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/#findComment-571644 Share on other sites More sharing options...
GateGuardian Posted June 22, 2008 Author Share Posted June 22, 2008 Ok code: Its suppose to query for data on the members.php page, store them as varaible using the extract() function, then echo them out later in the page into a table Problem is i keep ending up with a blank HTML table with no data being echoed in it checklogin.php <?php //Includes include 'Libary/opendb.php'; //Get user posted info $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $encrypted_mypassword=md5($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"; } include 'Libary/closedb.php'; ?> 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 FROM usersinfo WHERE Username ='$usernamesession'"; $result = mysql_query($query) or die(mysql_error()); //Place query data into variables $row = mysql_fetch_array($result) or die(mysql_error()); extract($row, EXTR_PREFIX_SAME, "prefix123"); ?> </p> <table width="257" border="1"> <tr> <td colspan="2"><img src="<?php echo $Picture; ?>"/></td> </tr> <tr> <td width="133">Username</td> <td width="108"><?php echo $Username; ?> </td> </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> </table> <?php include 'Libary/closedb.php'; ?> <p> </p> </body> </html> opendb.php <?php $conn = mysql_connect("localhost", "testdatabase", "test") or die(mysql_error()); echo "Connected to MySQL<br />"; mysql_select_db("testdatabase") or die(mysql_error()); echo "Connected to Database<br />"; ?> closedb.php <?php mysql_close($conn) or die(mysql_error()); echo "<p><b>Database Closed</b>"; ?> Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/#findComment-571711 Share on other sites More sharing options...
GateGuardian Posted June 22, 2008 Author Share Posted June 22, 2008 I hate to double post all the time But will someone give it a look over? Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/#findComment-571769 Share on other sites More sharing options...
DeanWhitehouse Posted June 23, 2008 Share Posted June 23, 2008 I think you should change this <?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 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; ?>"/></td> </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> </table> <?php include 'Libary/closedb.php'; ?> <p> </p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/#findComment-571925 Share on other sites More sharing options...
DarkWater Posted June 23, 2008 Share Posted June 23, 2008 Why are you using the deprecated session_register functions? Link to comment https://forums.phpfreaks.com/topic/111348-baffaling-problem/#findComment-571926 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.