Jump to content

Archived

This topic is now archived and is closed to further replies.

Avalanche

Membership Tutorial Help

Recommended Posts

Yes, I know, this should be in the tutorial help, but as I see not many people go there, so I thought I\'d post here. Anyways, I\'m creating the table users with all the fields, and here is my code:

 

[php:1:923f2c57a2]<?php

 

$conn=mysql_connect (\"localhost\", \"burnttoa_tehuser\", \"<mypasswordhere>\") or die (\'I cannot connect to the database because: \' . mysql_error());

mysql_select_db (\"burnttoa_tehdb\",$conn);

 

$sql = \'CREATE TABLE `users` ( `userid` INT(25) NOT NULL, `first_name` VARCHAR(25) NOT NULL, `email_address` VARCHAR(25) NOT NULL, `username` VARCHAR(25) NOT NULL, `password` VARCHAR(255) NOT NULL, `info` TEXT NOT NULL, `user_level` ENUM(\'0\',\'1\',\'2\',\'3\') DEFAULT \'0\' NOT NULL, `signup_date` DATETIME DEFAULT \'0000-00-00 00:00:00\' NOT NULL, `last_login` DATETIME DEFAULT \'0000-00-00 00:00:00\' NOT NULL, `activated` ENUM(\'0\',\'1\') DEFAULT \'0\' NOT NULL, PRIMARY KEY (userid) ) TYPE = MYISAM COMMENT = \'Membership Information\';\';

if ($sql==FALSE) {

print \"<code><b>error:</b> query1 failed.<br></code>\";

} else {

print \"<code>query1 was successful.<br></code>\";

}

 

mysql_close($conn);

 

?>[/php:1:923f2c57a2]

 

It says the query was sucessful, but whenever I look at my databases it says there is no table there.

 

Could somebody help?

Share this post


Link to post
Share on other sites

Hello buddy

 

were is the

mysql_query

statement??

 

U have to give this command to execute the query

Share this post


Link to post
Share on other sites

Okay...

 

[php:1:754b4a81ee]<?php

 

$conn=mysql_connect (\"localhost\", \"burnttoa_tehuser\", \"<mypass>\") or die (\'I cannot connect to the database because: \' . mysql_error());

mysql_select_db (\"burnttoa_tehdb\",$conn);

 

$sql = mysql_query(\"CREATE TABLE \'users\' ( \'userid\' INT(25) NOT NULL, \'first_name\' VARCHAR(25) NOT NULL, \'email_address\' VARCHAR(25) NOT NULL, \'username\' VARCHAR(25) NOT NULL, \'password\' VARCHAR(255) NOT NULL, \'info\' TEXT NOT NULL, \'user_level\' ENUM(\'0\',\'1\',\'2\',\'3\') DEFAULT \'0\' NOT NULL, \'signup_date\' DATETIME DEFAULT \'0000-00-00 00:00:00\' NOT NULL, \'last_login\' DATETIME DEFAULT \'0000-00-00 00:00:00\' NOT NULL, \'activated\' ENUM(\'0\',\'1\') DEFAULT \'0\' NOT NULL, PRIMARY KEY (userid), TYPE = MYISAM COMMENT = \'Membership Information\'\");

if ($sql==FALSE) {

print \"<code><b>error:</b> query1 failed.<br></code>\";

} else {

print \"<code>query1 was successful.<br></code>\";

}

 

mysql_close($conn);

 

?>[/php:1:754b4a81ee]

 

The query fails. What\'s wrong now?

Share this post


Link to post
Share on other sites
CREATE TABLE users ( userid INT(25) NOT NULL, first_name VARCHAR(25) NOT NULL, email_address VARCHAR(25) NOT NULL, username VARCHAR(25) NOT NULL, password VARCHAR(255) NOT NULL, info TEXT NOT NULL, user_level ENUM(\'0\',\'1\',\'2\',\'3\') DEFAULT \'0\' NOT NULL, signup_date DATETIME DEFAULT \'0000-00-00 00:00:00\' NOT NULL, last_login DATETIME DEFAULT \'0000-00-00 00:00:00\' NOT NULL, activated ENUM(\'0\',\'1\') DEFAULT \'0\' NOT NULL, PRIMARY KEY  (userid), TYPE = MYISAM COMMENT = \'Membership Information\')

Share this post


Link to post
Share on other sites

Okay, thanks, but I just realized the tutorial said \"run the SQL statement with phpmyadmin\" not \"use phpmyadmin to make the table\".

 

So I just ran the script (in the tutorial) instead and it works.

 

Thanks for your time and effort, though. I appreciate it.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.