Page 1 of 1

Creating a MySQL table

Posted: Tue Feb 15, 2005 4:03 pm
by Wldrumstcs
Okay, I am at a loss. Where is the error?

Code: Select all

<?
include('connect.php');
$sql = mysql_query("CREATE TABLE users( user_id INT(11) NOT NULL AUTO_INCREMENT, username VARCHAR(255) NOT NULL FULL TEXT, password VARCHAR(32) DEFAULT 0 NOT NULL FULL TEXT, email VARCHAR(255) NOT NULL FULL TEXT, homepage VARCHAR(255) NOT NULL FULL TEXT, aim VARCHAR(100) NOT NULL FULL TEXT, date_format VARCHAR(50) NOT NULL FULL TEXT, date_join INT(11) DEFAULT 0 NOT NULL, post_last MEDINT(9) DEFAULT 0 NOT NULL, post_total MEDINT(9) DEFAULT 0 NOT NULL, PRIMARY KEY(user_id))");
echo 'Creating table: ''users''....';

?>

Posted: Tue Feb 15, 2005 4:04 pm
by feyd
want to at least say what mysql says?

Posted: Tue Feb 15, 2005 4:05 pm
by Wldrumstcs
I am highly confused by what you just wrote... Sorry.

Posted: Tue Feb 15, 2005 4:06 pm
by d3ad1ysp0rk
What. Is. The. MySQL. Error?

Posted: Tue Feb 15, 2005 4:08 pm
by Wldrumstcs
There is no visible error, the table just isn't created.

Posted: Tue Feb 15, 2005 4:11 pm
by d3ad1ysp0rk
You never actually execute the command.

In PHP, when a variable is set to something, it isn't actually evaluated UNTIL it is referenced.
since $sql is never referenced, mysql_query never gets executed. Try just using it as a function instead of storing it as a variable.

Posted: Tue Feb 15, 2005 5:05 pm
by Wldrumstcs
What would the function look like?

...

Posted: Tue Feb 15, 2005 5:49 pm
by s.dot
PHPMyAdmin is a wonderful tool for creating and managing tables. It takes alot of the hassle out of creating it yourself.

Or in your example to execute the command, take the mysql_query( ); off of your $sql variable and then run mysql_query($sql);