Error Inserting Data into database.

Codes here !

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Wed Jan 23, 2013 6:27 am

Error Inserting Data into database.

Postby gahuja91 » Wed Jan 23, 2013 6:42 am

Hi everyone,
I am new to PHP and just made a PHP script which inserts data into a table. But i keep getting this error:
Parse error: syntax error, unexpected 'INSERT' (T_STRING) in C:\xampp\htdocs\PHP\Chapter3\add.php on line 14
Please help...
My code is as follows:

Code: Select all

  <title>Make Me Elvis - Add Email</title>
  $fname = $_POST['fname'];
  $lname = $_POST['lname'];
  $email = $_POST['email'];
  $db = mysqli_connect('localhost', 'root', '', 'elvis_store')
  or die("Error connecting to database');
  $query = "INSERT INTO email_list VALUES ('$fname', '$lname', '$email')";

  $result = mysqli_query($db, $query)
  or die('Error updating database');


  echo 'Customer added';

Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests