frontlinegamerz Posted January 7, 2009 Share Posted January 7, 2009 I altered a table now the insert command will not work, anyone have this problem? Quote Link to comment https://forums.phpfreaks.com/topic/139783-insert-sql-breaking-after-alter-table/ Share on other sites More sharing options...
premiso Posted January 7, 2009 Share Posted January 7, 2009 Umm post the code. Chances are it is due to a column issue... Quote Link to comment https://forums.phpfreaks.com/topic/139783-insert-sql-breaking-after-alter-table/#findComment-731290 Share on other sites More sharing options...
frontlinegamerz Posted January 7, 2009 Author Share Posted January 7, 2009 $sql = 'ALTER TABLE `list` ADD `reason` VARCHAR(30) NOT NULL;'; after adding this now it doesn't insert anything at all and there is another field that was working Quote Link to comment https://forums.phpfreaks.com/topic/139783-insert-sql-breaking-after-alter-table/#findComment-731295 Share on other sites More sharing options...
matto Posted January 7, 2009 Share Posted January 7, 2009 I think premiso meant post the code you are using when you are doing the insert. could also be useful to see the table definition: mysql>desc tablename Quote Link to comment https://forums.phpfreaks.com/topic/139783-insert-sql-breaking-after-alter-table/#findComment-731298 Share on other sites More sharing options...
frontlinegamerz Posted January 7, 2009 Author Share Posted January 7, 2009 function admin_list() { global $blackorwhite; $bwurl = $_POST['bwurl']; $bwreason = $_POST['bwreason']; $bwsub = $_POST['bwsub']; $remove = $_POST['remove']; if($bwsub) { if($bwurl) { @mysql_query("INSERT INTO ".addslashes($blackorwhite)."list VALUES ('".addslashes($bwurl,$bwreason)."')"); Quote Link to comment https://forums.phpfreaks.com/topic/139783-insert-sql-breaking-after-alter-table/#findComment-731349 Share on other sites More sharing options...
matto Posted January 7, 2009 Share Posted January 7, 2009 Can I suggest you change this line @mysql_query("INSERT INTO ".addslashes($blackorwhite)."list VALUES ('".addslashes($bwurl,$bwreason)."')"); to this: @mysql_query("INSERT INTO ".addslashes($blackorwhite)."list VALUES ('".addslashes($bwurl,$bwreason)."')") or die(mysql_error()); Once you have done this try to do the action that does the insert and see what error message you get. Quote Link to comment https://forums.phpfreaks.com/topic/139783-insert-sql-breaking-after-alter-table/#findComment-731909 Share on other sites More sharing options...
frontlinegamerz Posted January 8, 2009 Author Share Posted January 8, 2009 Column count doesn't match value count at row 1 table is empty Quote Link to comment https://forums.phpfreaks.com/topic/139783-insert-sql-breaking-after-alter-table/#findComment-732132 Share on other sites More sharing options...
matto Posted January 8, 2009 Share Posted January 8, 2009 You could fix this by altering the insert statement to define the fields that are going to have data populated into. Example: $sql = "insert into tablename (field1, field2) values('$field1','$field2')"; @mysql_query($sql) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/139783-insert-sql-breaking-after-alter-table/#findComment-732140 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.