String sql = ("insert into registration(pic) values(?) where email='"+Email+"' ");
i get error :error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where email='yyy#ymail.com'' at line 1
You have to use UPDATE query to pass it like
String sql = "UPDATE registration SET pic = ? WHERE email = '" + Email + "'";
Syntax for UPDATE query is
UPDATE table_name SET column_name = value;
Insert query format should be,
"insert into tablename (columnname) values(coulmnvalue)"
OR
"update registration set pic='' where email='"+Email+"'";
Yes. that is impossible.
Either you want:
insert into registration(pic) values(?)
Which will give you a new row;
Or you want an UPDATE:
UPDATE registration SET pic = ?
WHERE email = <EMAILYouWant>
Which will update an existing row where email = the record with the email you want to update the pic column.
Related
I have a database named prestashop, a table ps_product and a field mq which is tinyInt.
If I do this query on console, it runs correctly, editing the value of a field in a record:
USE prestashop UPDATE ps_product SET mq = 0 WHERE id_product = 1
If I do this query programmatically (php):
mysql_query("USE prestashop
UPDATE ps_product
SET mq = 0
WHERE id_product = 1;")
or die("Query non valida: " . mysql_error());
and this is the error:
Query non valida: 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 'UPDATE ps_product SET mq = 0 WHERE id_product = 1' at line 2
why?
In the console all proceeds correctly, and it really edit the value on the table
For update product detail in prestashop you should write query like that:
$sql = 'UPDATE '._DB_PREFIX_.'product SET mq=0 WHERE id_product=1';
if (!Db::getInstance()->execute($sql))
die('error!');
I hope it would help you.
I am using MySQL with ASP.NET/VB. In a table I use GUID instead of int identifiers. All goes as planned until I try to update a specific row, where I get a syntax error in the statement below:
Dim q As String = "UPDATE documents SET date_document = #date_document, document_type = #document_type, sender = #sender, receiver = #receiver, description = #description, document_number = #document_number, pages = #pages, handled_date = current_timestamp, handled_user_id = #handled_user_id, error_code = #error_code) WHERE id = #id"
My GUID parameter:
.Parameters.Add("#id", MySqlDbType.Guid, 16).Value = myguid
And 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 ') WHERE id = '8873442f-2f0b-4372-ac08-8388220c6eca'' at line 1
Any ideas on what's going on?
You're chasing down the wrong issue. What character does your error syntax begin with? It starts off as ') Where id = ...
You're assuming it's the id. It's not. That works fine. The first character is a closing parenthesis. That's the clue. There is no opening parenthesis. Remove the ) because you don't need it with an update statement.
I am trying to update my table "user" column "img1_name", where the column "blogger_id" equals to $blogger_id and "hotel_id" column equals to $hotel_id.
$sql = "UPDATE user (img1_name) VALUES ('".$img1_name."')
WHERE (blogger_id) = (".$blogger_id.") AND (hotel_id) = ("$hotel_id")";
But it shows error below
Parse error: syntax error, unexpected T_VARIABLE in
/home3/sunangel/public_html/lib/functions/functions.php on line 1593
Can I know how should I edit the line such that it does its function?
You have gone parenthesis crazy and have wrong syntax for your UPDATE statement...
Try this:
$sql = <<<EOT
UPDATE user
SET img1_name = '{$img1_name}'
WHERE blogger_id = {$blogger_id}
AND hotel_id = {$hotel_id}
EOT;
See MySQL documentation for proper UPDATE syntax - http://dev.mysql.com/doc/refman/5.6/en/update.html
Try this :
$sql = "UPDATE user SET img1_name = '".$img1_name."' WHERE blogger_id = ".$blogger_id." AND hotel_id = " . $hotel_id;
Here is SQL UPDATE syntax :
UPDATE your_table_name
SET column_name1 = "your_value",
column_name2 = "another_value"
WHERE your_filter_column = "your_filter_value"
I have this query, which spits out that I have an error in syntax. I cannot for the life of me understand what it is. I have a table, where one column is email and the other is subscribed (the latter of which is a boolean using tinyint). Any idea what's wrong with this syntax?
$query = "UPDATE $DB_TABLE SET $DB_IS_SUBSCRIBED_KEY = 0 WHERE $DB_EMAIL_KEY = $email";
Your email value needs to be wrapped in quotes.
UPDATE tablename SET columname = 1 WHERE emailcolumn = "email#email.com"
$produpd = "UPDATE tblnavpc SET tblnavpc.ChildName = tblnav.NavName " .
"FROM tblnav WHERE tblnavpc.CID = tblnav.NavID";
This is the error I get"
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 tblnav
WHERE tblnavpc.CID = tblnav.NavID' at
line 1
I know keys aren't named greatly but I just trying to fix this one problem, I didn't name the tables.
You don't have a FROM clause in an update:
UPDATE tblnavpc
INNER JOIN tblnav ON tblnavpc.CID = tblnav.NavID
SET tblnavpc.ChildName = tblnav.NavName
"From" cannot be used with update statements.
Should be
$produpd = "UPDATE tblnavpc SET tblnavpc.ChildName = tblnav.NavName " .
"WHERE tblnavpc.CID = tblnav.NavID";