hi there,

I am totally new to php and i am using Dreamweaver 8. I am trying to create a page to initiate connection to the MySQL Server 5.0 at localhost, but the browser returns me this error message:

"Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\My_PHP\connect_to_mysql.php on line 11"

The testing code i was trying as below:

<?php
$connection = mysql_connect('localhost', 'root', 'password');
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($connection);
?>

Please help me to solve my problem. Thank y'all very much!

    As of PHP5, the MySQL library is now disabled by default and the new [man]MySQLi[/man] library has taken its place. So, you can either learn to use MySQLi or re-enable MySQL by loading the .dll file as an extension.

      does php 4 have the mysql functions enabled by default? if so, i will remove the php5 and reinstall with php 4.

        Since you're on Windows, yes, the MySQL extension comes already compiled into PHP4.

        Really, though, if you wanted the better OOP functionality of PHP5, you can definitely keep it - the manual page for [man]MySQL[/man] outlines how to (easily) enable the MySQL extension under PHP5.

          hmm......

          I am new to PHP. Could you teach me step by step to enable the MySQL supports for PHP5?

            Did you visit the [man]MySQL[/man] manual page and read the instructions for PHP 5+ under "Installation on Windows Systems" ? The manual usually assumes the end user knows very little about the topic being discussed and is therefore very descriptive.

            Try doing what it says, and if you get stuck, let us know where you're at in the process - what you've done already, what step is confusing you, etc.

              9 days later

              do noit put the pasword that's all
              if it thoes'nt work try the other one:
              <?php
              $connection = mysql_connect('localhost', 'root');
              if (!$connection) {
              die('Could not connect: ' . mysql_error());
              }
              echo 'Connected successfully';
              mysql_close($connection);
              ?>

              <?php
              $connection = mysql_connect("localhost", "root");
              if (!$connection) {
              die('Could not connect: ' . mysql_error());
              }
              echo 'Connected successfully';
              mysql_close($connection);
              ?>

                Write a Reply...