beansandsausages Posted November 28, 2007 Share Posted November 28, 2007 Hello all, I have a problem and its confusing me. Here got i have 2 mysql querries, one to retrive user info and a second to get new posts, But the one to retrive posts works and other doesnt. code is : <?php session_start(); $title = "SeverancE Dawn of Destruction - Logged In "; $location = "Logged In"; include("connect.php"); // update stuff $update_ip = mysql_query("UPDATE `users` SET ip='$_SERVER[REMOTE_ADDR]' WHERE username='$_SESSION[username]'"); $update_location = mysql_query("UPDATE `users` SET page='$location' WHERE username='$_SESSION[username]'"); $update_time = mysql_query("UPDATE `users` SET times_on=times_on+'1' WHERE username='$_SESSION[username]'"); // player info stuff error here. $check = mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) $get_news = mysql_query("SELECT * FROM news order by id desc limit 0, 5"); while($news = mysql_fetch_array($get_news)) if($_SESSION['valid']) { echo " Welcome back <font color=\"black\">$info[username]</font>. Currently you have logged in <font color=\"black\">$info[times_on]</font> times. <br /><br /> <u><strong>Current Game Messages</srtong></u> "; echo "<br /> "; echo " Message Poster : <font color=\"black\"> $news[by] </font> "; } else { echo 'You must login to view this page.'; } include("bottom.php"); ?> but if i swap the queries round, ie put bottom on top and top on bottom then the other one works. if you get what i am trien to say. $check = mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) $get_news = mysql_query("SELECT * FROM news order by id desc limit 0, 5"); while($news = mysql_fetch_array($get_news)) like the bottom query will work and top one wont. but if i swap it found then the top one works but bottom wont. Link to comment https://forums.phpfreaks.com/topic/79295-solved-got-a-problem/ Share on other sites More sharing options...
Wes1890 Posted November 28, 2007 Share Posted November 28, 2007 Take out the "while".. change to $check = mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'")or die(mysql_error()); $info = mysql_fetch_array($check); $get_news = mysql_query("SELECT * FROM news order by id desc limit 0, 5"); $news = mysql_fetch_array($get_news); Link to comment https://forums.phpfreaks.com/topic/79295-solved-got-a-problem/#findComment-401363 Share on other sites More sharing options...
beansandsausages Posted November 28, 2007 Author Share Posted November 28, 2007 shit yeah, thank you mate, looking at the script for hours i missed that. Link to comment https://forums.phpfreaks.com/topic/79295-solved-got-a-problem/#findComment-401450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.