I create a stored procedure, and I get an error when I call it.
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 ''results0.79123800+1345985910.html')' at line 1
This is how I call it from my php code:
mysql_query("CALL lastscan($task_id,'$file_name')") or die(mysql_error());
I have the sp in my database..
If it is a quote thing, how do I escape the variable I put inside, without modified the stored procedure?
You have incorrect syntax here, use this please:
mysql_query("CALL lastscan('" .$task_id. "', '" .$file_name. "')") or die(mysql_error());
Related
i am facing problem in inserting image inside db, error message is:
Invalid query: 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 'VALUES('','$_59.jpg','����' at line 1
Query written is:
$insert=mysql_query("INSERT INTO store VALUES(id,name,image)VALUES('','$image_name','$image')") or die("Invalid query: " . mysql_error());
I am Using xamppv3.2.1, Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3, Server version: 5.6.21 - MySQL Community Server (GPL).
You have an errant VALUES keyword:
$insert=mysql_query("INSERT INTO store (id,name,image) VALUES ('','$image_name','$image')") or die("Invalid query: " . mysql_error());
FYI, if your id column is set to auto-increment you don't need to have it in your query:
$insert=mysql_query("INSERT INTO store (name,image) VALUES ('$image_name','$image')") or die("Invalid query: " . mysql_error());
Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
Modify your query, you are using VALUES keyword incorrectly. Modify it to:
INSERT INTO store (id,name,image) VALUES('','$image_name','$image')
I doubt your id is VARCHAR type. If it is INT type, put some integer value there.
INSERT INTO store (id,name,image) VALUES(1,'$image_name','$image')
If your id is auto increment, let db insert it
INSERT INTO store (name,image) VALUES('$image_name','$image')
I am using following Insert statement to insert Blob row read from one database into another. (there is data when i echo the same insert statement).
UPDATE:
"INSERT INTO co_registration_picture_evidence_blb
(_URI, _CREATOR_URI_USER, _CREATION_DATE, _LAST_UPDATE_URI_USER, _LAST_UPDATE_DATE,
_TOP_LEVEL_AURI, VALUE) VALUES('".$imageRow['_URI']."','".$imageRow['_CREATOR_URI_USER']."','"
.$imageRow['_CREATION_DATE']."','".$imageRow['_LAST_UPDATE_URI_USER']."','".
$imageRow['_LAST_UPDATE_DATE']."','".$imageRow['_TOP_LEVEL_AURI']."'".
$imageRow['VALUE']."')"
I get following error 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 3
Update: Now i get 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 '?PNG\r\n\Z\n\0\0\0\rIHDR\0\0\0?\0\0\0?\0\0\0????\0\0%iCCPICC Profile\0\0x??M' at line 3
Can anyone tell what's wrong with the syntax? my guess is that i should wrap VALUE column that is of type LongBlob (that holds an image) to some encoding function. (all data fields are already mysql_real_escape_string() filtered).
Any input would be really appreciated.
Regards.
You seem to be missing a , '
INSERT INTO co_registration_picture_evidence_blb
(_URI, _CREATOR_URI_USER, _CREATION_DATE, _LAST_UPDATE_URI_USER, _LAST_UPDATE_DATE,
_TOP_LEVEL_AURI, VALUE) VALUES('".$imageRow['_URI']."','".$imageRow['_CREATOR_URI_USER']."','"
.$imageRow['_CREATION_DATE']."','".$imageRow['_LAST_UPDATE_URI_USER']."','".
$imageRow['_LAST_UPDATE_DATE']."','".$imageRow['_TOP_LEVEL_AURI']."', '".
$imageRow['VALUE']."')
What did I change?
'".$imageRow['_TOP_LEVEL_AURI']."'".
'".$imageRow['_TOP_LEVEL_AURI']."', '".
I tried to use the following code to insert,
$op=$_POST["ans"];
$username=$_GET["username"];
mysql_query("insert into $username values('Q3','$op')")
or die(mysql_error());
But I got the following 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 'values('Q1','Wrong')' at line 1
Why am I getting this error? How can I fix it?
Your query structure is not making any sense. You're inserting into $username? That's not the name of the table, is it?
mysql_query("INSERT INTO `tablename` values('Q3','" . mysql_real_escape_string($op) . "')") or die(mysql_error());
Always be very careful to escape any and all user data being put into your queries, and please, please stop using mysql_query in new code.
I have a Query That work in phpmyadmin but not work on php (mysqli)
where is the problem ?
Query:
INSERT INTO `SepidarSoft_Portal`.`Archive_Media` SET `CTime`='1364135670',`UTime`='1364135670',`PID`='',`State`='1',`Sequence`='0',`Subject`='Hojom Marg ( www.Parstafrih.ir )',`Text`='',`Description`='',`Definition`='',`KeyWord`='',`ETag`='',`Access`='',`LinkToPage`='',`Attachment`='[{\"Name\":null,\"Kind\":null,\"Size\":false,\"Address\":\"27\",\"More\":{\"Original\":1}}]',`STime`='0',`ETime`='0';
SET #LAST_ID:=LAST_INSERT_ID();
INSERT INTO `SepidarSoft_Portal`.`Archive_Media_MoreInfo` (`id`,`Key`,`Value`) VALUES (#LAST_ID,'Instrumental','1'),(#LAST_ID,'KindFile','صوتی'),(#LAST_ID,'Genre','نغمه'),(#LAST_ID,'SName','Amir Tajik ( www.Parstafrih.ir )'),(#LAST_ID,'Events','[[\"\"]]'),(#LAST_ID,'Album','( www.Parstafrih.ir )'),(#LAST_ID,'Composer',''),(#LAST_ID,'Adjustment',''),(#LAST_ID,'Subtitle','[object HTMLInputElement]'),(#LAST_ID,'Release','');
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 'SET #LAST_ID:=LAST_INSERT_ID();
1) I use php mysqli_multi_query for this
Your issue is simple.
Backticks ( ` ) are used to execute commands in php. That's why you're being given a syntax error. Replace them with single or double quotes within your mysqli functions.
Kindly read the following document and you should be sorted :)
Backticks on php.net
Struggling with a simple insert command, i'm getting 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 'All In:
The Poker Movie, tells the story of poker focusing on why one of our nat'
at line 2"
Basically passing film information into a table, here is the code -
$query1 = "INSERT INTO Films_Info (Films_ID,FilmName, FilmRelease, Synopsis,Poster,CritScore,AudScore,Director,Studio,IMDB,date_added_db)
VALUES ('',$Film_Name', '$Film_Release','$filmsynopsis','$film_image','$film_critic','$film_audience','$film_director','$film_studio','$film_imdbID','')";
$runquery1 = mysql_query($query1)or die(mysql_error());
Thanks guys
It looks like that you are missing an ' before $Film_Name. Can you add the missing apostrophe?
If you have phpmyadmin enabled on you server, you can paste the code into the SQL-Field to get syntax highlighting on the SQL query.