Page 1 of 1

have error in php or sql...help me...

Posted: Mon Sep 19, 2011 8:41 pm
by akim2749
this php code have the error when submit data to update...the error message like : Data Profil tidak dapat dicapai.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='anign',type='q' WHERE n_penyakit='angin'' at line 1...help me to solve this problem...


<?php
session_start();
include 'config.php';

$n_penyakit=$_POST["n_penyakit"];
$desc=$_POST["desc"];
$type=$_POST["type"];

$query="UPDATE penyakit SET n_penyakit='$n_penyakit',desc='$desc',type='$type' WHERE n_penyakit='$n_penyakit'";
$result=mysql_query($query) or die ('Data Profil tidak dapat dicapai.'.mysql_error());
?>

Re: have error in php or sql...help me...

Posted: Mon Sep 19, 2011 9:41 pm
by McInfo
DESC is a reserved word; so you need to change the name of the field so it does not conflict with the reserved word, or use backticks whenever you refer to that field so MySQL knows you mean the field and not the reserved word.

Re: have error in php or sql...help me...

Posted: Mon Sep 19, 2011 10:09 pm
by akim2749
i change the name of the field..but the error still appear..any idea..can you give the other syntax for update function...

Re: have error in php or sql...help me...

Posted: Tue Sep 20, 2011 1:20 am
by akim2749
McInfo wrote:DESC is a reserved word; so you need to change the name of the field so it does not conflict with the reserved word, or use backticks whenever you refer to that field so MySQL knows you mean the field and not the reserved word.
\

it work...thanks cz help me.... :D