I get an error message seemingly out of nowhere. The cited text – ,)’ – doesn’t exist in the program or its single INCLUDE ONCE().
The error: "Table creation failed: (1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’ , , , , , , , , , )’ at line 7 "
The script:
[php]testMySQLiCreateTABLE.php
include_once ('/cnnct2mysqli.php'); //Contains 4 db connection parameters for line 23 below
$TEST = 1;
If($TEST){
$email = [email protected]
;
$first_name = Fname
;
$last_name = LongerLastNames
;
$address1 = Addr01
;
$address2 = Addr02
;
$city = cty
;
$state = MI
;
$zip = 48118;
$country = US
;
$USIT_txt = true
;
$quantity = 1;
$invoiceNo = 140814
;
$zip = 48138
;
}
// Check connection
$mysqli = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
if (!$mysqli->query("DROP TABLE IF EXISTS test1")
||
!$mysqli->query("CREATE TABLE test1
(
`id` int(10) unsigned NOT NULL auto_increment,
`amount` varchar(6) default NULL,
`item_name` varchar(24) default NULL,
`email` varchar(40) default NULL,
`first_name` varchar(20) NOT NULL default '',
`last_name` varchar(40) NOT NULL default '',
`address1` varchar(100) default NULL,
`address2` varchar(100) default NULL,
`city` varchar(50) default NULL,
`state` varchar(6) default NULL,
`zip` varchar(12) default NULL,
`country` varchar(6) DEFAULT NULL,
`invoiceNo` varchar(20) default NULL,
`USIT_txt` enum('True','False') default 'False',
`updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`created` timestamp NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
INDEX(id)
)")
||
!$mysqli->query("INSERT INTO test1(
id, email, first_name, last_name, address1, address2,
city, state, zip, country, invoiceNo, USIT_txt
)
VALUES
(
$email, $first_name, $last_name, $address1, $address2, $city,
$state, $zip, $country, $invoiceNo, $payment_date $USIT_txt
)
")
)
{
echo "Table creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
}
$mysqli->close();[/php]
How can this happen? It is a stymie.
Thanks for any ideas.
usit