Problem with a php install page
Hi,
I am trying to create an install.php page for my Alumnus Database. But I keep getting the following error.
Successfully created the marty database.
1064: You have an error in your SQL syntax near '(mbr_id SMALLINT(5) DEFAULT '0' NOT NULL AUTO_INCREMENT,fname varchar(15) NOT NUL' at line 1
The code of the 'install.php' page is as follows:
<?php
include "common_db.inc";
$dbname = "marty";
$user_tablename = "user";
$user_table_def = "mbr_id SMALLINT(5) DEFAULT '0' NOT NULL AUTO_INCREMENT,";
$user_table_def .= "fname varchar(15) NOT NULL DEFAULT ' ', ";
$user_table_def .= "lname varchar(15) NOT NULL DEFAULT ' ', ";
$user_table_def .= "grad_year smallint(4) NOT NULL DEFAULT '0', ";
$user_table_def .= "status varchar(7) NOT NULL DEFAULT '', ";
$user_table_def .= "location varchar(25) DEFAULT NULL, ";
$user_table_def .= "email varchar(50) NOT NULL DEFAULT '', ";
$user_table_def .= "url varchar(50) NULL,DEFAULT '', ";
$user_table_def .= "comments text, ";
$user_table_def .= "username varchar(15) NOT NULL DEFAULT '', ";
$user_table_def .= "password varchar(100) NOT NULL DEFAULT '', ";
$user_table_def .= "occupation varchar(30) DEFAULT NULL, ";
$user_table_def .= "interests varchar(30) DEFAULT NULL, ";
$user_table_def .= "registerdate date NOT NULL DEFAULT '0000-00-00', ";
$user_table_def .= "pic varchar(25) DEFAULT NULL, ";
$user_table_def .= "PRIMARY KEY (mbr_id), ";
$user_table_def .= "UNIQUE KEY mbr_id (mbr_id) ";
//$link_id = db_connect();
//if(!$link_id) die(sql_error());
if(!mysql_query("CREATE DATABASE $dbname")) die(sql_error());
echo "Successfully created the $dbname database.<br>";
if(!mysql_select_db($dbname)) die(sql_error());
if(!mysql_query("CREATE TABLE $user ($user_table_def)")) die(sql_error());
?>
Can you spot any obvious errors. I code most of my code from the book "Begining PHP4" by Wrox.
Any help would be helpfull.
I figured it out. Thanks all.
For curiosity's sake, what was the error?
-Colin
Colin Anderson
Ambition is a poor excuse for those without
sense enough to be lazy.
Sorry, I should have put that there.
In the script, there were a few DEFAULT without anything afterwards and I also changed a variable in my common_db.inc file which may have helped.
Originally posted by Jose
Sorry, I should have put that there....
Bleh. Don't worry about it! Thanks though. Glad you fixed your problem.
-Colin
Colin Anderson
Ambition is a poor excuse for those without
sense enough to be lazy.
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks