Click here to Skip to main content
15,900,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
why i am seeing the error on the screen when i try to select result from postgres database

syntax error at or near "s" LINE 1

PHP
$product_name="Do U Speak Green? - Tiger Stripes Men's Crew Neck T Shirt";

$farr=pg_query("select * from product where product_name='$product_name'");

while($row1=pg_fetch_array($farr))
{
$product_id=$row1['product_id'];

echo "  -  ".$product_id;
}
Posted
Comments
Mohibur Rashid 6-Aug-13 10:47am    
What version of php are you using? your error does not make sense;
G4mm4R4y 6-Aug-13 14:15pm    
I too, do not know what he (or the error) is trying to say

PHP
$product_name="Do U Speak Green? - Tiger Stripes Men's Crew Neck T Shirt";
 
addslashes($product_name);

$farr=pg_query("select * from product where product_name='$product_name'");
 
while($row1=pg_fetch_array($farr))
{
$product_id=$row1['product_id'];
 
echo "  -  ".$product_id;
}
 
Share this answer
 
Comments
Mohibur Rashid 6-Aug-13 23:52pm    
So, your problem was not in line number 1?
 
Share this answer
 
Comments
Mohibur Rashid 6-Aug-13 10:46am    
useless suggestion.
wladimirbm 7-Aug-13 3:38am    
look, in string line you have single quot like - '
when complete sql query to mysql sent line -
select * from product where product_name='Do U Speak Green? - Tiger Stripes Men's Crew Neck T Shirt'
and now count of quot - 3!!!
you search line = 'Do U Speak Green? - Tiger Stripes Men' and after this left symbols
because you must escape quot which in $product_name
for this have function http://www.php.net/en/function.addslashes.php, read please description, there is exsample for you
Mohibur Rashid 7-Aug-13 5:34am    
Why do you think I didn't see that? I saw that, I ignore that, cause his question does not say he has problem with his Query, his question says, he has problem with Syntax at line 1.
wladimirbm 7-Aug-13 6:26am    
OMG
wladimirbm 7-Aug-13 3:41am    
$product_name=addslashes("Do U Speak Green? - Tiger Stripes Men's Crew Neck T Shirt");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900