mickyd69 Posted September 25, 2011 Share Posted September 25, 2011 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 More sharing options...
Pikachu2000 Posted September 25, 2011 Share Posted September 25, 2011 GROUP is a MySQL reserved word. Link to comment https://forums.phpfreaks.com/topic/247846-php-form-for-insert-into-database/#findComment-1272668 Share on other sites More sharing options...
mickyd69 Posted September 25, 2011 Author Share Posted September 25, 2011 Hi Pikachu2000 Thanks for the reply, I have changed the 'group' to 'car_group', which seems to work, only problem is, is that it's now inserting lots of empty entries, as well as the one I want to insert? Thanks.. Mick. Link to comment https://forums.phpfreaks.com/topic/247846-php-form-for-insert-into-database/#findComment-1272670 Share on other sites More sharing options...
mickyd69 Posted September 25, 2011 Author Share Posted September 25, 2011 scrap that.... just realised that I was instructing the header to go backto the Parse page instead of the form, so it was looping itself! D'oh!!! All sorted now, cheers! Link to comment https://forums.phpfreaks.com/topic/247846-php-form-for-insert-into-database/#findComment-1272674 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.