Jump to content

[SOLVED] got a problem.


burnside

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.