I get an error

You have an error in your SQL syntax near 'add,edit,name) VALUES('2005-08-06','ppt','30','15','JAMES')' at line 1

and it will not select any thing from the database that i have inserted

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<title>Addvert Information</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


if (isset($_POST['Submit'])) {
mysql_connect("localhost", "", "") or die( "Unable to select database" . mysql_error());
mysql_select_db("orderform")or die("Could not select database");
 $sql = "INSERT INTO test(date,media,add,edit,name) VALUES('".$_POST['date']."','".$_POST['media']."','".$_POST['add']."','".$_POST['edit']."','".$_POST['name']."')";
 $result = mysql_query($sql) or die(mysql_error());

<table width="100%" border="1">
    <td width="1056"><table width="100%" border="1">
        <td bgcolor="#0099FF"><form name="form1" method="post" action="">
          <div align="center">Date :
              <input name="date" type="text" id="date">
  Media Format :
  <input name="media" type="text" id="media">  
  Cost Of Add :
  <input name="add" type="text" id="add">
   Cost Of Edit :
   <input name="edit" type="text" id="edit">
   Name :
   <input name="name" type="text" id="name">
   <input type="submit" name="Submit" value="Submit">
        <td height="134" bgcolor="#0099FF"> <table width="100%" border="1">
            <td>Media Format </td>
            <td>Cost Of Add (&pound;) </td>
            <td>Cost Of Edit (&pound;) </td>
              mysql_connect("localhost", "", "") or die( "Unable to select database" . mysql_error());
mysql_select_db("orderform")or die("Could not select database");
              $result = mysql_query("SELECT * FROM test")
                  or die(mysql_error());

        echo "<tr><td>";
        echo $row['id'];
        echo "</td><td>";
      echo $row['date'];
        echo "</td><td>";
        echo $row['media'];
        echo "</td><td>";
        echo $row['add'];
        echo "</td><td>";
        echo $row['edit'];
        echo "</td><td>";
        echo $row['name'];
        echo "</td></tr>";
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
I assume because of reserved words...

try this:
$sql = "INSERT INTO test([date],[media],[add],[edit],[name])

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
As mentioned, the word "add" is a reserved word in mySQL

The best solution is to rename that column


alter table test change `add`newName varchar(255);

where "newName" is the new name of the column

Another solution is to put in backticks in your query


$sql = "INSERT INTO test(`date`,`media`,`add`,`edit`,`name`) VALUES('".$_POST['date']."','".$_POST['media']."','".$_POST['add']."','".$_POST['edit']."','".$_POST['name']."')";
Yes some of your columns are reserver words See To access those use ` as fieldname-escape char

$sql = "INSERT INTO test(`date`,`media`,`add`,`edit`,`name`) ...

@angellll [column] is used in SQL-Server for column escapes, but mysql uses `
Guy Hengel [angelIII / a3]Billing EngineerCommented:
Sorry, indeed it is ``  instead of [] (confusing MSSQL and MYSQL)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.