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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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.. Quote Link to comment Share on other sites More sharing options...
RyanSF07 Posted March 26, 2007 Author Share Posted March 26, 2007 counting rows... Quote Link to comment 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 Quote Link to comment 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 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.