Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Error Inserting Data into database.

Codes here !

Moderators: macek, egami, gesf

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
<html>
<head>
  <title>Make Me Elvis - Add Email</title>
</head>
<body>
  <?php
  $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');

  mysqli_close($db);

  echo 'Customer added';
  ?>
</body>
</html>
gahuja91
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Jan 23, 2013 6:27 am

Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron