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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
akim2749
Forum Newbie
Posts: 3
Joined: Mon Sep 19, 2011 8:38 pm

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

Post 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());
?>
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

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

Post 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.
akim2749
Forum Newbie
Posts: 3
Joined: Mon Sep 19, 2011 8:38 pm

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

Post 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...
akim2749
Forum Newbie
Posts: 3
Joined: Mon Sep 19, 2011 8:38 pm

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

Post 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
Post Reply