Syntax Error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
BigAbe
Forum Commoner
Posts: 66
Joined: Fri Mar 31, 2006 7:41 pm

Syntax Error

Post by BigAbe »

Code: Select all

$bb = "SELECT COUNT (*) AS count FROM ads WHERE (adActive = 1)";

$getcount2 = mysql_query($bb) or die(mysql_error());

while($row2 = @mysql_fetch_array($getcount))
	$total = $row2["count"];
Firefox tells me 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 '(*) AS ct FROM ads WHERE (adActive = 1)' at line 1
Any thoughts?

-- Abe --
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

COUNT is a function, remove the space between it and the first paren.
BigAbe
Forum Commoner
Posts: 66
Joined: Fri Mar 31, 2006 7:41 pm

Post by BigAbe »

feyd wrote:COUNT is a function, remove the space between it and the first paren.
Thanks!
Post Reply