Jump to content

table already exists


addyp

Recommended Posts

hi guys, I just started using msql for the frist time and am having some problems, when i go to create the new table i get the error "table already exists" i have placeds an IF statment to see is the table is created and if not to make one, however it is still returning the same error,

ill post the code below anyhelp would be much apricated

<?php
if (empty($_POST['bug_ID']))
echo "<p>You must enter a BUG ID number, No Bug Recorded</p>";
else {
$bugID = addslashes($_POST['bug_ID']);	
$name = addslashes($_POST['bug_name']);	
$date = addslashes($_POST['Date']);	
$sDescription = addslashes($_POST['shortDiscription']);
$lDescription = addslashes($_POST['Discription']);	
$action = addslashes($_POST['action']);	
}

$table = "
create table bugs (
ID varchar (50) not null,
Name varchar (50) not null,
Date varchar (50) not null,
ShortDescription varchar (50) not null,
LongDescription varchar (100) not null,
Action varchar (100) not null,
primary key (ID)
)";

$conn=mysql_connect("xxxxxxxxxxx","xxxxxxxxxxx","xxxxxxxxxx");
mysql_select_db("xxxxxxx");

$sql="SELECT * FROM $table";

$result=@mysql_query($sql);


umask(0007);
if (!$result)
{
mysql_query($table)
or die(mysql_error());
}

if(isset($_POST['submit']))
{

mysql_query("INSERT INTO bugs (ID, Name, Date, ShortDescription, LongDescription, Action)
VALUES ('$bugID', '$name', '$date', '$sDescription', '$lDescription', '$action')");
}
echo "table updated";
mysql_close();

?>

 

Link to comment
https://forums.phpfreaks.com/topic/215772-table-already-exists/
Share on other sites

Archived

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

×
×
  • 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.