PHP GENERAL 14 WHAT S WRONG WITH THIS
Date: Tue, 8 Jul 2003 11:26:52 -0400

Subject: what's wrong with this?????
From: artoo_s@no-spam (Artoo)

I keep getting Parse error: parse error, unexpected T_LNUMBER in /usr/local/psa/home/create.php on line 9

This is line 9, which should just create a table.

$result = mysql_query('CREATE TABLE members (userid INT(25) NOT NULL AUTO_INCREMENT, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(50) NOT NULL, email_address VARCHAR(255) NOT NULL, username VARCHAR(30) NOT NULL,
password VARCHAR(30) NOT NULL, activated ENUM('0','1') DEFAULT '0' NOT NULL,
date_joined DATETIME NULL, last_login DATETIME NULL);')or die("Create table Error: ".mysql_error());

What's that error mean and is that CREATE TABLE query correct?

Thanks

Date: 08 Jul 2003 11:31:33 -0400

Subject: Re: [PHP] what's wrong with this?????





From: adam@no-spam (Adam Voigt)
Umm quotes.

Anywhere in your actual SQL that you are using a single quote,
you need to put a backslash before it, example:

activated ENUM('0','1') DEFAULT '0'

Becomes:

activated ENUM(\'0\',\'1\') DEFAULT \'0\'

On Tue, 2003-07-08 at 11:26, Artoo wrote:
> I keep getting Parse error: parse error, unexpected T_LNUMBER in > /usr/local/psa/home/create.php on line 9
> > This is line 9, which should just create a table.
> > $result = mysql_query('CREATE TABLE members (userid INT(25) NOT NULL > AUTO_INCREMENT, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(50) NOT > NULL, email_address VARCHAR(255) NOT NULL, username VARCHAR(30) NOT NULL,
> password VARCHAR(30) NOT NULL, activated ENUM('0','1') DEFAULT '0' NOT NULL,
> date_joined DATETIME NULL, last_login DATETIME NULL);')or die("Create table > Error: ".mysql_error());
> > What's that error mean and is that CREATE TABLE query correct?
> > Thanks -- Adam Voigt (adam@no-spam Linux/Unix Network Administrator The Cryptocomm Group

Date: Tue, 8 Jul 2003 11:34:54 -0400

Subject: Re: [PHP] what's wrong with this?????
From: artoo_s@no-spam (Artoo)
Thanks.

----- Original Message -----
From: "Adam Voigt" (adam@no-spam)
To: "Artoo" <artoo_s@no-spam>
Cc: <php-general@no-spam>
Sent: Tuesday, July 08, 2003 11:31 AM
Subject: Re: [PHP] what's wrong with this?????

> Umm quotes.
>
> Anywhere in your actual SQL that you are using a single quote,
> you need to put a backslash before it, example:
>
> activated ENUM('0','1') DEFAULT '0'
>
> Becomes:
>
> activated ENUM(\'0\',\'1\') DEFAULT \'0\'
>
>
>
> On Tue, 2003-07-08 at 11:26, Artoo wrote:
> > I keep getting Parse error: parse error, unexpected T_LNUMBER in > > /usr/local/psa/home/create.php on line 9
> >
> > This is line 9, which should just create a table.
> >
> > $result = mysql_query('CREATE TABLE members (userid INT(25) NOT NULL > > AUTO_INCREMENT, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(50)
NOT > > NULL, email_address VARCHAR(255) NOT NULL, username VARCHAR(30) NOT NULL,
> > password VARCHAR(30) NOT NULL, activated ENUM('0','1') DEFAULT '0' NOT NULL,
> > date_joined DATETIME NULL, last_login DATETIME NULL);')or die("Create table > > Error: ".mysql_error());
> >
> > What's that error mean and is that CREATE TABLE query correct?
> >
> > Thanks > -- > Adam Voigt (adam@no-spam > Linux/Unix Network Administrator > The Cryptocomm Group >
>


Date: Tue, 8 Jul 2003 11:38:07 -0400
Subject: Re: what's wrong with this?????
From: paul+php@no-spam (Paul Chvostek)

On Tue, Jul 08, 2003 at 11:26:52AM -0400, Artoo wrote:
> > I keep getting Parse error: parse error, unexpected T_LNUMBER in > /usr/local/psa/home/create.php on line 9
> > This is line 9, which should just create a table.
> > $result = mysql_query('CREATE TABLE members (userid INT(25) NOT NULL > AUTO_INCREMENT, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(50) NOT > NULL, email_address VARCHAR(255) NOT NULL, username VARCHAR(30) NOT NULL,
> password VARCHAR(30) NOT NULL, activated ENUM('0','1') DEFAULT '0' NOT NULL,
> date_joined DATETIME NULL, last_login DATETIME NULL);')or die("Create table > Error: ".mysql_error());
> > What's that error mean and is that CREATE TABLE query correct?

The CREATE TABLE is correct, but look at your ENUM values and DEFAULT.
What kind of quotes are you using? How do you think they should be interpreted? For easier reading, let's split up the query....

$q = 'CREATE TABLE members (userid INT() NOT NULL AUTO_INCREMENT, '
. 'first_name VARCHAR(30) NOT NULL, '
. 'last_name VARCHAR(50) NOT NULL, '
. 'email_address VARCHAR(255) NOT NULL, '
. 'username VARCHAR(30) NOT NULL, '
. 'password VARCHAR(30) NOT NULL, '
. 'activated ENUM("0","1") DEFAULT "0" NOT NULL, '
. 'date_joined DATETIME NULL, '
. 'last_login DATETIME NULL)';
$result = mysql_query($q) or die("Create table Error: ".mysql_error());

It's a heck of alot easier to see errors when you space things out a bit. The investment of the extra CPU time for PHP to glue the pieces together probably makes sense in the long run.

-- Paul Chvostek <paul@no-spam>
it.canada http://www.it.ca/
Free PHP web hosting! http://www.it.ca/web/


Date: Wed, 9 Jul 2003 11:11:13 +0400

Subject: Re: what's wrong with this?????
From: nadim@no-spam (Nadim Attari)
> $result = mysql_query('CREATE TABLE members (userid INT(25) NOT NULL > AUTO_INCREMENT, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(50) NOT > NULL, email_address VARCHAR(255) NOT NULL, username VARCHAR(30) NOT NULL,
> password VARCHAR(30) NOT NULL, activated ENUM('0','1') DEFAULT '0' NOT NULL,
> date_joined DATETIME NULL, last_login DATETIME NULL);')or die("Create table > Error: ".mysql_error());
---------------------------------------------------

- First of all verify ' (single quote) or " (double quote) here... this should solve the problem
BUT - Another problem will crop 'coz u didnot define a key...

Read -----
PRIMARY KEY (index_col_name,...)