I have been working on a project for about a week now and today i seem to of hit a massive brick wall. whilst working on writing some data to a database, something which is usually second nature, i keep getting syntax errors. Now i have gone over the code so much that the text is blending together and my head feels like an elephant is sat on it, with no results.
For test purposes i trimmed the code down to just write data to the first two fields of the database, ID & components(see code below). That was a success. However when i coded all 30 of the fields i began to get my errors.
Is there a limit as to how many records you can add to a mysql database at one time? Or is my eyesight finally going? :icon_cheesygrin:
I have enclosed the full code plus the error message i receive in the hope that someone might just say "aaaaah you missed out an apostrophe". Or something to that effect.
Thanks in advance.
My error message.
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 'case, tempco, location, manufacturer, date, datasheet, reclaimed, user, code, ro' at line 1
My code.
All session variables contain at least 3 characters at all times.
The 'name' & 'date' fields will eventually use variables. i have just nulled them for now.
The ID field auto increments.
<?php
session_start();
// include DB details. In my case "localhost", "root", "", "_components"
require_once("content_db.php");
//connect to database
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ($sql_connect_error);
mysql_select_db($dbname);
$Query = "INSERT INTO _components (ID, category, quantity, description, value, volt, current, tolerance, power, wafer, t_type, package, case, tempco, location, manufacturer, date, datasheet, reclaimed, user, code, rohs, mount, material, esr, dimensions, custom_code, track_taper, turns, gang) VALUES ('NULL', '".$_SESSION['category']."', '".$_SESSION['quantity']."', '".$_SESSION['description']."', '".$_SESSION['value']."', '".$_SESSION['volt']."', '".$_SESSION['current']."', '".$_SESSION['tolerance']."', '".$_SESSION['power']."', '".$_SESSION['wafer']."', '".$_SESSION['t_type']."', '".$_SESSION['package']."', '".$_SESSION['case']."', '".$_SESSION['tempco']."', '".$_SESSION['location']."', '".$_SESSION['manufacturer']."', 'NULL', '".$_SESSION['datasheet']."', '".$_SESSION['reclaimed']."', 'NULL', '".$_SESSION['code']."', '".$_SESSION['rohs']."', '".$_SESSION['mount']."', '".$_SESSION['material']."', '".$_SESSION['esr']."', '".$_SESSION['dimensions']."', '".$_SESSION['custom_code']."', '".$_SESSION['track_taper']."', '".$_SESSION['turns']."', '".$_SESSION['gang']."')";
mysql_query($Query) or die(mysql_error());
mysql_close($conn);
?>