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! Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/ 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>";} ?> Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80938 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 Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80939 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?) Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80940 Share on other sites More sharing options...
pro_se Posted August 26, 2006 Author Share Posted August 26, 2006 $rows2 = mysql_num_rows($result2); Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80941 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.. Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80944 Share on other sites More sharing options...
pro_se Posted August 26, 2006 Author Share Posted August 26, 2006 yup... connected Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80945 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 Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80951 Share on other sites More sharing options...
pro_se Posted August 27, 2006 Author Share Posted August 27, 2006 oh okay.. thanks maan.. Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80954 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] Link to comment https://forums.phpfreaks.com/topic/18764-solved-you-have-messages/#findComment-80998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.