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_Projects\Chapter.08\Chapter\CreateNewsLetter.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>
assaultkittyAsked:
Who is Participating?
 
DerokorianCommented:
Look at the error you get - mysql_create_db IS NOT a function in php. Unless you were define it as such, which, again, according to your error you haven't. I'm providing you with options that work with functions built into PHP already.
0
 
DerokorianCommented:
I believe you are looking to use mysql_select_db as that is a real function and mysql_create_db is not.
0
 
DerokorianCommented:
Tho it appears you are looking to create a DB so  you would issue a query for that:

if( mysql_query("CREATE DATABASE $DBName") ) {
0
 
assaultkittyAuthor Commented:
Why do I have to use these function?  Are they deprecated function?
0
 
assaultkittyAuthor Commented:
Very fast response.  Thank you!!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.