Jump to content

[SOLVED] Table Troubles


Hagbard

Recommended Posts

okay I'm trying to save fields from an add.php to my database..however when I try and post it I keep getting this error

 

You have an error in your SQL syntax near ') values ( '0', 'a', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''' at line 46

 

This is the actual script its trying to call. The config.php is where all my database info is listed obviously and it connects fine.

 

<?php require("include/config.php");

 

$id                              = $_POST['id'];

$last_name                    = $_POST['last_name'];

$first_name                    = $_POST['first_name'];

$artist2_last_name          = $_POST['artist2_last_name'];

$artist2_first_name          = $_POST['artist2_first_name'];

$ohio_tax_id_number      = $_POST['ohio_tax_id_number'];

$business_name              = $_POST['business_name'];

$address                      = $_POST['address'];

$city                          = $_POST['city'];

$state                        = $_POST['state'];

$zip                            = $_POST['zip'];

$telephone1                = $_POST['telephone1'];

$telephone2                = $_POST['telephone2'];

$email1                      = $_POST['email1'];

$email2                      = $_POST['email2'];

$medium                    = $_POST['medium'];

$artist_number            = $_POST['artist_number'];

$app_received_2007        = $_POST['app_received_2007'];

$jury_decision              = $_POST['jury_decision'];

$withdraw_date_2007      = $_POST['withdraw_date_2007'];

$check_25                = $_POST['check_25'];

$check_120                = $_POST['check_120'];

$check_200                = $_POST['check_200'];

$wci_qualified            = $_POST['wci_qualified'];

$winner_2008              = $_POST['winner_2008'];

$winner_2007              = $_POST['winner_2007'];

$winner_2006              = $_POST['winner_2006'];

$winner_2005              = $_POST['winner_2005'];

$postcard_request        = $_POST['postcard_request'];

$notes                        = $_POST['notes'];

$wci_app_received_2008    = $_POST['wci_app_received_2008'];

$withdraw_date_2008      = $_POST['withdraw_date_2008'];

$app_received_2008        = $_POST['app_received_2008'];

$booth_number_2008        = $_POST['booth_number_2008'];

$wci_image_1              = $_POST['wci_image_1'];

$wci_image_2              = $_POST['wci_image_2'];

$wci_image_3              = $_POST['wci_image_3'];

$wci_image_4              = $_POST['wci_image_4'];

$hear_about_festival      = $_POST['hear_about_festival'];

$wci_artist_number        = $_POST['wci_artist_number'];

$wci_notify_date          = $_POST['wci_notify_date'];

 

mysql_connect("$mysql_host", "$mysql_user", "$mysql_password");

mysql_select_db("$mysql_db") or die(mysql_error());

 

mysql_query("INSERT INTO $mysql_table (

id,

last_name,

first_name,

artist2_last_name,

artist2_first_name,

ohio_tax_id_number,

business_name,

address,

city,

state,

zip,

telephone1,

telephone2,

email1,

email2,

notes,

medium,

artist_number,

app_received_2007,

jury_decision,

withdraw_date_2007,

winner_2008,

winner_2007,

winner_2006,

winner_2005,

check_25,

check_120,

check_200,

wci_qualified,

postcard_request,

withdraw_date_2007,

wci_artist_number,

wci_decision,

wci_notify_date,

booth_number_2007,

app_received_2008,

withdraw_date_2008,

wci_app_received_2008,

booth_number_2008,

wci_image_1,

wci_image_2,

wci_image_3,

wci_image_4,

hear_about_festival,

)

values

(

'0',

'$last_name',

'$first_name',

'$artist2_last_name',

'$artist2_first_name',

'$ohio_tax_id_number',

'$business_name',

'$address',

'$city',

'$state',

'$zip',

'$telephone1',

'$telephone2',

'$email1',

'$email2',

'$notes',

'$medium',

'$artist_number',

'$app_received_2007',

'$jury_decision',

'$withdraw_date_2007',

'$winner_2008',

'$winner_2007',

'$winner_2006',

'$winner_2005',

'$check_25',

'$check_120',

'$check_200',

'$wci_qualified',

'$postcard_request',

'$withdraw_date_2008',

'$wci_artist_number',

'$wci_decision',

'$wci_notify_date',

'$app_received_2008',

'$wci_app_received_2008',

'$booth_number_2008',

'$wci_image_1',

'$wci_image_2',

'$wci_image_3',

'$wci_image_4',

'$hear_about_festival',

)") or die(mysql_error());

 

//$result = mysql_query ($query);

 

mysql_close();

 

header("Location: index.php");

 

?>

 

 

 

Any help would be greatly appreciated.  :)

Link to comment
https://forums.phpfreaks.com/topic/101204-solved-table-troubles/
Share on other sites

Check your column count, Make sure your trying to insert the same number of variables as there is columns's in your database.

 

