SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysqli_connect and mysql_connect (using PHP 5.0.4 and Mysql 4.1.7)

    Hi all,

    I install PHP ver 5.0.4 and mysql 4.1.7 in my WinXP system using IIS as web server.

    The following codes, using mysql_connect, work!

    Code:
    <html>
    <head><title>Open and Close Mysql connection</title></head>
    <body>
    <?
    // Connection to Mysql 
    $link = @mysql_connect( 
                'localhost',  // localhost 
                'root',       // user 
                '');    // password = null
    if ( !$link ) {
       echo "Error code: ".mysql_errno()."<br>";
       echo "Error info: ".mysql_error()."<br>";
       exit();
    }
    else {
       echo "Connection to MySQL !<br>";
    }
    mysql_close($link);  // close connection
    
    ?>
    </body>
    </html>
    BUT,

    the following codes, which using mysqli_connect, DO NOT work!

    Code:
    <html>
    <head><title>Open and Close Mysql connection</title></head>
    <body>
    <?
    // Connection to Mysql 
    
    $link = @mysqli_connect( 
                'localhost',  // localhost
                'root',       // user 
                '123456',     // password = null 
                'school');    // Database 
    if ( !$link ) {
       echo "Error code: ".mysqli_connect_errno()."<br>";
       echo "Error info: ".mysqli_connect_error()."<br>";
       exit();
    }
    else {
       echo "Connection to MySQL !<br>";
       echo "Database: school<br>";
    }
    mysqli_close($link); // Close connection
    ?>
    </body>
    </html>
    I read the html code for cose using mysqli_connect, the php codes run end at follows:

    Code:
    <html>
    <head><title>Open and Close Mysql connection</title></head>
    <body>
    ie: until beginning of html body ...


    Does anyone have any idea of it?

    Thanks.

    p/s: If change to ... (does not have @)

    Code:
    $link = mysqli_connect( 
                'localhost',  // localhost
                'root',       // user 
                '123456',     // password = null 
                'school');    // Database
    Error message of: : Call to undefined function mysqli_connect()
    Last edited by cyberlearner; Aug 6, 2005 at 09:52.

  2. #2
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Additional question:

    I read the book written by Harry Fuecks, The PHP Anthology
    Volume I: Foundations, Chapter 3: PHP and MySQL. If not mistaken, Harry Fuecks does not include the "improved" mysql function in this book athough the book is "PHP ready".

    Why?
    Do you think that we should stick with "Non-improvement mysql function", which does not have "i", for example mysql_connect instead of mysqli_connect?

  3. #3
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Up for attention.

    Thanks.

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    this is a PHP question, not a mySQL connection. but, the answer is you do not have the mysqli extension for PHP enabled in your php.ini file or you do not have the proper DLL's in the proper folders.

    do a search for "Call to undefined function mysqli_connect" in the PHP forum. there are probably lots of good threads on that.

  5. #5
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    mine didn't work until i copied libmysql.dll to my windows directory.


Bookmarks

Posting Permissions

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