Jump to content

[SOLVED] another pair of eyes


RyanSF07

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.