Jump to content

Recommended Posts

i am creating three tables using PHP

$sql_user = "CREATE TABLE $user(
user_id int(11) AUTO_INCREMENT NOT NULL PRIMARY KEY,
user_name varchar(100) NOT NULL,
user_password varchar(100) NOT NULL,
user_email varchar(100) NOT NULL,
user_ip varchar(20) NOT NULL,
user_ban varchar(3) NOT NULL,
ban_reason varchar(100) NOT NULL,
ban_length varchar(25) NOT NULL,
userlevel tinyint(1) unsigned NOT NULL,
random_key varchar(32) NOT NULL,
user_activated varchar(25) NOT NULL
)";


$sql_forumques = "CREATE TABLE $forum_quest(
id int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
topic varchar(255) NOT NULL default '',
detail longtext NOT NULL,
name varchar(65) NOT NULL default '',
email varchar(65) NOT NULL default '',
datetime varchar(25) NOT NULL default '',
view int(4) NOT NULL default '0',
reply int(4) NOT NULL default '0'
)AUTO_INCREMENT=1";


$sql_forumansw = "CREATE TABLE $forum_answ(
question_id int(4) NOT NULL default '0',
a_id int(4) NOT NULL default '0',
a_name varchar(65) NOT NULL default '',
a_email varchar(65) NOT NULL default '',
a_answer longtext NOT NULL,
a_datetime varchar(25) NOT NULL default '',
KEY a_id (`a_id`)
)";

 

i have a code to check if they already exist, but for the bottom two tables, it always says table created.

this is my checking code

$make_user= mysql_query($sql_user);
$make_forum = mysql_query($sql_forum1);
$make_forum1 = mysql_query($sql_forum2);
$checkifexist_user = mysql_query ("SELECT * FROM '$user' LIMIT 0,1");
$checkifexist_quest = mysql_query ("SELECT * FROM '$forum_quest' LIMIT 0,1");
$checkifexist_answ = mysql_query ("SELECT * FROM '$forum_answ' LIMIT 0,1");

if (!$make_user)
{
echo("'$user' Table already exists.<br>'$user' table could not be created.<br>");
}
else
{
echo("'$user' Table Created.<br>");
}
if (!make_forum)
{
echo("'$forum_quest' Table already exists.<br>'$forum_quest' table could not be created.<br>");
}
else
{
echo("'$forum_quest' Table Created.<br>");
}
if (!make_forum1)
{
echo("'$forum_quest' Table already exists.<br>'$forum_quest' table could not be created.<br>");
}
else
{
echo("'$forum_answ' Table Created.<br>");
}

$sql_forum1 = "CREATE TABLE $forum_quest(
id int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY,
topic varchar(255) NOT NULL default '',
detail longtext NOT NULL,
name varchar(65) NOT NULL default '',
email varchar(65) NOT NULL default '',
datetime varchar(25) NOT NULL default '',
view int(4) NOT NULL default '0',
reply int(4) NOT NULL default '0'
)AUTO_INCREMENT=1";


$sql_forum2 = "CREATE TABLE $forum_answ(
question_id int(4) NOT NULL default '0',
a_id int(4) NOT NULL default '0',
a_name varchar(65) NOT NULL default '',
a_email varchar(65) NOT NULL default '',
a_answer longtext NOT NULL,
a_datetime varchar(25) NOT NULL default '',
KEY a_id (`a_id`)
)";

soz i updated it a bit, bust still the same problem

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.