WTF is wrong with this?!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

WTF is wrong with this?!

Post by Terencentanio »

Code: Select all

$msgs = "SELECT * FROM rs2_msgs WHERE to = '$logged'";
$mresult = mysql_query($msgs);
$mnum = mysql_numrows($mresult);
Someone see an error? 'cos I can't.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

mysql_num_rows($mresult);
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

And what's wrong with it?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

change

Code: Select all

mysql_numrows($mresult);
to

Code: Select all

mysql_num_rows($mresult);
from php.net
For downward compatibility mysql_numrows() can also be used. This is deprecated however.
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

That doesn't work either.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What exackly is being returned? Any output?
Are you sure your query is matching any rows?
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

Yep. The "to" is the same as the "logged" ... but it won't return owt.
HormonX
Forum Commoner
Posts: 50
Joined: Tue Dec 10, 2002 7:43 pm
Location: Toronto

Re: WTF is wrong with this?!

Post by HormonX »

$mresult = mysql_query($msgs);


this is missing one variable and that would be a link indentifier.
$mresult = mysql_query($msgs , $link);
hopefully that helps.

Greg
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

And what's the link for?

I have used this code so many times, it just isn't working now.

If I remove the "WHERE --" from the SQL, it works fine... but that's no good.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

A longshot but try

Code: Select all

$msgs = "SELECT * FROM `rs2_msgs` WHERE `to` = '".trim($logged)."'";
Terencentanio
Forum Commoner
Posts: 27
Joined: Mon Dec 06, 2004 10:32 am
Location: England

Post by Terencentanio »

w00t. works :D Thanks.
mrmachoman
Forum Newbie
Posts: 5
Joined: Sat Jan 22, 2005 6:36 pm

Post by mrmachoman »

I fear you were having problems since "to" is a SQL reserved word. Be very careful when using reserved words in your DB.
Post Reply