Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

table creation

Codes here !

Moderators: macek, egami, gesf

table creation

Postby xlordt » 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..
User avatar
New php-forum User
New php-forum User
Posts: 34
Joined: Thu Dec 12, 2002 9:00 pm
Location: NJ

Postby Joan Garnet » 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");
User avatar
Joan Garnet
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.