I got this error :
Database problem occur, please try again later.
- Error in query: INSERT INTO main SET title ='', url='www.jerseymurah.com', kod='jerseymurah', owner='Hasbul Aqill', tag='jersey, football, world cup', since='Feb 2010', desc='ssfsfsfsfs'
- 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 'desc='ssfsfsfsfs'' at line 1 (Error #1064)
- File: /home/yosh/domains/yosh.my/public_html/demo/admincp/tambah-save.php
and this is my mysql query code :
$query = "INSERT INTO main SET title ='".$ttile."', url='".$url."',
kod='".$kod."', owner='".$owner."', tag='".$tag."', since='".$since."',
desc='".$desc."'";
$db->rq($query);
Please help and thanks a lot!
DESC is a reserved word in mySQL.
You need to put that field in backticks:
`desc`="..."
maybe consider renaming the field.
mySQL reserved words in the manual
I think DESC is a reserved word, try escaping it with backticks.
mysql_query("INSERT INTO main(title,url,kod,owner,tag,since,description) VALUES('$title','$url','$kod','$owner','$tag','$since','$desc')");
Related
I'm a newbie in the php programming.
I would like to apply an insert query but 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 'left) VALUES ('****df','****2135gh','***#yahoo.com' at line 2"}
$sql_insert_new_user = "insert into users (username,password,email,status,finance,province,city,address,tell,
mobile,admin_seen,type,left) VALUES ('$username','$password','$email',1,0,$town,$city,
'$address','$telephone','$mobile',0,'employe',0)";
mysql_query($sql_insert_new_user);
$error = mysql_error();
left is a reserved word and in the query you need escape with backtics
`left`
https://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
left is a reserved word and in the query you need to use like this for all reserved word
'left'
This gives all the details about reserved word https://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
$sql_insert_new_user = "insert into users (username,password,email,status,finance,province,city,address,tell,
mobile,admin_seen,type,`left`) VALUES ('$username','$password','$email',1,0,$town,$city,
'$address','$telephone','$mobile',0,'employe',0)";
left is a mysql reserved word. So you have to rename the column left.
See here : reserved Words for furhter information
I've a little question.
I've written this code to add the values to mysql database but when i run the code and I got an error. Can anybody help me?
the code:
$fel = $mysqli->query("INSERT INTO deleted (uid,buy_type,prop_type,district,street,room_min,room_max,price_min,price_max,condition_type,heat_type,lift_type,parking_type,type_of_del,when)
VALUES ('".$mysqli->real_escape_string($letomb['uid'])."',
'".$mysqli->real_escape_string($letomb['buy_type'])."',
'".$mysqli->real_escape_string($letomb['prop_type'])."',
'".$mysqli->real_escape_string($letomb['district'])."',
'".$mysqli->real_escape_string($letomb['street'])."',
'".$mysqli->real_escape_string($letomb['room_min'])."',
'".$mysqli->real_escape_string($letomb['room_max'])."',
'".$mysqli->real_escape_string($letomb['price_min'])."',
'".$mysqli->real_escape_string($letomb['price_max'])."',
'".$mysqli->real_escape_string($letomb['condition_type'])."',
'".$mysqli->real_escape_string($letomb['heat_type'])."',
'".$mysqli->real_escape_string($letomb['lift_type'])."',
'".$mysqli->real_escape_string($letomb['parking_type']).",
'".$mysqli->real_escape_string($type_of_del)."',
now())") or die($mysqli->error);
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 'when) VALUES ('3', 'kiado', 'lakas', '1'' at line 1
WHEN is a reserved word. Enclosing it in backticks should fix your problem, as it will then be treated as an identifier.
`when`
You should use backticks around your column names. when is a MySQL keyword so it's being interpreted incorrectly. At the very least use backticks around when.
This is the error I receive when I type in code further down:
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 'order(order_date,cust_firstname,cust_lastname,cust_add,cust_city,cust_state,indi' at line 1
The code for this error is:
<?php
include "db.php";
$cust_firstname=$_POST['name'];
$cust_lastname=$_POST['lastname'];
$cust_add=$_POST['add'];
$cust_city=$_POST['city'];
$cust_state=$_POST['state'];
$cust_country=$_POST['country'];
$cust_zip=$_POST['pincode'];
$cust_phone=$_POST['mobile'];
$cust_email=$_POST['email'];
$sql=mysql_query("INSERT INTO order(order_date,cust_firstname,cust_lastname,cust_add,cust_city,cust_state,$cust_country,cust_zip,cust_phone,cust_email)values(now(),'$cust_firstname','$cust_lastname','$cust_add','$cust_city','$cust_state','$cust_country','$cust_zip','$cust_phone','$cust_email')")or die(mysql_error());
header("location:done.php");
?>
What I'm wondering, is what this error really means and what I have to do to fix it?
Order is a reserved keyword. You need to wrap it in ticks:
$sql=mysql_query("INSERT INTO `order` (order_date,
try this
$sql=mysql_query("INSERT INTO `order` (order_date,cu.....
order is reserved key word in mysql
EDIT:
change this
$cust_country
to
cust_country
in insert statment columns
If I remove the line condition=\''.$this->condition.'\', it works.
If I let it there, the following error message appears:
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 'condition='unknown', promotional='0', website='0', quantity='1',
' at line 7
mysql_query('UPDATE products SET
name = \''.$this->name.'\',
description = \''.$this->description.'\',
brand = \''.$this->brand.'\',
model = \''.$this->model.'\',
price=\''.$this->price.'\',
condition=\''.$this->condition.'\',
promotional=\''.$this->promotional.'\',
website=\''.$this->website.'\',
quantity=\''.$this->quantity.'\',
service=\''.$this->service.'\'
WHERE id = \''.$this->id.'\' '
CONDITION is a reserved mysql keyword. You must enclose it in backticks:
`condition`=\''.$this->condition.'\',
You have to rename condition column. See Reserved MySQL keywords table
I'm trying to update using mysql_query in php and it gives me 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 'read='1' WHERE id='14'' at line 1
I've been looking at my query for about 10 minutes now and I cant find whats wrong with it. Here it is:
if ($row['read'] == 0) {
mysql_query("UPDATE mail SET read='1' WHERE id='$mailid'") or die(mysql_error());
}
Do anyone see where the error is?
read is a reserved word.
Enclose it into the backticks:
UPDATE mail SET `read`='1' WHERE id='$mailid'
How about...
"UPDATE `mail` SET `read`='1' WHERE `id`='".$mailid."'"
read is a reserved word. You need to use backticks ` around read.