Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am unable to insert integer data from insert statement.
$value = $_POST[from];
$query = mysql_query("INSERT INTO trip(tripid,from)VALUES(NULL, $value)");
Here from is integer value, but i am getting syntax error as :
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'from)VALUES(NULL, 1)'` at line 1.
from is Reserved Words in MySQL http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-5.html
try this
mysql_query("INSERT INTO trip(tripid,`from`)VALUES(NULL, $value)");
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm getting the following SQL error:
You have an error in your SQL syntax; check the manual
that corresponds to your MariaDB server version for the
right syntax to use near `classxii`.`email`='rajdeep#gmail.com', `classx`.`email`='rajdeep#gmail.com' at line 5
My PHP code looks like:
$sql = "UPDATE `graduation`, `classxii`, `classx` SET `university`='$university', `college`='$college', `course`='$course', `branch`='$branch', `year`='$year',
`school1`='$school1', `board1`='$board1', `percentage1`='$percentage1', `year1`='$year1',
`school2`='$school2', `board2`='$board2', `percentage2`='$percentage2', `year2`='$year2'
WHERE `graduation`.`email`='$email', `classxii`.`email`='$email', `classx`.`email`='$email'";
$res = mysql_query($sql) or die(mysql_error());
What could be the issue here?
You need to change commas to AND in your where part of the statement:
WHERE `graduation`.`email`='$email' AND `classxii`.`email`='$email' AND `classx`.`email`='$email'";
Or if searching only one of them use OR:
WHERE `graduation`.`email`='$email' OR `classxii`.`email`='$email' OR `classx`.`email`='$email'";
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
So lately I've tried my attempt at SQL, and PHP, and other such, I've come to a problem that of which being: INSERT INTO, just can't seem to work for me. Here's what I have in the PHP file:
$sql = "INSERT INTO forum(USERID, FN, LN, Email) VALUES (NULL,'".$_POST['FN']."', '".$_POST['LN']."', '".$_POST['Email']."';";
This string works, however, I get This error:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
Would anyone be able to provide info on this?
You must close the parenthesis:
$sql = "INSERT INTO forum(USERID, FN, LN, Email) VALUES (NULL,'".$_POST['FN']."', '".$_POST['LN']."', '".$_POST['Email']."');";
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
This is my code:
UPDATE post SET pagetext = replace(pagetext, 'hiiiiiii','lol')
But it doesn't work and I get 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 ''hiiiiiii''lol') FROM post WHERE' at line 1
Any ideas?
MySQL server version for the right syntax to use near ''hiiiiiii''lol')
^
Look close, you dont have a comma between those parameters and because of that your string becomes invalid having 2 quotation marks inside.
It appears there was a problem with phymyadmin, the query is indeed correct.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I really don't understand why this query gives me an error in Mysql
UPDATE gallery_photos SET photo_title='Velato stupore' photo_link='http://path/to/img.jpg' WHERE photo_id='27'
phpmyadmin says:
#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 'photo_link='http://path/to/im
You are missing a comma:
UPDATE gallery_photos SET photo_title='Velato stupore', photo_link='http://path/to/img.jpg' WHERE photo_id='27'
UPDATE gallery_photos SET photo_title='Velato stupore',photo_link='http://path/to/img.jpg' WHERE photo_id='27'
Use this
It is a punctuation issue, you are missing comma between the columns to set
UPDATE gallery_photos SET photo_title='Velato stupore', photo_link='`http://path/to/img.jpg`' WHERE photo_id='27'
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have the below code running and cannot find what the error is. Can anyone suggest anything I should check?
$result = mysql_query("SELECT * FROM table") or die (mysql_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 'table' at line 1
table is a reserved keyword, you must escape it with backtick.
SELECT *
FROM `table`
MySQL Reserved Keyword List