$accname =$_POST['uaccountname'];
$aid =$_POST['aid'];
if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['submit'] =='update account')

{

    $qry = "UPDATE accounts SET acc_name = $accname WHERE acc_id =$aid";
    mysql_query($qry) or die(mysql_error());    
}   

it gives folling 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 '' at line 1

Recommended Answers

You shouldn't need to write it like that.

You should just be able to use single quotes with the query.

Jump to Post

All 3 Replies

i have written the following query
$qry ="UPDATE accounts SET acc_name = '".$accname."' WHERE acc_id =$aid";

but the issue doesnt resolve

You shouldn't need to write it like that.

You should just be able to use single quotes with the query.

Member Avatar
$qry ="UPDATE accounts SET acc_name = '$accname' WHERE acc_id =$aid";

would be ok

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.