Jump to content

Archived

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

pro_se

[solved] you have messages!

Recommended Posts

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!

Share this post


Link to post
Share on other sites
try this

echo "<span style=\"color:#0000FF; background-color:#BED5E7\"><strong><a href=\"messagecenter.php\">You have a new message!</a></strong></span><br>";} ?>

Share this post


Link to post
Share on other sites
still says: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/userhome.php on line 163

Share this post


Link to post
Share on other sites
what does line 163 say?  Have you connected to the database (or is that a silly question?)

Share this post


Link to post
Share on other sites
The error is caused by having a database table field named 'read'. READ is a reserved word in MySQL -> http://www.htmlite.com/mysql002a.php

Change read to something else (not reserved), e.g. msg_read

Share this post


Link to post
Share on other sites

×

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.