MySQL Forums
Forum List  »  Newbie

table creation problem
Posted by: midgetron
Date: June 24, 2005 06:57AM

Hi, Ive created a database on my server but Im unsure about if the code is working correctly as Im trying to create a table which stores blog entries. Im using the following code.

<?php

mysql_connect ('localhost', '$db_midge1', '$db_******') ;
mysql_select_db ('$db_midge1');

$sql="CREATE TABLE php_blog (
id int(20) NOT NULL auto_increment,
timestamp int(20) NOT NULL,
title varchar(255) NOT NULL,
entry longtext NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY id (id)
)";

$result = mysql_query($sql) or print ("Can't create the table 'php_blog' in the database.<br />" . $sql . "<br />" . mysql_error());

if ($result != false)
{
echo "Table 'php_blog' was created!\n";
}

mysql_close();

?>

I was wondering if there was anything wrong with it or if theres a way to find out if the table has been created correctly - it doesnt return any error or other message about it executing.

Thanks for your help.

Options: ReplyQuote


Subject
Written By
Posted
table creation problem
June 24, 2005 06:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.