stikky Posted September 1, 2006 Share Posted September 1, 2006 hello, i am a complete beginner and I have been having trouble getting variables taken from a form into a mySQL table.Yesterday, I only either got the variable names inserted (eg $fg), or I got a 'syntax error' message.Today I extracted the values first, but no matter what I try I still get this error message:Query failed: 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 ''test1','test2','test3','test3','test4','test5','test7','test8','test9') VALUES ' at line 1This is an improvement, as these are the correct values (the fieldnames are also in variables).Here is the code as it is now:extract($customer);extract($labels);$sql = "INSERT INTO testing ('$firstName','$lastName','$company','$street','$city','$county','$phone','$email','$query') VALUES ('$fN','$lN','$cp','$stt','$cy','$coy','$ph','$el','$qu');";$result = mysql_query($sql,$dbh) or die("Query failed: ".mysql_error()); $customer is the array of values, $labels is the array of fieldnames.I have tried every variation on the theme I can think of. Please can someone help? Quote Link to comment Share on other sites More sharing options...
.josh Posted September 1, 2006 Share Posted September 1, 2006 take the quotes away from the field name variables (but leave the quotes around the data variables on) Quote Link to comment Share on other sites More sharing options...
stikky Posted September 1, 2006 Author Share Posted September 1, 2006 thanks that works fine now, silly me! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.