Jump to content


Photo

[solved] you have messages!


  • Please log in to reply
9 replies to this topic

#1 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 26 August 2006 - 11:29 PM

hey guys! i have a query to see if a certain user has messages... it is not working right... here it is:
<?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>";} ?>
it gives me a supplied argument error? it would be cool if you'd help!

#2 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 26 August 2006 - 11:39 PM

try this

echo "<span style=\"color:#0000FF; background-color:#BED5E7\"><strong><a href=\"messagecenter.php\">You have a new message!</a></strong></span><br>";} ?>
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#3 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 26 August 2006 - 11:41 PM

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

#4 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 26 August 2006 - 11:41 PM

what does line 163 say?  Have you connected to the database (or is that a silly question?)
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#5 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 26 August 2006 - 11:42 PM

$rows2 = mysql_num_rows($result2);

#6 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 26 August 2006 - 11:44 PM

im sure i did... i will check..

#7 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 26 August 2006 - 11:45 PM

yup... connected

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 27 August 2006 - 12:08 AM

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
Legend has it that reading the manual never killed anyone.
My site

#9 pro_se

pro_se
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts

Posted 27 August 2006 - 12:18 AM

oh okay.. thanks maan..

#10 Aurorius

Aurorius
  • New Members
  • Pip
  • Newbie
  • 4 posts
  • LocationMalaysia

Posted 27 August 2006 - 04:06 AM

or you can change read to `read`




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users