Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Posts
    313

    Unanswered: I cannot use PHP to connect MySQL database

    <?php
    $username = "pee_wee";
    $password = "let_me_in";
    $hostname = "localhost";
    $dbh = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");

    print "Connected to MySQL<br>";
    $selected = mysql_select_db("fruit",$dbh)
    or die("Could not select fruit");
    // you're going to do lots more here soon
    mysql_close($dbh);
    ?>

    Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\PHP\connmysql.php on line 5


    I installed MySQL Database server, and PHP, I used IIS 5.1 to run PHP.
    It works for the basic elements.
    But, it doesn't work for connecting to MySQL Database.

    Please let me know what's problem.

    Thanks.

  2. #2
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    The most common reason for this is that the default php.ini for current versions of PHP does not enable the mysql interface dll (what were they thinking.) Find the following line in the php.ini and remove the ; to uncomment it -
    Code:
    change this -
    ;extension=php_mysql.dll
    to this -
    extension=php_mysql.dll
    Under IIS, you must reboot to get this change to take effect.

  3. #3
    Join Date
    Sep 2005
    Posts
    313
    It still doesn't work.


    Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\PHP\connmysql.php on line 5
    PHP Warning: PHP Startup: Unable to load dynamic library './php_mysql.dll' - The specified module could not be found. in Unknown on line 0


    What's wrong with it?

    Thanks.

  4. #4
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    This sounds like an incomplete installation of PHP.

    Which windows binary did you download and install? If you got the .zip full version, it includes the extension dll's. If you got the .exe installer version, it does not include any extensions.

    There is also an extension directory name in the php.ini that must be set. Find the following line in your php.ini and make sure that the path in the quotes points to the location where the extension .dll's are located -
    Code:
    extension_dir = "./ext/"

  5. #5
    Join Date
    Sep 2005
    Posts
    313
    Hi,

    It works, because I install .zip files which includes all library files.

    But, I have another question.

    What is ./ext/?

    Because right now I set it
    extension_dir = "C:\Inetpub\wwwroot\PHP\PHP files\ext"
    It is correct.

    Could you explain ./ext/ to me?

    Thanks.
    Last edited by accessman2; 04-20-06 at 20:28.

  6. #6
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    It is just a sample/possible path.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •