erniehan
New Member
- Messages
- 11
- Reaction score
- 1
- Points
- 3
I have entered the first code set below into PhpMyAdmin and it works. Using PHP and running it gives me a syntax error. HELP! This is my first exposure to SQL. I am a retired assembly language and C++ programmer doing this for fun! If I run each SQL statement separately like in second code segment, it works great. What simple little thing have I missed? :biggrin:
[FONT="][/FONT]FIRST CODE SET
$sqlquery = <<< HERE
DROP TABLE IF EXISTS adminpw;
CREATE TABLE adminpw
(pwd INT AUTO_INCREMENT PRIMARY KEY,
adminid CHAR(20),
adpw CHAR(20)
);
INSERT adminpw VALUES (null, 'admin', 'admin');
INSERT adminpw VALUES (null, 'dog', 'tiger');
INSERT adminpw VALUES (null, 'horse', 'cat');
HERE;
SECOND CODE SET:
/* Delete the Admin Password Table and Rebuild it */
$sqlquery = "DROP TABLE adminpw;";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
$sqlquery = "CREATE TABLE adminpw
(pwd INT(10) AUTO_INCREMENT PRIMARY KEY,
adminid CHAR(20),
adpw CHAR(20)
);";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
$sqlquery = "INSERT adminpw VALUES (null, 'rabbit', 'hare');";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
/*print "<p>a $result</p>";*/
$sqlquery = "INSERT adminpw VALUES (null, 'mouse', 'cat');";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
/*print "<p>b $result</p>";*/
$sqlquery = "INSERT adminpw VALUES (null, 'bird', 'dog');";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
/*print "<p>c $result</p>";*/
[FONT="][/FONT]FIRST CODE SET
$sqlquery = <<< HERE
DROP TABLE IF EXISTS adminpw;
CREATE TABLE adminpw
(pwd INT AUTO_INCREMENT PRIMARY KEY,
adminid CHAR(20),
adpw CHAR(20)
);
INSERT adminpw VALUES (null, 'admin', 'admin');
INSERT adminpw VALUES (null, 'dog', 'tiger');
INSERT adminpw VALUES (null, 'horse', 'cat');
HERE;
SECOND CODE SET:
/* Delete the Admin Password Table and Rebuild it */
$sqlquery = "DROP TABLE adminpw;";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
$sqlquery = "CREATE TABLE adminpw
(pwd INT(10) AUTO_INCREMENT PRIMARY KEY,
adminid CHAR(20),
adpw CHAR(20)
);";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
$sqlquery = "INSERT adminpw VALUES (null, 'rabbit', 'hare');";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
/*print "<p>a $result</p>";*/
$sqlquery = "INSERT adminpw VALUES (null, 'mouse', 'cat');";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
/*print "<p>b $result</p>";*/
$sqlquery = "INSERT adminpw VALUES (null, 'bird', 'dog');";
$result = mysql_query($sqlquery, $conn) or die(mysql_error());
/*print "<p>c $result</p>";*/