| Bug #43978 | You have an error in your SQL syntax ... | ||
|---|---|---|---|
| Submitted: | 31 Mar 2009 8:49 | Modified: | 18 Feb 2013 11:44 |
| Reporter: | Bugs System | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: C API (client library) | Severity: | S2 (Serious) |
| Version: | 5.1.30 | OS: | Other (XAMPP) |
| Assigned to: | CPU Architecture: | Any | |
[31 Mar 2009 9:02]
Valeriy Kravchuk
Try to NOT add " around the SQL statement. In SQL " are used only for string literals.
[1 May 2009 23:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[18 Feb 2013 11:44]
Igor Solodovnikov
User tried to execute SQL statement enclosed in unnecessary quotation marks. This is syntax error. So server's response is plain correct. Closing as not-a-bug.

Description: Hello, I wrote a PHP Skript, which can convert normal SQL-Statements to PHP-Code. It converts: SELECT * FROM downloads; To: "SELECT * FROM downloads" It removes the (;) at the end and adds a (") at the beginning and at the end. Then, when I want to run this mysql, I get this message: 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 '"SELECT * FROM downloads"' at line 1 I do not understand this, because there is no error. How to repeat: function sql2php($file) { $file = file_get_contents($file); $r = array(' ;', '"',); $w = array(';', '\"'); $file = str_replace($r, $w, $file); $file = preg_replace("#(.*?);#is", "\\1~", $file); $file = explode('~', $file); for ($i = 0; $i < count($file); $i++) { $file[$i] = trim($file[$i]); $file[$i] = '"' . $file[$i] . '"'; } return $file; } function runsqlarray($array) { $return = true; for ($i = 0; $i < count($array); $i++) { if ($array[$i] != '""') { echo (mysql_query($array[$i])) ? '' : $return = false; } } return $return; } $create = sql2php('create.sql'); if (!mysql_query($create[0])) { echo mysql_error(); footer(1); } create.sql: SELECT * FROM downloads;