Creating Tables.
Posted by: J_M (117.102.33.---)
Date: December 23, 2007 06:45PM

I am using this code to create some tables in a database..

<?php
$con = mysql_connect("localhost","peter","abc123"winking smiley;
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// Create database
if (mysql_query("CREATE DATABASE my_db",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}

// Create table in my_db database
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE person
(
FirstName varchar(15),
LastName varchar(15),
Age int
)";
mysql_query($sql,$con);

mysql_close($con);
?>

But it doesn't seem to work. I've checked in phpmyadmin and there are no tables created.

Is Wamp disabling table creation?

Options: ReplyQuote
Re: Creating Tables.
Posted by: toivo (203.19.130.---)
Date: December 24, 2007 02:11AM

Hi,

If you are creating a new database, I assume your user does not have any access rights to the newly created database.

Please note that giving users universal access rights to all the databases is not very secure.

Regards,

toivo
Sydney, Australia

Options: ReplyQuote


Sorry, only registered users may post in this forum.