Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Strange CREATE TABLE Issue

$
0
0
The following query works fine when I do it phpmyadmin.

Code:

DROP TABLE IF EXISTS tmp_price_compare;
                                CREATE TABLE IF NOT EXISTS tmp_price_compare (
                                supplier_reference varchar(32) DEFAULT NULL,
                                quantity int(10) NOT NULL DEFAULT '0',
                                price decimal(20,6) NOT NULL DEFAULT '0.000000',
                                wholesale_price decimal(20,6) NOT NULL DEFAULT '0.000000'
                        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

When I try to put it in my code though like so:

Code:

mysql_query("DROP TABLE IF EXISTS tmp_price_compare;
                                CREATE TABLE IF NOT EXISTS tmp_price_compare (
                                supplier_reference varchar(32) DEFAULT NULL,
                                quantity int(10) NOT NULL DEFAULT '0',
                                price decimal(20,6) NOT NULL DEFAULT '0.000000',
                                wholesale_price decimal(20,6) NOT NULL DEFAULT '0.000000'
                        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;")
                                or die(mysql_error());

it gives me the following error:

Code:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE IF NOT EXISTS tmp_price_compare ( supplier_reference varchar(32' at line 2
Any thoughts?

Thanks,

Ron

Viewing all articles
Browse latest Browse all 13329

Trending Articles