MySQL Error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
c_pattle
Forum Newbie
Posts: 9
Joined: Sat Apr 24, 2010 7:35 am

MySQL Error

Post by c_pattle »

Hey everyone. I'm trying to simply just create a php document that allows me to create a database using MySQL. I've copied my code below (password for mysql is correct but I wanted to hide it).

Code: Select all

<?php

$conn = mysql_connect("localhost","root","******") or die ("Sorry");

$rs1 = mysql_create_db ( $_REQEUST['db'] );

$rs2 = mysql_list_db ($conn );
for( $row = 0; $row < mysql_num_rows ($rs2); $row++) {
	$list.= mysql_tablename( $rs2, $row) . " - ";
}
?>

<html>
<head>
<title>Title</title>
</head>

<body>
<form action="<?php echo ( $_SERVER['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>
When I try to run the page I get this error "Fatal error: Call to undefined function mysql_create_db() in /var/www/test2.php on line 5"

Does anyone know why this is happening?

Thanks for any help
Last edited by John Cartwright on Sat Apr 24, 2010 12:05 pm, edited 1 time in total.
Reason: Please use proper tags when posting code.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: MySQL Error

Post by John Cartwright »

http://ca3.php.net/mysql_create_db wrote: The function mysql_create_db() is deprecated. It is preferable to use mysql_query() to issue a sql CREATE DATABASE statement instead.
Post Reply