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? Link to comment https://forums.phpfreaks.com/topic/226522-mysql-database-not-updating-from-php-code/ 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' Link to comment https://forums.phpfreaks.com/topic/226522-mysql-database-not-updating-from-php-code/#findComment-1169194 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. Link to comment https://forums.phpfreaks.com/topic/226522-mysql-database-not-updating-from-php-code/#findComment-1169206 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 Link to comment https://forums.phpfreaks.com/topic/226522-mysql-database-not-updating-from-php-code/#findComment-1169208 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')"; Link to comment https://forums.phpfreaks.com/topic/226522-mysql-database-not-updating-from-php-code/#findComment-1169210 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 Link to comment https://forums.phpfreaks.com/topic/226522-mysql-database-not-updating-from-php-code/#findComment-1169212 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 Link to comment https://forums.phpfreaks.com/topic/226522-mysql-database-not-updating-from-php-code/#findComment-1169216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.