RyanSF07 Posted March 25, 2007 Share Posted March 25, 2007 Hi Guys, I accidentally dropped a table (holy crap!) and now that I've rebuilt it, I get this pesky error: Error: (1065) Query was empty I've looked this over 100 times, but can't see the mistake. Do you see the error? //insert into database $sql = "INSERT INTO video VALUES ('0', '$_SESSION[id]', '$_POST[title]', '$_POST[video]', '$_POST[description_text]', '$_POST[category_text]', '$_POST[level_text]', NOW())"; $result = mysql_query($query) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); Why won't my data INSERT just as smoothly as before? Any ideas? Thanks! Ryan Link to comment https://forums.phpfreaks.com/topic/44271-solved-another-pair-of-eyes/ Share on other sites More sharing options...
Barand Posted March 26, 2007 Share Posted March 26, 2007 As you haven't specified the columns that those values belong to, and we don't know the structure of your table, then sorry, no ideas. However $sql = "...." mysql_query($query) doesn't bode well Link to comment https://forums.phpfreaks.com/topic/44271-solved-another-pair-of-eyes/#findComment-215054 Share on other sites More sharing options...
dswain Posted March 26, 2007 Share Posted March 26, 2007 I believe to use those variables (session and post variables) you need to change the quotations? <?php $sql = "INSERT INTO video VALUES ('0', '$_SESSION[id]', '$_POST[title]', '$_POST[video]', '$_POST[description_text]', '$_POST[category_text]', '$_POST[level_text]', NOW())"; ?> Should become: <?php $sql = "INSERT INTO video VALUES ('0', '" . $_SESSION['id'] . "', '" . $_POST['title'] . "', ..."; ?> I'm not 100% sure about that but I think that's the case. It might have to do with not specifying the columns you want to insert the data into. Link to comment https://forums.phpfreaks.com/topic/44271-solved-another-pair-of-eyes/#findComment-215055 Share on other sites More sharing options...
RyanSF07 Posted March 26, 2007 Author Share Posted March 26, 2007 Hi Barand, Thanks.. the updated error message now reads: "Query: INSERT INTO video VALUES ('0', '1', 'a', 'a', 'a', 'people', 'low-intermediate', NOW()) Error: (1136) Column count doesn't match value count at row 1" id int(11) auto_increment Primary Key user_id int(11) NULL title varchar(40) NULL video text NULL description_text text NULL category_text varchar(20) NULL level_text varchar(20) NULL Thanks again for your help here. Ryan PS Dswain, I'll try that now.. Link to comment https://forums.phpfreaks.com/topic/44271-solved-another-pair-of-eyes/#findComment-215059 Share on other sites More sharing options...
RyanSF07 Posted March 26, 2007 Author Share Posted March 26, 2007 counting rows... Link to comment https://forums.phpfreaks.com/topic/44271-solved-another-pair-of-eyes/#findComment-215060 Share on other sites More sharing options...
AndyB Posted March 26, 2007 Share Posted March 26, 2007 Column count doesn't match value count Your database table has six columns; your query has eight values Link to comment https://forums.phpfreaks.com/topic/44271-solved-another-pair-of-eyes/#findComment-215062 Share on other sites More sharing options...
RyanSF07 Posted March 26, 2007 Author Share Posted March 26, 2007 Yep.. added timestamp. Thanks guys very much for your help! Ryan Link to comment https://forums.phpfreaks.com/topic/44271-solved-another-pair-of-eyes/#findComment-215065 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.