MySQL server version for the right syntax to use near ',)' at line 1
I have this code to show records from MySQL database in a table named vehicles, getting the following error, please help:
I have just moved this site from another server, were it was working fine, thanks for looking
$query = "SELECT * FROM ".$CFG->db_name.".vehicles WHERE live = '1' AND page = '".$page."'";
$q = mysql_query($query);
if (!$q) echo mysql_error();
if (mysql_num_rows($q) > 0)
$count = 1;
$prodno = mysql_num_rows($q);
while ($r = mysql_fetch_array($q))
this is what it says in my browser;
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 '-web654fdh.vehicles WHERE live = '1' AND page = 'machinery'' at line 1
Is it possible to replace ".$CFG->db_name." with a static database name and see if the issue persists?
If it does, is there a new error message?
If there is no error with a static name, we need to look at what $CFG->db_name contains. For example, does the database name contain a space character?
Why are you putting your database name in your query, it is not needed (in fact I have never seen that before)?
Just change your query to below and see what happens.
$query = "SELECT * FROM vehicles WHERE live = 1 AND page = '".$page."'";
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)