SELECT * FROM onlinepg as pg, pg_rooms as rooms WHERE pg.pg_id=rooms.pg_id and pg.status=0 AND ( rooms.roomtype='Sharing Basis' )
How I can write above query in PHP.. so that I can run successfully on mysql.
SELECT * FROM onlinepg as pg, pg_rooms as rooms WHERE pg.pg_id=rooms.pg_id and pg.status=0 AND ( rooms.roomtype='Sharing Basis' )
How I can write above query in PHP.. so that I can run successfully on mysql.
I Knew all above stuffs.. But when I run above sql I got error on server.. Actually it is running on local but not on server..
**SQL query failed. Check your query.
Error Returned: 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 '\'Sharing Basis\' )' at line 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'Sharing Basis\' )' at line 1
**
Is roomtype a varchar? Perhaps a column is missing? Compare both tables, something must be off.
'\'Sharing Basis\' )'
looks like a missuse of mysql_real_escape_string
can u post the php-code used to create the query?
if(!(empty($roomtype)))
{
foreach($roomtype as $r)
$rr.="rooms.roomtype='$r' or ";
if(strlen($rr)==0)
$rr="";
else
{
$rr = substr($rr, 0, -3);
$rr=" AND ( $rr ) ";
}
}
Error Returned: 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 '\'Sharing Basis\' )' at line 1You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'Sharing Basis\' )' at line 1
when you see that it's usually something quite close just before '\'Sharing Basis\' )'
such as a missing comma, or empty number variable or extra/missing brackets.
Basically mysql is evaluating your query and that is the first part that doesn't make sense based on what was said before it
get php to print out the query it is running to the page just before it runs it so you can see what it is doing eg.
$query = "blah blah";
echo $query;
mysql_query($query);
Echoing Sql query and running that on server does not have problem. Actaully, it is running on local but not on Server.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.