Dear experts,

I am a newbie and reading a book to use PHP to create new database with follow codes:

<?php
$host="localhost";
$userdb="root";
$passdb="";
$connecting=mysql_connect($host,$userdb,$passdb);
mysql_create_db("administration",$connecting);
echo"Administration database has been created.";
?>

however, when I load it at my localhost, it said:

Fatal error: Call to undefined function mysql_create_db() in C:\xampp\htdocs\admindb.php on line 6

Kindly need your helps..what is wrong with my codes please..??..because I just pasted from the book..Thank you

Regards,

Rasya

    What version of MySQL?

    From the [man]mysql_create_db/man manual page:

    Note: This function will not be available if the MySQL extension was built against a MySQL 4.x client library.

      what do you mean by below statement..???

      NogDog;10891667 wrote:

      What version of MySQL?

      This function will not be available if the MySQL extension was built against a MySQL 4.x client library.

      mySQL version is 5.0.67 (it looks when I click mysql start (i use XAMPP))...what is the correct syntax for line 6 please..??..

      Thank you for your kind helps..

      Regards,

      Rasya

        for MySQL4.1 lib users;

        as noted the function is a no-go for MySQL4.1 libs. While i do not know the logic behind this i was relieved to see that

        mysql_connect ("localhost","$user","$password")
        $soru = 'CREATE DATABASE '.$dbname;
        mysql_query($soru);

        worked just fine...

          djjjozsi;10891670 wrote:

          for MySQL4.1 lib users;

          as noted the function is a no-go for MySQL4.1 libs. While i do not know the logic behind this i was relieved to see that

          mysql_connect ("localhost","$user","$password")
          $soru = 'CREATE DATABASE '.$dbname;
          mysql_query($soru);

          worked just fine...

          Hi,

          I have tried to put your codes:

          mysql_connect ("localhost","$user","$password")
          $soru = 'CREATE DATABASE '.$dbname;
          mysql_query($soru);
          

          but the result failed:

          mysql_connect ("localhost","$user","$password") $soru = 'CREATE DATABASE '.$dbname; mysql_query($soru);

          ...what should I do in order I can connect to mysql from PHP...???

          kindly need your helps...Thanks a lot...

            why don't you create your database in phpmyadmin?

            if its not installed, then use the php database create. If you are new in php/mysql then that will be usefuly (phpmyadmin)

            this is a template to connect to a database:
            <?
            $hostname=""; // the mysql hostname will placed here, for example localthost.
            $user="
            "; // username to the mysql server
            $pass="*"; // password to the mysql
            $dbase="
            "; // write the database's name here you've created with phpmyadmin

            $connection=mysql_connect("$hostname","$user","$pass");
            $db=mysql_select_db($dbase,$connection); //lets select that database

            ?>

              oo..ok...I did it from myphpadmin....but, for manual script was did not worked...anyway, thanks a lot...it works from myphpadmin 🙂

                when you create the database with phpmyadmin, that shows the working code.

                hello

                  Write a Reply...