Oblivion13
Regular Member
- Sep 7, 2011
- 480
- 260
Hey All,
I am new at PHP and I am trying to make a form post to the database and when I click on Submit, I am getting this error.
I am running PHP Version 5.2.17
If anyone can help me with this I would sure appreciate it. I have been searching and trying to fix it for over 2 hrs now.
I am new at PHP and I am trying to make a form post to the database and when I click on Submit, I am getting this error.
Here is the post.php that I am using.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 'desc, image) VALUES('','New Test','1324','Here is a desc.','')' at line 1
Code:
<?php
// Pick up the form data and assign it to variables
$id = $_POST['id'];
$name = $_POST['name'];
$model = $_POST['model'];
$desc = $_POST['desc'];
$image = $_POST['image'];
// contact to database
$connect = mysql_connect("localhost", "ADMIN", "PASS") or die ("Error , check your server connection.");
mysql_select_db("DBNAME");
//Get data in local variable
$id=$_POST['id'];
$name=$_POST['name'];
$model=$_POST['model'];
$desc=$_POST['desc'];
$image=$_POST['image'];
// check for null values
if ($name=="" or $model=="")
echo "All fields must be entered, hit back button and re-enter information";
else{
$query="INSERT INTO new_equip(id, name, model, desc, image)
VALUES('$id','$name','$model','$desc','$image')";
mysql_query($query) or die(mysql_error());
}
// Redirect
header("Location: Admin_AddListing.php");
?>
I am running PHP Version 5.2.17
If anyone can help me with this I would sure appreciate it. I have been searching and trying to fix it for over 2 hrs now.
Last edited: