assaultkitty
asked on
Newsletter PHP
I am having problems with this program. @ this line if (mysql_create_db($DBName, $DBConnect) === FALSE)
The error is
( ! ) Fatal error: Call to undefined function mysql_create_db() in C:\wamp\www\9780538745840_ Data\PHP_P rojects\Ch apter.08\C hapter\Cre ateNewsLet ter.php on line 19
Can you help me?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Create Newsletter Database</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
$DBName = "newsletter";
$DBConnect = mysql_connect("localhost", "root", "");
if ($DBConnect === FALSE)
echo "<p>Connect error: "
. myqsql_error() . "</p>\n";
else
{
if (mysql_create_db($DBName, $DBConnect) === FALSE)
echo "<p>Could not create the \"$DBName\" " .
"database: " . mysql_error($DBConnect) .
"</p>\n";
else
echo "<p>Successfully created the " .
"\"$DBName\" database.</p>\n";
mysql_close($DBConnect);
}
?>
</body>
</html>
The error is
( ! ) Fatal error: Call to undefined function mysql_create_db() in C:\wamp\www\9780538745840_
Can you help me?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Create Newsletter Database</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
$DBName = "newsletter";
$DBConnect = mysql_connect("localhost",
if ($DBConnect === FALSE)
echo "<p>Connect error: "
. myqsql_error() . "</p>\n";
else
{
if (mysql_create_db($DBName, $DBConnect) === FALSE)
echo "<p>Could not create the \"$DBName\" " .
"database: " . mysql_error($DBConnect) .
"</p>\n";
else
echo "<p>Successfully created the " .
"\"$DBName\" database.</p>\n";
mysql_close($DBConnect);
}
?>
</body>
</html>
I believe you are looking to use mysql_select_db as that is a real function and mysql_create_db is not.
Tho it appears you are looking to create a DB so you would issue a query for that:
if( mysql_query("CREATE DATABASE $DBName") ) {
if( mysql_query("CREATE DATABASE $DBName") ) {
ASKER
Why do I have to use these function? Are they deprecated function?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very fast response. Thank you!!!!!