Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am practicing php and sql. at a stage when I'm trying to enter a record into a table with 2 exiting records. but it doesn't add and show an 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 '=('Aqeela','Nasreen','Hakeem Chattah')' at line 1"

Why is it not entering a record in data base. Is there any syntax error?

$username="root";
$pass="";
$database="addressbook";
$server="127.0.0.1";

$con=mysql_connect($server,$username,$pass);
$db_found=mysql_select_db($database,$con);
if($db_found)
{
$sql_insert="INSERT INTO table_address_book(f_name,l_name,address) VALUES=('Aqeela','Nasreen','Hakeem Chattah')";
    $result=mysql_query($sql_insert);
    if(!$result){
        print "sorry cannot proceed your request<br>".mysql_error();

        }
else
{
//  print "recorded entered successfuly<br>";
//  print "now dATABASES AFTER EDITING ARE<BR><br>";
    $new_sql="SELECT*FROM table_address_book";
    $result_after_editing=mysql_query($new_sql);
    while($db_field_edited=mysql_fetch_assoc($result_after_editing))
    {
        print $db_field_edited['ID']."<br>";
        print $db_field_edited['f_name']."<br>";
        print $db_field_edited['l_name']."<br>";
        print $db_field_edited['address']."<br>";
        print "<BR><BR><BR>";


        }
        mysql_close($con);
    }
}
else
{
    die("unable to connect database ".mysql_error());
    }
share|improve this question
remove '=' from query ... – haseeb 9 mins ago

5 Answers

The error clearly shows place where error in syntax occur.

Remove that =

INSERT INTO table_address_book(f_name,l_name,address) VALUES('Aqeela','Nasreen','Hakeem Chattah')"
share|improve this answer

Remove the = sign from VALUES=(...)

share|improve this answer

There's no '=' after VALUES, just: VALUES (val1, val2, .., valN)

share|improve this answer

I think there is an error in your INSERT INTO statment, you have written wrong VALUES part.

$sql_insert="INSERT INTO table_address_book(f_name,l_name,address) VALUES=('Aqeela','Nasreen','Hakeem Chattah')";

you need to remove "=" from your VALUES= part like this.

$sql_insert="INSERT INTO table_address_book(f_name,l_name,address) VALUES('Aqeela','Nasreen','Hakeem Chattah')";

please correct this line of code in your code and check it again.

share|improve this answer

query me sy value k bad = ka sign remove kr do.

$sql_insert="INSERT INTO table_address_book(f_name,l_name,address) VALUES ('Aqeela','Nasreen','Hakeem Chattah')";
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.