SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Fatal error: Call to undefined function mysqli_connect() in C:\Program Files (x86)\Ap

    I know there's another thread on this but it doesn't help me.

    Reading Database Driven Websites and I come to this error when I try to run this code:

    PHP Code:
    <?php
    $link 
    mysqli_connect('localhost''root''password');
    if (!
    $link)
    {
        
    $output 'Unable to connect to the datbase server.';
        include 
    'output.html.php';
        exit();
    }

    if (!
    mysqli_set_charset($link'utf8'))
    {
        
    $output 'Unable to set database connection encoding.';
        include 
    'output.html.php';
        exit();
    }

    if (!
    mysqli_select_db($link'ijdb'))
    {
        
    $output 'Unable to locate the joke database.';
        include 
    'output.html.php';
        exit();
    }

    $output 'Database connection established.';
    include 
    'output.html.php';?>
    Of course, I filled in password with my real password. I checked my PHP info and the Loaded Configuration File was configured correctly i.e. extension=php_mysqli.dll was uncommented in php.ini. My php version is 5.3.5. I installed the thread safe version of PHP. I tried changing the localhost to 127.0.0.1. I tried everything in that thread and nothing helps. I can't even get a different error message. It just keeps coming up: Fatal error: Call to undefined function mysqli_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2.

    Can someone please help. I'm itching to move on in the book. Thanks in advance.
    Last edited by SpacePhoenix; Feb 5, 2011 at 14:40. Reason: put php tags round php code to improve readability

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,034
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Run the following:

    PHP Code:
    <?php
    echo 'The following PHP extensions are loaded on this server';
    echo 
    '<pre>';
    print_r(get_loaded_extensions());
    echo 
    '</pre>';
    ?>
    It will list all the PHP extensions which are currently loaded on the server concerned. Is there an entry in the outputted list for mysqli ?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what I get:

    The following PHP extensions are loaded on this server

    Array
    (
    [0] => Core
    [1] => bcmath
    [2] => calendar
    [3] => com_dotnet
    [4] => ctype
    [5] => date
    [6] => ereg
    [7] => filter
    [8] => ftp
    [9] => hash
    [10] => iconv
    [11] => json
    [12] => mcrypt
    [13] => SPL
    [14] => odbc
    [15] => pcre
    [16] => Reflection
    [17] => session
    [18] => standard
    [19] => mysqlnd
    [20] => tokenizer
    [21] => zip
    [22] => zlib
    [23] => libxml
    [24] => dom
    [25] => PDO
    [26] => Phar
    [27] => SimpleXML
    [28] => wddx
    [29] => xml
    [30] => xmlreader
    [31] => xmlwriter
    [32] => apache2handler
    [33] => mhash
    )

  4. #4
    SitePoint Addict Kevinslair's Avatar
    Join Date
    Jul 2002
    Location
    Binghamton
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm jealous. My hosting company doesn't have mcrypt. LOL
    I PHP!

  5. #5
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can someone please help me with this? I've been all over the internet looking for a solution and I literally can't find anything that helps.

  6. #6
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,034
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Did you remove the ; from in front of the extension=php_mysqli.dll or was it not there, if you removed it, did you reboot the server afterwards?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  7. #7
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Removed it a restarted the server.

  8. #8
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. I figured out the original problem but now I get these error messages:

    Warning: mysqli_connect() [function.mysqli-connect]: [2002] No connection could be made because the target machine actively (trying to connect via tcp://127.0.0.1:3306) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

    Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): No connection could be made because the target machine actively refused it. in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

    Any suggestions for these new problems? Thanks.

  9. #9
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,034
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Check your firewall, it may be blocking access to the port
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  10. #10
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Turned off all firewalls and still getting the same messages.

  11. #11
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,034
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Try going back to using localhost for the hostname
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  12. #12
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, tried that too. The error message just changes from: (trying to connect via tcp://127.0.0.3:3306)

    to: (trying to connect via tcp://localhost:3306)

    Wow. I've been at this for hours and I just can't find a solution. Very frustrating.

  13. #13
    SitePoint Zealot ChrisWiegman's Avatar
    Join Date
    Sep 2010
    Location
    Austin, Texas, United States
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Verify the mysql server is running and boud to a network port as opposed to trying to use a socket.

  14. #14
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apache is running on port 80.

  15. #15
    SitePoint Member
    Join Date
    May 2004
    Location
    United Kingdom
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mdragotta1 View Post
    Ok. I figured out the original problem but now I get these error messages:

    Warning: mysqli_connect() [function.mysqli-connect]: [2002] No connection could be made because the target machine actively (trying to connect via tcp://127.0.0.1:3306) in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

    Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): No connection could be made because the target machine actively refused it. in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

    Any suggestions for these new problems? Thanks.
    You said you have figured out the original problem. I am experiencing the exact same problem, would you care to share with me the solution?

  16. #16
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're getting the error message:

    Fatal error: Call to undefined function mysqli_connect()

    then, the "mysqli" module is probably not being loaded by php. You can confirm this by running phpinfo(); in your php code. If "mysqli" is not listed in the resulting page, then it is not being loaded.

    I'm using php 5.3.6, and mysql 14.14 on Windows 7. The solution that successfully loads "mysqli" for me (and prevents the above error message) is to download "libmysql.dll" from libmysql.dll free download - DLL-files.com and put it in my path, or just copy it to my Windows folder.

    Ironically, I found this solution by reading PHP: Installation - Manual, which says that for php 5.3.0+ you don't need to configure access to "libmysql.dll"!


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
  •