Jump to content

Personal messages error?


WhiteShade6

Recommended Posts

So I'm making personal messages in my site and for some reason they wont work. Here is my code for displaying messages:

 

				 $query="SELECT * FROM messages WHERE recipient=$user_id ORDER BY id DESC";
			 $result=mysql_query($query) or die(mysql_error());
			 while($row = mysql_fetch_array($result))
			 	{
				$msg_id=mysql_real_escape_string($row['sender']);
				$qu=mysql_query("SELECT username FROM users WHERE id='".$msg_id."' LIMIT 1"); list($quu)=mysql_fetch_array($qu);
				echo '<tr><td>'.$row['title'].'</td><td><a href="users?id='.$msg_id.'">'.$quu.'</a></td><td>'.$row['date'].'</td></tr>';
				}

 

Now this is what I get:

 

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 'ORDER BY id DESC' at line 1

 

Some useful information:

[*]I already echoed $user_id, it is 1, and it is an integer, not a string.

[*]The database is connected, and messages is a table. "recipient" is a field (int[11]), and so is "id".

 

Any help would be appreciated! thanks!

Link to comment
https://forums.phpfreaks.com/topic/174270-personal-messages-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.