| | |
Qeury problem(plz help)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2006
Posts: 10
Reputation:
Solved Threads: 0
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)
----------------------------------------------
$[PHP]query="select count(*) from cart where cookieId ='GetCartId()'
and bookid = '$bookid'";[/PHP]
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)
----------------------------------------------
$[PHP]query="select count(*) from cart where cookieId ='GetCartId()'
and bookid = '$bookid'";[/PHP]
•
•
Join Date: Sep 2006
Posts: 23
Reputation:
Solved Threads: 0
Type the following after you declare the $query variable:
You should then be able to debug your query. If not, post what you get here.
php Syntax (Toggle Plain Text)
echo $query;
You should then be able to debug your query. If not, post what you get here.
Simple PHP Pagination - No Database Required.
If you like it, give me some props. ;)
If you like it, give me some props. ;)
•
•
Join Date: Nov 2005
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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)
----------------------------------------------
$[PHP]query="select count(*) from cart where cookieId ='GetCartId()'
and bookid = '$bookid'";[/PHP]
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
•
•
Join Date: Dec 2006
Posts: 33
Reputation:
Solved Threads: 0
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 [php]$string="{$array['id']} bla bla.";[/php]
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.
[php]$cartId = GetCartId();
$query="select count(*) from cart where cookieId ='{$cartId}'and bookid = '{$bookid}'";[/php]
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.
[php]$cartId = GetCartId();
$query="select count(*) from cart where cookieId ='{$cartId}'and bookid = '{$bookid}'";[/php]
Last edited by remcov; Dec 21st, 2006 at 1:19 pm.
![]() |
Similar Threads
- Problem, plz help (C)
- public pathroom problem (plz help) (Java)
- problem with connection to sql server (ASP.NET)
- Page Cannot Be Displayed/... PLZ HELP? (Windows NT / 2000 / XP)
- weird problem (Troubleshooting Dead Machines)
- A Small Problem ....plz Help Me Out.... (C)
Other Threads in the PHP Forum
- Previous Thread: About Imagemagick
- Next Thread: hi everyone..
| Thread Tools | Search this Thread |
apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date display dynamic echo email error fcc file files folder form forms freelancing function functions google href htaccess html image include incode insert integration ip javascript joomla limit link login mail match menu method mlm mod_rewrite multiple mysql oop pageing pagerank paypal pdf php problem query radio random recursion recursiveloop remote script search server sessions sms smtp soap source space sql strip_tags subversion support! survey syntax system table template tutorial undefined update upload url validator variable video virus web window.onbeforeunload=closeme; youtube





