mysql_create_db doesn't work?? Please help!
Posted: Sat Nov 22, 2003 5:31 am
Hi all
Im learning PHP but am completely stuck on this.... I want to create a database and got this from my book.
Anyone know why this script is unable to make the database?
Lawrence.
Im learning PHP but am completely stuck on this.... I want to create a database and got this from my book.
Code: Select all
<?php
#Database Control
#Creating a Database.
$conn = @mysql_connect("localhost", "BLA BLA", "BLA BLA") or die ("Sorry - could not connect to MySQL: " .mysql_error());
# THIS BIT DOESNT MAKE A DATABASE(?) <----------------------
$rs1 = @mysql_create_db($db) or die ("didn't work");
$rs2 = @mysql_list_dbs( $conn );
for($row=0; $row<mysql_num_rows($rs2); $row++)
{ $list .= mysql_tablename($rs2, $row)." | "; }
?>
<html>
<head><title>Creating Databases</title></head>
<form action = "<?php echo ($PHP_SELF); ?>" method="post">
Current Databases: <?php echo($list); ?> <hr>
Name: <input type="text" name ="db">
<input type="submit" value ="create database">
</form></body></html>Lawrence.