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
https://forums.phpfreaks.com/topic/44271-solved-another-pair-of-eyes/
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.

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..

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.