[thelist] creating a mySQL table dynamically in php
sasha
spam at bittersweet2.com
Mon Jan 6 15:14:01 CST 2003
On Mon, 6 Jan 2003 13:02:43 -0800 (PST), Tom Dell'Aringa
<pixelmech at yahoo.com> wrote:
> I'm trying to create a table in my DB with a script. Here is the
> code:
> -----------------
> // connection stuff
>
> $sql = " CREATE TABLE test (";
> $sql .= " pid VARCHAR(12), ";
> $sql .= " qty VARCHAR(12), ";
> $sql .= " ); ";
>
> if(!@mysql_query($sql))
> {
> print "Err" . mysql_error();
> exit();
> }
> -----------------
>
> I don't get the table, I keep getting this type of error:
>
> You have an error in your SQL syntax near '); ' at line 1
Try removing the first semicolon in the last $sql .= line. You don't need
semicolons at the end of a sql statement in php.
First lesson in debugging: print your output. If it's a variable, print
the variable. If it's an array, print_r the array.
Might I also recommend this:
http://www.evolt.org/article/rating/17/41393/index.html
--
sasha
More information about the thelist
mailing list