PDA

View Full Version : Anybody see the problem in this?



.:.:jjm261:.:.
27-09-2008, 11:10 AM
$new = mysql_query("select * from pm where readdate = '0' and to = '$logged[id]'");
$new = mysql_num_rows($new);which should select all the rows from pm where readdate=0 and the to=the logged user

then further down i've got this


- <a href=\"messages.php\">Private Messages ($new New)</a><br />I'm using the techtuts system but with a different database structure, but it doesnt seem to change even if i make it simple and put select from pm where to = 2

but nuffink :(

Sorry i forgot to say my error, it says ( New) as in theres no new, but there is new ones

Jxhn
27-09-2008, 12:17 PM
I don't know much about php or mysql, but shouldn't it be something like this:

$new = mysql_query("select * from ´pm´ where ´readdate´ = '0' and ´to´ = '$logged[id]'");
$new = mysql_num_rows($new);

Decode
27-09-2008, 12:23 PM
$new = mysql_query( "SELECT * FROM pm WHERE readdate = '0' AND to = '{$logged[id]}'" ) or die( mysql_error( ) );
$new = mysql_affected_rows( );

.:.:jjm261:.:.
27-09-2008, 01:00 PM
Well apparantly it was in the wrong place =[ i'm stupid

but now i'm getting this error



Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/easymitc/public_html/Feudel/arcade/mattssystem/login.php on line 145

and with your code i'm getting this

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to = '2'' at line 1

L?KE
27-09-2008, 10:03 PM
Don't use $new twice.

I'm not sure if that's it but I did it once and php didn't like it.

Decode
28-09-2008, 09:08 AM
Don't use $new twice.

I'm not sure if that's it but I did it once and php didn't like it.

That has nothing to do with the problem...

I think its because you are using "to" as a column name, so mysql thinks you are trying to get it to do an action. (Im not 100% sure!)

.:.:jjm261:.:.
28-09-2008, 09:25 AM
Yes, it was that,

i did the query in phpmyadmin and it showed to as a function so i put it in ` and it worked

Thanks for all your help

Want to hide these adverts? Register an account for free!