Jump to content

PHP Form for INSERT INTO database?


mickyd69

Recommended Posts

Hi...

 

Got a slight problem with my code, it keeps telling me that there is an error in my syntax, yet I have used the same code before perfectly, and for the life of me cannot see the problem? ....any ideas?

 

<?php

if (!isset($_SESSION)) {

  session_start();

}

// Connects to your Database

mysql_connect("localhost", "justair1_mick", "guru1969") or die(mysql_error()) ;

mysql_select_db("justair1_justair") or die(mysql_error()) ;

 

$filename = ($_FILES['image']['name']);

$group = $_POST['group'];

$make_model = $_POST['make_model'];

$seats = $_POST['seats'];

$transmission = $_POST['transmission'];

$doors = $_POST['doors'];

$lg_bags = $_POST['lg_bags'];

$sm_bags = $_POST['sm_bags'];

$aircon = $_POST['aircon'];

$day1 = $_POST['1_day'];

$days2 = $_POST['2_days'];

$days3_6 = $_POST['3_6days'];

$week = $_POST['week'];

$days8_13 = $_POST['8_13days'];

$days14 = $_POST['14_days'];

 

if(isset($filename)){

//This is the directory where images will be saved

$target = "images/";

$target2 = $target . basename( $_FILES['image']['name']);

 

//This gets all the other information from the form

$fileA=($_FILES['image']['name']);

}

 

$updateSQL = "INSERT INTO car_groups (group, make_model, transmission, seats, doors, lg_bags, sm_bags, aircon, image) VALUES ('$group', '$make_model', '$transmission', '$seats', '$doors', '$lg_bags', '$sm_bags', '$aircon', '$filename')";

 

mysql_query($updateSQL) or die(mysql_error());

 

//Writes the photo to the server

move_uploaded_file($_FILES['image']['tmp_name'], $target2);

 

header ("Location: carhireInsert.php");

?>

 

It keeps telling me...

"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 'group, make_model, transmission, seats, doors, lg_bags, sm_bags, aircon, image) ' at line 1" ..?

 

Really stuck on this one...

 

Any help would be apreciated..

thanks.. Mick.

Link to comment
https://forums.phpfreaks.com/topic/247846-php-form-for-insert-into-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.