Error message:

Query failed: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 ')' at line 1

--------------------------------------
Can any one able to edit it in correct form?(*I using PHP5)
----------------------------------------------


$

query="select count(*) from cart where cookieId ='GetCartId()'
and bookid = '$bookid'";

Type the following after you declare the $query variable:

echo $query;

You should then be able to debug your query. If not, post what you get here.

Error message:

Query failed: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 ')' at line 1

--------------------------------------
Can any one able to edit it in correct form?(*I using PHP5)
----------------------------------------------


$

query="select count(*) from cart where cookieId ='GetCartId()'
and bookid = '$bookid'";

Hello cty ,

According to your SQL statement that is embeded in your PHP code, there is a very simple mistake which is : take a look at your SQL statement , the second condition in the WHERE Clause which is -
bookid = '$bookid'; - there has to be two dots , one before the $ sign in the variable and one after the variable , also there has to be double quotes before the single quotes, so it should look like this :
bookid = "'.$bookid.'";

So your query will be like this :

query="select count(*) from cart where cookieId ='GetCartId()'
and bookid = "'.$bookid.'" ";

So, please try it and see if it works , and please reply me whether it worked or not , because this was from my experience using PHP With MySQL ..

Hope it works well .. ;)
looking forward for your reply ,

Best regards
Joseph.G.Hodali

Sorry joseph.hodali you are wrong. The bookid part is ok, except from the fact that he needs to user {$bookid} when using variables inside double quotes. The {} define the beginning and end of a varibale inside double quotes. This makes it possible to do

$string="{$array['id']} bla bla.";

The problem is the function GetCartId(), if its an sql function you don't use the single quotes, but I bet its an php function and you can not include a function inside a string. Try this it should function better.

$cartId = GetCartId();
$query="select count(*) from cart where cookieId ='{$cartId}'and bookid = '{$bookid}'";
This article has been dead for over six months. Start a new discussion instead.