tjverge Posted February 3, 2011 Share Posted February 3, 2011 the below code as I understand should insert a new record into my database, but it's not. <?php $notes = $_POST['notes']; $cnamedb = $_POST['cname']; $username = $_SESSION['username']; mysql_query("INSERT INTO `ccccomma_eve`.`corps` (`id`, `name`, `ticker`, `alliance`, `ceo`, `tax`, `members`, `hq`, `apidate`, `notes`, `notedate`, `updatedby`) VALUES ('', '$cnamedb', '', '', '', '', '', '', '', '$notes', NOW(), '$username'"); echo $cnamedb." Updated"; ?> Any ideas why? Quote Link to comment Share on other sites More sharing options...
tjverge Posted February 3, 2011 Author Share Posted February 3, 2011 updated to this so I could see the error: <?php $notes = $_POST['notes']; $cnamedb = $_POST['cname']; $username = $_SESSION['username']; $query ="INSERT INTO `ccccomma_eve`.`corps` (`id`, `name`, `ticker`, `alliance`, `ceo`, `tax`, `members`, `hq`, `apidate`, `notes`, `notedate`, `updatedby`) VALUES ('', '$cnamedb', '', '', '', '', '', '', '', '$notes', NOW(), '$username'"; mysql_query($query) or die('mysql error ' . mysql_error() . ' in query : ' . $query); echo $cnamedb." Updated"; ?> this is the out put: mysql error 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 '' at line 1 in query : INSERT INTO `ccccomma_eve`.`corps` (`id`, `name`, `ticker`, `alliance`, `ceo`, `tax`, `members`, `hq`, `apidate`, `notes`, `notedate`, `updatedby`) VALUES ('', 'The Choireporation', '', '', '', '', '', '', '', 'test', NOW(), 'TX1' Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted February 3, 2011 Share Posted February 3, 2011 You left off the closing parenthesis on your values. Quote Link to comment Share on other sites More sharing options...
tjverge Posted February 3, 2011 Author Share Posted February 3, 2011 Sorry I don't see it they all look like they have a matching open and close... could you please post the right code? Thank you Quote Link to comment Share on other sites More sharing options...
tjverge Posted February 3, 2011 Author Share Posted February 3, 2011 Sorry I don't see it they all look like they have a matching open and close... could you please post the right code? Thank you Still didn't work here is what I have: $query ="INSERT INTO Corps (`id`, `name`, `ticker`, `alliance`, `ceo`, `tax`, `members`, `hq`, `apidate`, `notes`, `notedate`, `updatedby`) VALUES ('', '$cnamedb', '', '', '', '', '', '', '', '$notes', NOW(), '$username')"; Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 3, 2011 Share Posted February 3, 2011 What's the error you're getting now? Ken Quote Link to comment Share on other sites More sharing options...
tjverge Posted February 3, 2011 Author Share Posted February 3, 2011 It's fixed was a spelling error in my table name had Corps should of been corps Thank you everyone for there help, and putting up with my questions 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.