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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.