scadran Posted May 13, 2007 Share Posted May 13, 2007 hey guys I have just designed a BD. there are companies with auto increament which are integer. When I try to populate it after i tool value from another form and try to insert it into a table i recieve an error! I don't ask the companyID value from user as it is auto increament. Don't tell me to put NULL for that entry as it didn't work as well! here are codes: <?php include 'config.php'; $comp_name = $_POST['companname']; $desc = $_POST['desc']; $telephoneno = $_POST['tel']; $own = $_POST['owner']; $sql = "INSERT INTO company ( description , telephoneno , owner , compname, compid ) VALUES ($desc, $telephoneno, $own, $comp_name, NULL)"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); header('location: panel.php'); ?> Any idea what should i do to not recieve 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 .... Thanks Guys waiting for ur answers! Quote Link to comment https://forums.phpfreaks.com/topic/51158-solved-populating-an-auto_increament-attribute/ Share on other sites More sharing options...
Daniel0 Posted May 13, 2007 Share Posted May 13, 2007 You need quotes around the values if they are strings (such as the compname). Quote Link to comment https://forums.phpfreaks.com/topic/51158-solved-populating-an-auto_increament-attribute/#findComment-251874 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.