English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories




Make:
Model:
Year:
Price:
Features:
Comments:





$con = mysql_connect("gamerz-anonymous.com","Test123","Test123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("gamerz_anonymous_com_cars");

$Make=$_POST['Make'];
$Model=$_POST['Model'];
$Year=$_POST['Year'];
$Price=$_POST['Price'];
$Features=$_POST['Features'];
$Comments=$_POST['Comments'];

mysql_query("INSERT INTO `UsedCars` ( id , Make , Model , Year , Price , Features , Comments)
VALUES ('', '$Make', '$Model', '$Year', '$Price', '$Features', '$Comments')");

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($con)
?>

2007-09-04 20:07:47 · 2 answers · asked by jetstrike3000 2 in Computers & Internet Programming & Design

The html and php are seperate files

2007-09-04 20:08:07 · update #1

2 answers

Take the quotes away from the table name. Also the quotes away from the variable names. However the SQL needs the comma in between the variables.
As in
mysql_query("INSERT INTO UsedCars ( id , Make , Model , Year , Price , Features , Comments)
VALUES (''.$Make.", ".$Model.", ".$Year.", ".$Price.", ".$Features.", ".$Comments.")");

2007-09-04 23:49:35 · answer #1 · answered by AnalProgrammer 7 · 1 0

I think you problem is coming from trying to enter a id into your database. An Id is generally auto_incremented by the sql database. and doesn't need to be present in your SQL statement.
Something I find that helps me is echoing out the generated SQL statement and if there is an error, take that echoed statement and put it into the SQL query are of phpmyAdmin and debug what going wrong there!

Hope that helps bud. Might I suggest using an object orientated style of database connection called mysqli - check it out at php.net/mysqli

2007-09-04 20:49:09 · answer #2 · answered by Joshy 1 · 0 1

fedest.com, questions and answers