SQL syntax error
Solved
Viky
-
PLIPLAPLO Posted messages 1 Status Membre -
PLIPLAPLO Posted messages 1 Status Membre -
Hello,
I have a personal website where I use a database (the one offered by Free).
I received this 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 '' at line 1"
I don't know where my problem comes from. Line 1 does not correspond to SQL syntax.
Can someone guide me to tell me where my error originates?
Thank you in advance
Viken
I have a personal website where I use a database (the one offered by Free).
I received this 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 '' at line 1"
I don't know where my problem comes from. Line 1 does not correspond to SQL syntax.
Can someone guide me to tell me where my error originates?
Thank you in advance
Viken
17 réponses
There is a ' or a " or an extra space instead of a char
example:
insert into toto values('integer_type_value')
instead of
insert into toto values(integer_type_value)
check your query carefully and correct it.
if it persists, send me a sample of your query to address removed by moderation and I will provide you with the solution.
example:
insert into toto values('integer_type_value')
instead of
insert into toto values(integer_type_value)
check your query carefully and correct it.
if it persists, send me a sample of your query to address removed by moderation and I will provide you with the solution.
Hello,
Actually, it's MySQL that is responding to you, not PHP.
MySQL finds an error on the first line of the query you send it. This thus gives you no clue about the location of the failing query.
You need to go through the script of the page, check all the queries, and debug...
--
Best regards.
Actually, it's MySQL that is responding to you, not PHP.
MySQL finds an error on the first line of the query you send it. This thus gives you no clue about the location of the failing query.
You need to go through the script of the page, check all the queries, and debug...
--
Best regards.
Hello
Next time, create your own thread instead of doing archaeology in the forum :)
The query you proposed does not contain any obvious errors. I see 3 possible explanations:
. the error is not on that line
. the query is not exactly the one you copied here
. your variable $nombreDeMessagesParPage ends with a )
Personally, I lean towards the 1st hypothesis because the message mentions a closing parenthesis, and there isn't one in your query (the one after $nombreDeMessagesParPage is not part of the query), unless maybe in the variables, but I don't really believe that.
Next time, create your own thread instead of doing archaeology in the forum :)
The query you proposed does not contain any obvious errors. I see 3 possible explanations:
. the error is not on that line
. the query is not exactly the one you copied here
. your variable $nombreDeMessagesParPage ends with a )
Personally, I lean towards the 1st hypothesis because the message mentions a closing parenthesis, and there isn't one in your query (the one after $nombreDeMessagesParPage is not part of the query), unless maybe in the variables, but I don't really believe that.
What are you doing then?
I have the same bug: 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 'WHERE username=''' at line 1
I have the same bug: 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 'WHERE username=''' at line 1
Error
It seems there is an error in your SQL query. The message below may help you find the cause.
ERROR: Invalid punctuation @ 5
STR: />
SQL: <br />
<b>Fatal error</b>: Allowed memory size of 20971520 bytes exhausted (tried to allocate 13245544 bytes) in <b>/var/www/html/phpMyAdmin-2.11.1-all-languages/libraries/zip.lib.php</b> on line <b>114</b><br />
SQL query:
<br /> <b>Fatal error</b>: Allowed memory size of 20971520 bytes exhausted (tried to allocate 13245544 bytes) in <b>/var/www/html/phpMyAdmin-2.11.1-all-languages/libraries/zip.lib.php</b> on line <b>114</b><br />
MySQL responded: Documentation
#1064 - 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 '<br />
<b>Fatal error</b>: Allowed memory size of 20971520 bytes exhausted (tri' at line 1
I am transferring my site but it’s not working, can someone help me please? Site www.vente-enchere.net
It seems there is an error in your SQL query. The message below may help you find the cause.
ERROR: Invalid punctuation @ 5
STR: />
SQL: <br />
<b>Fatal error</b>: Allowed memory size of 20971520 bytes exhausted (tried to allocate 13245544 bytes) in <b>/var/www/html/phpMyAdmin-2.11.1-all-languages/libraries/zip.lib.php</b> on line <b>114</b><br />
SQL query:
<br /> <b>Fatal error</b>: Allowed memory size of 20971520 bytes exhausted (tried to allocate 13245544 bytes) in <b>/var/www/html/phpMyAdmin-2.11.1-all-languages/libraries/zip.lib.php</b> on line <b>114</b><br />
MySQL responded: Documentation
#1064 - 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 '<br />
<b>Fatal error</b>: Allowed memory size of 20971520 bytes exhausted (tri' at line 1
I am transferring my site but it’s not working, can someone help me please? Site www.vente-enchere.net
Here is my error. I'm struggling to find the solution but nothing. I can't move forward anymore. It's even giving me headaches. If someone here could help me. Here is my error:
SQL Error! INSERT INTO enfant VALUES('', 'coulibaly sarha precilia', 'Enfts......3', 'AGE', 'MARITAL STATUS', 'LEVEL OF EDUCATION', 'ivorian.......1', 'ETHNICITY', 'RELIGION', 'SECTOR OF ACTIVITY', 'MAIN OCCUPATION', 'no BCG', 'no DT COQ POLIO +HB', 'no YELLOW FEVER', 'no MEASLES', 'DEPARASITIZATION', 'CHOOSE', '', '')
Cannot add or update a child row: a foreign key constraint fails ('victims'.'child', CONSTRAINT 'child_ibfk_1' FOREIGN KEY ('matri_enf') REFERENCES 'victim' ('registration_number'))
SQL Error! INSERT INTO enfant VALUES('', 'coulibaly sarha precilia', 'Enfts......3', 'AGE', 'MARITAL STATUS', 'LEVEL OF EDUCATION', 'ivorian.......1', 'ETHNICITY', 'RELIGION', 'SECTOR OF ACTIVITY', 'MAIN OCCUPATION', 'no BCG', 'no DT COQ POLIO +HB', 'no YELLOW FEVER', 'no MEASLES', 'DEPARASITIZATION', 'CHOOSE', '', '')
Cannot add or update a child row: a foreign key constraint fails ('victims'.'child', CONSTRAINT 'child_ibfk_1' FOREIGN KEY ('matri_enf') REFERENCES 'victim' ('registration_number'))
Hello
I am also experiencing the same issue, however, I cannot share the code of my backup because it is very important. As you can see, I am trying to import my SugarCRM database that I initially set up and configured on my OVH server. I made a backup of the database and I am attempting to import it in gzip format, but it is not working!!!!!! It displays the following error: #1064 - 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 '[LOW_PRIORITY] [LOCAL] INFILE 'mcbizsql.tar.gz' [IGNORE | REPLACE] optio' at line 1.
If anyone has an idea to resolve this issue, it is urgent.
Thank you for your cooperation.
I am also experiencing the same issue, however, I cannot share the code of my backup because it is very important. As you can see, I am trying to import my SugarCRM database that I initially set up and configured on my OVH server. I made a backup of the database and I am attempting to import it in gzip format, but it is not working!!!!!! It displays the following error: #1064 - 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 '[LOW_PRIORITY] [LOCAL] INFILE 'mcbizsql.tar.gz' [IGNORE | REPLACE] optio' at line 1.
If anyone has an idea to resolve this issue, it is urgent.
Thank you for your cooperation.
Hello,
I have the same 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" at line 1" SELECT *FROM CF_groups_perm WHERE id_group =......
but I don't understand anything about the solutions......... what exactly should I do........ what should I change and where?
I have the same 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" at line 1" SELECT *FROM CF_groups_perm WHERE id_group =......
but I don't understand anything about the solutions......... what exactly should I do........ what should I change and where?
I encountered the same error. I am currently working on my own machine where I installed WAMP server 2.0
so Apache Version 2.2.11, PHP Version 5.3.0 MySQL Version 5.1.36 and here is my SQL query as I wrote it
$response = mysql_query("SELECT * FROM livredor ORDER BY id DESC LIMIT " . $firstMessageToDisplay . ", " . $numberOfMessagesPerPage) or die(mysql_error());
and I have this 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 ')' at line 1
Can someone help me?
so Apache Version 2.2.11, PHP Version 5.3.0 MySQL Version 5.1.36 and here is my SQL query as I wrote it
$response = mysql_query("SELECT * FROM livredor ORDER BY id DESC LIMIT " . $firstMessageToDisplay . ", " . $numberOfMessagesPerPage) or die(mysql_error());
and I have this 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 ')' at line 1
Can someone help me?
Hello, I have the same problem as the first person who posted the message!!!!
Please help me
Thank you
Please help me
Thank you
Hello everyone,
I had the same error but for a different reason:
I was using a field "table" in my bookings table.
However, the problem was that this field is a reserved word, so it can't be used as a field name.
To solve the problem, I had to add double quotes in my INSERT!
Here is my INSERT from my PHP file:
$requete = "INSERT INTO bookings (email, name, firstname, phone, 'table', bottle, soft, people, date_envoi) "
. "VALUES ('$email', '$name', '$firstname', '$phone', '$amountt', '$amountb', '$amounts', '$amountp', NOW())";
I had to replace table with 'table' and it worked!!!
I had the same error but for a different reason:
I was using a field "table" in my bookings table.
However, the problem was that this field is a reserved word, so it can't be used as a field name.
To solve the problem, I had to add double quotes in my INSERT!
Here is my INSERT from my PHP file:
$requete = "INSERT INTO bookings (email, name, firstname, phone, 'table', bottle, soft, people, date_envoi) "
. "VALUES ('$email', '$name', '$firstname', '$phone', '$amountt', '$amountb', '$amounts', '$amountp', NOW())";
I had to replace table with 'table' and it worked!!!
Hello, I have the same type of problem as Viky:
I have a phpbb forum, I am changing my host, and I am at the crucial step of importing the database from my old forum.
However, when I import the file, I get the same error message:
SQL query:
CREATE DATABASE `sidious4` DEFAULT;
MySQL responded:
#1064 - 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 '' at line 1
Do you have any idea?
I have a phpbb forum, I am changing my host, and I am at the crucial step of importing the database from my old forum.
However, when I import the file, I get the same error message:
SQL query:
CREATE DATABASE `sidious4` DEFAULT;
MySQL responded:
#1064 - 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 '' at line 1
Do you have any idea?
In a similar situation, it is also possible that one of the field names is reserved and treated as a structural word.
For example, if I have a field called "read" that I use as a boolean to indicate that a message has been read:
"UPDATE messages SET read=0 WHERE id=1"
This fails.
Indeed, if I enter this query in the "SQL" tab of PHPmyAdmin, I notice that after submitting (and indicating that an error has occurred), PHPmyAdmin displays "read" in uppercase, and in the same color as UPDATE or WHERE. Therefore, I need to choose another name for my field "read."
For example, if I have a field called "read" that I use as a boolean to indicate that a message has been read:
"UPDATE messages SET read=0 WHERE id=1"
This fails.
Indeed, if I enter this query in the "SQL" tab of PHPmyAdmin, I notice that after submitting (and indicating that an error has occurred), PHPmyAdmin displays "read" in uppercase, and in the same color as UPDATE or WHERE. Therefore, I need to choose another name for my field "read."
Hello!
I have the same error as the first person who commented, the message I receive is "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 'description like '58'' at line 1" (when I send my query for dirid=58 but it's the same for other dirid=)
I have read and reread my code and I can't find my error!
Here is my code: descriptionpage.php
I have the same error as the first person who commented, the message I receive is "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 'description like '58'' at line 1" (when I send my query for dirid=58 but it's the same for other dirid=)
I have read and reread my code and I can't find my error!
Here is my code: descriptionpage.php
<html> <head> </head> <body> <?php // connecting to MySQL $db = mysql_connect('localhost', 'root', ''); // selecting the database mysql_select_db('movie',$db); $id=$_GET['dirid']; $query=mysql_query("SELECT * FROM movie WHERE movie_name,description like '$id'") or die(mysql_error()); while ($r=mysql_fetch_array($query)) { echo "<b>Movie name : </b>".$r['movie_name']."<br>"; echo "<b>Description : </b>".$r['description']."<br>"; } ?> </body> </html>
<?php
mysql_connect("localhost","root","");
mysql_select_db("tutos");
if(!empty($_POST)){
$username = $_POST['username'];
$email = $_POST['email'];
$about = $_POST['about'];
if($username&&$email&&$about){
extract($_POST);
$sql="UPDATE users SET username='$username', email='$email', about='{$_POST["about"]}'";
$req = mysql_query($sql) or die(mysql_error());
$sql = stripslashes($_POST['about']);
$success="Votre compte a bien été modifié {$_SESSION["Auth"]["username"]}";
}else{
$erreur="Veuillez compléter tous les champs";
}
}
$sql="SELECT * FROM users";
$req = mysql_query($sql);
while($d=mysql_fetch_assoc($req)){
?>
Hello everyone!
Sorry to dig up this topic but I have the same error, and I can't find out where it's coming from...
I created my database residence_etudiante on PMA and I would like to fill it easily and quickly with foreign keys and everything (which is really giving me trouble).
Here is my SQL query, automatically generated by the AnalysisSI software from my ER diagram:
and here is the error that shows up:
Can you help me sort out this little issue?
I should mention that I am a novice in this area and that coding is not my strong suit... thanks in advance!
Sorry to dig up this topic but I have the same error, and I can't find out where it's coming from...
I created my database residence_etudiante on PMA and I would like to fill it easily and quickly with foreign keys and everything (which is really giving me trouble).
Here is my SQL query, automatically generated by the AnalysisSI software from my ER diagram:
DROP TABLE IF EXISTS Concierge ;
CREATE TABLE Concierge (id_conc int AUTO_INCREMENT NOT NULL,
nom_conc TEXT, ad_conc TEXT,
tel_conc NUMERIC(10),
id_resi INT NOT NULL,
PRIMARY KEY (id_conc) ) ENGINE=InnoDB;
DROP TABLE IF EXISTS Résidence ;
CREATE TABLE Résidence (id_resi int AUTO_INCREMENT NOT NULL,
nom_resi TEXT, ad_resi TEXT,
tel_resi NUMERIC(10),
PRIMARY KEY (id_resi) ) ENGINE=InnoDB;
DROP TABLE IF EXISTS Studio ;
CREATE TABLE Studio (id_studio int AUTO_INCREMENT NOT NULL,
charges NUMERIC(50),
loyer NUMERIC(5),
id_resi INT NOT NULL,
id_loc INT NOT NULL,
id_prop INT NOT NULL,
PRIMARY KEY (id_studio) ) ENGINE=InnoDB;
DROP TABLE IF EXISTS Locataire ;
CREATE TABLE Locataire (id_loc int AUTO_INCREMENT NOT NULL,
nom_loc TEXT, ad_loc TEXT,
tel_loc NUMERIC(10),
PRIMARY KEY (id_loc) ) ENGINE=InnoDB;
DROP TABLE IF EXISTS Propriétaire ;
CREATE TABLE Propriétaire (id_prop int AUTO_INCREMENT NOT NULL,
nom_prop TEXT, ad_prop TEXT,
tel_prop NUMERIC(10),
PRIMARY KEY (id_prop) ) ENGINE=InnoDB;
ALTER TABLE Concierge
ADD CONSTRAINT FK_Concierge_id_resi
FOREIGN KEY (id_resi)
REFERENCES Résidence (id_resi);
ALTER TABLE Studio
ADD CONSTRAINT FK_Studio_id_resi
FOREIGN KEY (id_resi)
REFERENCES Résidence (id_resi);
ALTER TABLE Studio
ADD CONSTRAINT FK_Studio_id_loc
FOREIGN KEY (id_loc)
REFERENCES Locataire (id_loc);
ALTER TABLE Studio
ADD CONSTRAINT FK_Studio_id_prop
FOREIGN KEY (id_prop)
REFERENCES Propriétaire (id_prop);
and here is the error that shows up:
Error
SQL query:
CREATE TABLE Concierge(
id_conc INT AUTO_INCREMENT NOT NULL ,
nom_conc TEXT,
ad_conc TEXT,
tel_conc NUMERIC( 10 ) ,
id_resi INT NOT NULL ,
PRIMARY KEY ( id_conc )
) ENGINE = INNODB;
MySQL responded: Documentation
#1064 - 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 '(8) NOT NULL,
nom_conc TEXT, ad_conc TEXT,
tel_conc NUMERIC(10),
id_resi INT(8) ' at line 1
Can you help me sort out this little issue?
I should mention that I am a novice in this area and that coding is not my strong suit... thanks in advance!
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 '12' at line 8
عذراً: 1064
Date: Wednesday 5th of December 2007 04:31:22 PM
---------------Query---------------
in this script
SELECT rafia_news.*,COUNT(rafia_comment.news_id) as numrows
FROM rafia_news LEFT JOIN rafia_comment
ON rafia_news.id = rafia_comment.news_id
WHERE rafia_news.allow = 'yes'
AND rafia_news.inindex = '1'
GROUP BY rafia_news.id
ORDER BY rafia_news.id DESC
LIMIT 12
thank you for helping me to correct this error
to know: I am clueless in programming
عذراً: 1064
Date: Wednesday 5th of December 2007 04:31:22 PM
---------------Query---------------
in this script
SELECT rafia_news.*,COUNT(rafia_comment.news_id) as numrows
FROM rafia_news LEFT JOIN rafia_comment
ON rafia_news.id = rafia_comment.news_id
WHERE rafia_news.allow = 'yes'
AND rafia_news.inindex = '1'
GROUP BY rafia_news.id
ORDER BY rafia_news.id DESC
LIMIT 12
thank you for helping me to correct this error
to know: I am clueless in programming
salam 3likom, do you still not have any solutions?! How did you solve the problem!!!! Because I have the same
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 '-mail, subject, message, url_) VALUES ('a', 'a@a.fr', 'test' at line 1
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 '-mail, subject, message, url_) VALUES ('a', 'a@a.fr', 'test' at line 1
Hello
Right now I am receiving emails inviting me to click on a link. When I click on these links, I get the same errors!
I am using Internet Explorer 7. Are the errors caused by bugs in IE7? Are they errors on the sender's side?
Thank you for your help
windows xp ie7
Right now I am receiving emails inviting me to click on a link. When I click on these links, I get the same errors!
I am using Internet Explorer 7. Are the errors caused by bugs in IE7? Are they errors on the sender's side?
Thank you for your help
windows xp ie7
I have the same problem too (I bet the one reading this page looking for solutions is going to commit suicide, everyone has the same problem lol); except that I have the problem with what is called the placeholder "?";
Here is my code:
$reponse=$bdd->query('SELECT password FROM users WHERE username=?');
$reponse->execute(array($_POST['username']));
and here is the 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 '?' at line 1
Here is my code:
$reponse=$bdd->query('SELECT password FROM users WHERE username=?');
$reponse->execute(array($_POST['username']));
and here is the 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 '?' at line 1
I love you