Jump to content

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?

Link to comment
https://forums.phpfreaks.com/topic/301-membership-tutorial-help/
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?

Link to comment
https://forums.phpfreaks.com/topic/301-membership-tutorial-help/#findComment-951
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\')

Link to comment
https://forums.phpfreaks.com/topic/301-membership-tutorial-help/#findComment-952
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.