can't create databases

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
In the code below, the mysql_connect commands work correctly (though
I've changed the passwords here).  I get the "We were able to
establish a connection" message. But then the code hangs and does
nothing. What am I doing wrong? The username and password are root, so
I should have the right permissions. The same username and password,
when I put them into phpMyAdmin, allow me to create databases without
a trouble.

    $link = mysql_connect('localhost', 'u345', '2134');
    if ($link) {
        echo "<p>We were able to establish a connection to the
    } else {
        die('Could not connect: ' . mysql_error());

    $result = mysql_create_db($website);
    if ($results) {
              echo "The database '$website' was created.";
    } else {
        die("There was a problem. We were not able to create the database.
It is possisble that a database of the same name already existed, or
perhaps someone recently changed the configuration of the database
server. YOu might want to contact whoever is in charge of the database
and ask them what is up :". mysql_error());

Re: can't create databases

lawrence wrote:
Quoted text here. Click to load it

apparently your mysqld daemon is not running.  Which OS? Register_globals is
another issue, but this one says the mysql server is not running.

Michael Austin.
Consultant - Available.
Donations welcomed.

Re: can't create databases

On 30 Jul 2004 05:47:54 -0700, (lawrence)

Quoted text here. Click to load it

You have two variables: $result and $results. Typo?

Where does $website come from? Recent versions of PHP have
register_globals disabled by default, so you could try using either
$_POST["website"] or $_GET["website"] as appropriate. Echo $website to
check it isn't empty.

David ( )

Re: can't create databases

Quoted text here. Click to load it

Sorry that I left so much out. $website is submitted from a form. The
database is given the same name as the site. We working with PHP
4.0.6, so register_globals is still on by default.

Site Timeline