FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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');
Related topics
Help with mysql query
MySQL Query Cache
mysql query based on 2 fields using 3 different tables
whats wrong with this mysql query?
what is wrong with this query? Please please help!
MySQL connection
I'm doing something wrong,,,
MySQL Query help
PHP and Javascript Issue handling data from a mysql query
MySQL query limit?
MySQL
n00b mySQL question :D
AJAX tutorial [2nd part now updated]
mySQL Query/PHP code - get the highest value...
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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