www.webdeveloper.com
Results 1 to 3 of 3

Thread: MySQL server version for the right syntax to use near ',)' at line 1

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    MySQL server version for the right syntax to use near ',)' at line 1

    Hi Everyone


    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

    <?php

    $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);
    include "js/code.js";
    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

    thanks

    Jamie

  2. #2
    Join Date
    Sep 2008
    Posts
    95
    Hello Jamie,

    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?

  3. #3
    Join Date
    Aug 2012
    Posts
    155
    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.
    PHP Code:
    $query "SELECT * FROM vehicles WHERE live = 1 AND page = '".$page."'"

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles