Php, SQL not working [closed] - php

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']."');";

Related

I think its all ok but it's giving some simple mysql syntax error [closed]

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 6 years ago.
Improve this question
I don't think that there should be any error pls check and respond fast.
$sql = "INSERT INTO users (Name, Price, SaleDonate, Publisher,Author,PrintedPrice,ImageFront,ImageMiddle,ImageBack,SchoolCollage,Course,Class,City,Code,Part,Category,PosterId,PublishingDate,PostingDate)"
." VALUES"
." ('$name','$price','$saledonate','$publisher','$author','$printedprice','$imagefront','$imagemiddle','$imageback','$schoolcollage','$course','$class','$city','$code','$part','$category','$posterId','$publishingdate','$postingdate';";
The error is-
Could not enter data: 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
The data I am entering does not contain any "
Pls help and thanks in advance
You should use the below query :-
$sql = "INSERT INTO users (Name, Price, SaleDonate, Publisher,Author,PrintedPrice,ImageFront,ImageMiddle,ImageBack,SchoolCollage,Course,Class,City,Code,Part,Category,PosterId,PublishingDate,PostingDate) VALUES(".$name.",".$price.",".$saledonate.",".$publisher.",".$author.",".$printedprice.",".$imagefront.",".$imagemiddle.",".$imageback.",".$schoolcollage.",".$course.",".$class.",".$city.",".$code.",".$part.",".$category.",".$posterId.",".$publishingdate.",".$postingdate.");";
$sql = "INSERT INTO users (Name, Price, SaleDonate, Publisher,Author,PrintedPrice,ImageFront,ImageMiddle,ImageBack,SchoolCollage,Course,Class,City,Code,Part,Category,PosterId,PublishingDate,PostingDate) VALUES ('$name','$price','$saledonate','$publisher','$author','$printedprice','$imagefront','$imagemiddle','$imageback','$schoolcollage','$course','$class','$city','$code','$part','$category','$posterId','$publishingdate','$postingdate')";
Hope this will help you.

mysql replace query not working [closed]

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.

Error in Mysql UPDATE query [closed]

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'

Unable to insert data php mysql - integer [closed]

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)");

Simple MySQL Syntax Error [closed]

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

Categories