INSERT INTO TABLE VARIABLE1, VARIABLE2.. VARIABLE40 Values('COLUMN1', 'COLUMN2'....'COLUMN40');

 

EDIT: I just counted.. seems like your trying to insert 44 values into 42 row spaces. So check your column count, your missing 2 variables you should be including.

Thank you for the help I made sure to correct the columns and even deleted that comma at the end of the command. However I'm still getting the error

 

You have an error in your SQL syntax near ') values ( '0', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'aa', 'a', 'a', 'a', 'a' at line 44

 

for some reason

 

<?php require("include/config.php");

 

$id                      = $_POST['id'];

$last_name                = $_POST['last_name'];

$first_name              = $_POST['first_name'];

$artist2_last_name        = $_POST['artist2_last_name'];

$artist2_first_name      = $_POST['artist2_first_name'];

$ohio_tax_id_number      = $_POST['ohio_tax_id_number'];

$business_name            = $_POST['business_name'];

$address                  = $_POST['address'];

$city                    = $_POST['city'];

$state                    = $_POST['state'];

$zip                      = $_POST['zip'];

$telephone1              = $_POST['telephone1'];

$telephone2              = $_POST['telephone2'];

$email1                  = $_POST['email1'];

$email2                  = $_POST['email2'];

$notes                    = $_POST['notes'];

$medium                  = $_POST['medium'];

$artist_number            = $_POST['artist_number'];

$app_received_2007        = $_POST['app_received_2007'];

$jury_decision            = $_POST['jury_decision'];

$withdraw_date_2007      = $_POST['withdraw_date_2007'];

$winner_2008              = $_POST['winner_2008'];

$winner_2007              = $_POST['winner_2007'];

$winner_2006              = $_POST['winner_2006'];

$winner_2005              = $_POST['winner_2005'];

$check_25                = $_POST['check_25'];

$check_120                = $_POST['check_120'];

$check_200                = $_POST['check_200'];

$wci_qualified            = $_POST['wci_qualified'];

$postcard_request        = $_POST['postcard_request'];

$wci_artist_number        = $_POST['wci_artist_number'];

$wci_decision            = $_POST['wci_decision'];

$wci_notify_date          = $_POST['wci_notify_date'];

$wci_app_received_2008    = $_POST['wci_app_received_2008'];

$withdraw_date_2008      = $_POST['withdraw_date_2008'];

$app_received_2008        = $_POST['app_received_2008'];

$booth_number_2008        = $_POST['booth_number_2008'];

$wci_image_1              = $_POST['wci_image_1'];

$wci_image_2              = $_POST['wci_image_2'];

$wci_image_3              = $_POST['wci_image_3'];

$wci_image_4              = $_POST['wci_image_4'];

$hear_about_festival      = $_POST['hear_about_festival'];

 

mysql_connect("$mysql_host", "$mysql_user", "$mysql_password");

mysql_select_db("$mysql_db") or die(mysql_error());

 

mysql_query("INSERT INTO $mysql_table (

id,

last_name,

first_name,

artist2_last_name,

artist2_first_name,

ohio_tax_id_number,

business_name,

address,

city,

state,

zip,

telephone1,

telephone2,

email1,

email2,

notes,

medium,

artist_number,

app_received_2007,

jury_decision,

withdraw_date_2007,

winner_2008,

winner_2007,

winner_2006,

winner_2005,

check_25,

check_120,

check_200,

wci_qualified,

postcard_request, 

wci_artist_number,

wci_decision,

wci_notify_date,

app_received_2008,

withdraw_date_2008,

wci_app_received_2008,

booth_number_2008,

wci_image_1,

wci_image_2,

wci_image_3,

wci_image_4,

hear_about_festival,

)

values

(

'0',

'$last_name',

'$first_name',

'$artist2_last_name',

'$artist2_first_name',

'$ohio_tax_id_number',

'$business_name',

'$address',

'$city',

'$state',

'$zip',

'$telephone1',

'$telephone2',

'$email1',

'$email2',

'$notes',

'$medium',

'$artist_number',

'$app_received_2007',

'$jury_decision',

'$withdraw_date_2007',

'$winner_2008',

'$winner_2007',

'$winner_2006',

'$winner_2005',

'$check_25',

'$check_120',

'$check_200',

'$wci_qualified',

'$postcard_request',

'$wci_artist_number',

'$wci_decision',

'$wci_notify_date',

'$app_received_2008',

'$withdraw_date_2008',

'$wci_app_received_2008',

'$booth_number_2008',

'$wci_image_1',

'$wci_image_2',

'$wci_image_3',

'$wci_image_4',

'$hear_about_festival'

)") or die(mysql_error());

 

//$result = mysql_query ($query);

 

mysql_close();

 

header("Location: index.php");

 

?>

 

 

 

 

 

 

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.