+ Reply to Thread
Results 1 to 10 of 10

Thread: MySQL Error

  1. #1
    YamiKaitou's Avatar
    YamiKaitou is offline x10 Elder YamiKaitou is an unknown quantity at this point
    Join Date
    Oct 2006
    Posts
    636

    MySQL Error

    How can I fix this error?

    Error: 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 ' `Reinstallation of database`)' at line 1

    Code dealing with that line:
    Code:
    		$reason = "\'Reinstallation of database\'";
    		$log = "INSERT INTO `develop_log` (`Num`, `User`, `Action`) VALUES (NULL, $id, $reason);";
    		mysql_query($log) or die (mysql_error());
    &id is defined elsewhere

  2. #2
    Micro is offline Retired staff (11-12-2008) Micro is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    West Midlands
    Posts
    1,301

    Re: MySQL Error

    put $id and $reason into {} -- eg {$id} {$reason}
    Micro

  3. #3
    dest581 is offline x10 Lieutenant dest581 is an unknown quantity at this point
    Join Date
    Sep 2006
    Posts
    348

    Re: MySQL Error

    Alternatively, though it wouldn't look as nice, you could make them look like ".$reason."

  4. #4
    Micro is offline Retired staff (11-12-2008) Micro is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    West Midlands
    Posts
    1,301

    Re: MySQL Error

    Although, if you use {$reason} it prevents problems with quotes later on. You can fully make an error message in html this way and then put {$reason} in the html (Or from external files) and get it to parse it.
    Micro

  5. #5
    dest581 is offline x10 Lieutenant dest581 is an unknown quantity at this point
    Join Date
    Sep 2006
    Posts
    348

    Re: MySQL Error

    Useful to know. Thanks!

  6. #6
    YamiKaitou's Avatar
    YamiKaitou is offline x10 Elder YamiKaitou is an unknown quantity at this point
    Join Date
    Oct 2006
    Posts
    636

    Re: MySQL Error

    Micro, do you mean like this?
    Code:
    		$reason = "\'Reinstallation of database\'";
    		$log = "INSERT INTO `develop_log` (`Num`, `User`, `Action`) VALUES (NULL, {$id}, {$reason});";
    		mysql_query($log) or die (mysql_error());
    Because I still get the same error. Could you explain how I should write the code if you mean differently?

  7. #7
    Micro is offline Retired staff (11-12-2008) Micro is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    West Midlands
    Posts
    1,301

    Re: MySQL Error

    Um, dont you have to quote round strings? If im not mistaken i think you might have to. Bit rusty with MySQL, gotta learn it a bit more and get some decent stuff coded.

    Also, you dont have to escape quotes in $reason if you have "" round it and use '.
    Last edited by Micro; 11-22-2006 at 01:07 PM.
    Micro

  8. #8
    Brandon's Avatar
    Brandon is offline Former Senior Account Rep Brandon is on a distinguished road
    Join Date
    Jun 2006
    Location
    Tewksbury, MA
    Posts
    9,589

    Re: MySQL Error

    Try this

    Code:
    $reason = "\'Reinstallation of database\'";
    $log = "INSERT INTO `develop_log` (`Num`, `User`, `Action`) VALUES (NULL, {$id}, {$reason})";
    mysql_query($log) or die (mysql_error());
    You had an extra ";"
    Last edited by Brandon; 11-22-2006 at 02:03 PM.
    Thanks,
    Brandon Long

  9. #9
    YamiKaitou's Avatar
    YamiKaitou is offline x10 Elder YamiKaitou is an unknown quantity at this point
    Join Date
    Oct 2006
    Posts
    636

    Re: MySQL Error

    Nope, that didn't work either. But, I did get it to work, here is the code
    Code:
    $reason = "Reinstallation of database";
    $log = 'INSERT INTO `develop_log` (`Num`, `User`, `Action`) VALUES (NULL, \'$id\', \'$reason\')';
    mysql_query($log) or die (mysql_error());

  10. #10
    Brandon's Avatar
    Brandon is offline Former Senior Account Rep Brandon is on a distinguished road
    Join Date
    Jun 2006
    Location
    Tewksbury, MA
    Posts
    9,589

    Re: MySQL Error

    Thatll work, use
    Code:
    '
    instead of
    Code:
    "
    .
    Thanks,
    Brandon Long

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. Have a problem with my forum
    By tikloos in forum Scripts & 3rd Party Apps
    Replies: 43
    Last Post: 01-19-2006, 01:14 AM
  3. {req} Banners
    By SEŅOR in forum The Marketplace
    Replies: 23
    Last Post: 01-05-2006, 03:15 PM
  4. vBulletin mySQL error!
    By dphiance in forum Free Hosting
    Replies: 3
    Last Post: 06-11-2005, 02:28 AM
  5. Replies: 19
    Last Post: 04-05-2005, 05:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers