# PHP/MySQL - What's wrong with this INSERT statement?

**URL:** <https://forum.kirupa.com/t/php-mysql-whats-wrong-with-this-insert-statement/279351>\
**Category:** programming\
**Created:** [January 13, 2009, 8:34pm UTC](https://forum.kirupa.com/t/php-mysql-whats-wrong-with-this-insert-statement/279351 "2009-01-13T20:34:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [January 13, 2009, 8:34pm UTC](https://forum.kirupa.com/t/php-mysql-whats-wrong-with-this-insert-statement/279351/1 "2009-01-13T20:34:31Z")

</div>

```auto

<?php

include 'connect.php';

$link = mysql_connect("$host","$user","$pass") or die ("Unable to connect to database.");
mysql_select_db("$db", $link) or die (mysql_error());

$sql = "INSERT INTO customer ('first_name', 'last_name', 'telephone', 'email', 'street', 'city', 'state', 'country', 'postal_code', 'pay_method', 'artpieces') VALUES ('elmer', 'fudd', 123-435-1235, 'elmer@yahoo.com', '123 Hawaii Ave.', 'Barcelona', NULL, 'Spain', '9H3-4R5', 'money order', '11042008')";

$query = mysql_query($sql, $link);

if(!mysql_query($sql))
{
    //error_log("Can't insert user: ".mysql_error());
    die("Could not insert user because: ".mysql_error());
} else {
    echo "Data Inserted!";
}
mysql_close($link);

// Error: Could not insert user because: 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 ''first_name', 'last_name', 'telephone', 'email', 'street', 'city', 'state', 'cou' at line 1
?>

```

Here is an image of the database table structure (I changed everything to NULL allowed while troubleshooting):

[http://www.tornedgedesign.com/\_test/kirupa/dbase.gif](http://www.tornedgedesign.com/_test/kirupa/dbase.gif)
