pro_se Posted August 26, 2006 Share Posted August 26, 2006 hey guys! i have a query to see if a certain user has messages... it is not working right... here it is: [code]<?php $username = $_SESSION['username']; $new = 'new';$sql_query2 = "SELECT * FROM messages WHERE toname='$username' and read='$new'";$result2 = mysql_query($sql_query2);$rows2 = mysql_num_rows($result2); if ($rows2==0) { echo ''; } else { echo "<span style=color:#0000FF; background-color:#BED5E7><strong><a href=messagecenter.php>You have a new message!</a></strong></span><br>";} ?>[/code]it gives me a supplied argument error? it would be cool if you'd help! Quote Link to comment Share on other sites More sharing options...
AdRock Posted August 26, 2006 Share Posted August 26, 2006 try thisecho "<span style=\"color:#0000FF; background-color:#BED5E7\"><strong><a href=\"messagecenter.php\">You have a new message!</a></strong></span><br>";} ?> Quote Link to comment Share on other sites More sharing options...
pro_se Posted August 26, 2006 Author Share Posted August 26, 2006 still says: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/userhome.php on line 163 Quote Link to comment Share on other sites More sharing options...
AdRock Posted August 26, 2006 Share Posted August 26, 2006 what does line 163 say? Have you connected to the database (or is that a silly question?) Quote Link to comment Share on other sites More sharing options...
pro_se Posted August 26, 2006 Author Share Posted August 26, 2006 $rows2 = mysql_num_rows($result2); Quote Link to comment Share on other sites More sharing options...
pro_se Posted August 26, 2006 Author Share Posted August 26, 2006 im sure i did... i will check.. Quote Link to comment Share on other sites More sharing options...
pro_se Posted August 26, 2006 Author Share Posted August 26, 2006 yup... connected Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 27, 2006 Share Posted August 27, 2006 The error is caused by having a database table field named 'read'. READ is a reserved word in MySQL -> http://www.htmlite.com/mysql002a.phpChange read to something else (not reserved), e.g. msg_read Quote Link to comment Share on other sites More sharing options...
pro_se Posted August 27, 2006 Author Share Posted August 27, 2006 oh okay.. thanks maan.. Quote Link to comment Share on other sites More sharing options...
Aurorius Posted August 27, 2006 Share Posted August 27, 2006 or you can change [b]read[/b] to [b]`read`[/b] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.