Hello,

I'm normally pretty good with PHP but since updating to the latest version I can't seem to get most my script's to work.

I am trying to pull two variables, from the database and count how many row's there are.

$query = mysql_query("SELECT * FROM notifications WHERE to='$username' AND read='unread'") or die(mysql_error());
        	
        	$totalNotif = mysql_num_rows($query);

The Error's I am getting are:

With die(): 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='kris' AND read='unread'' at line 1

With out die(): Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\Portal\index.php on line 174
Call Stack
# Time Memory Function Location
1 0.0005 724560 {main}( ) ..\index.php:0
2 0.0017 733312 mysql_num_rows ( ) ..\index.php:174

I do have $username set.

Thanks,

Kris

to and read are reserved words, use backticks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.