FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

What is wrong with this MySQL query?

 


Fire Boar
I've tried everything... now it's the last resort: seeking help here. I've got a create table query for MySQL but it's not creating. Can someone point out what's wrong? Thanks.
Code:
$querycreate = <<<STRING

CREATE TABLE 'lottery_users' (
'id' INT(11) NOT NULL AUTO_INCREMENT,
'username' VARCHAR(25) NOT NULL,
'tickets' TINYINT(2) NOT NULL,
PRIMARY KEY ('id'),
INDEX ('tickets'),
UNIQUE ('username')
)

STRING;
mysql_query($querycreate);

And yes, I did define and log into the database properly: the script handles other stuff from that table as well and that works fine, it's just creating this table that's the problem.

Thanks.
jeremyyak
I don't really see anything wrong, it could be the apostrophes?

Try this:
Code:
CREATE TABLE lottery_users
(
id INT(11) NOT NULL AUTO_INCREMENT,
username VARCHAR(25) NOT NULL,
tickets TINYINT(2) NOT NULL,
PRIMARY KEY(id),
INDEX(tickets),
UNIQUE(username)
);


Hope you get it working.
~Jeremy~
Fire Boar
Yes, that works, thanks.
raver
next time don't add them, or use ` between them, like:
INSERT INTO `lottery_users`(id, name) VALUES('1', 'proper way to use quotes:D');
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.