table creation

Codes here !

Moderators: egami, macek, gesf

Post Reply
User avatar
New php-forum User
New php-forum User
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ

Sun Feb 09, 2003 9:37 pm

this is really weard.. i created this script.. but its not creating the table....

Code: Select all


$db_name = "test";
$table_name = "users";

$db = @mysql_connect("localhost", "x", "123") or
      die ("Could not connect to mysql");
      mysql_create_db($db_name, $db);
      mysql_select_db($db_name, $db);

$db_table = "CREATE TABLE $table_name (id INT NOT NULL AUTO_INCREMENT, username
$table_Creation = mysql_db_query($table_name, $db_table, $db);
  echo "creation as been made successfully!";


i cant figure out why.. =/ the error that i keep getting is..
Computer/Programm rox.. (php, c/c++ will take over soon muhahah

User avatar
Joan Garnet
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Tue Feb 11, 2003 3:53 pm

Try this:

Code: Select all

$sql ="CREATE TABLE ".$table_name."   (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,username VARCHAR(255))";
   $myconn = mysql_connect($server,$user,$password);
if (!@mysql_select_db($database)){
   echo "Couldn't open database";

   echo "Error: ".mysql_error();
   echo ("Table succesfully created");

Post Reply