SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Call to undefined function mysqli_connect() - Help Required

    Hello all,

    New here, and new to MySQL, but not PHP. Following the book and every single search result I can find on the issue, yet still not solved on my system.

    I installed Apache/PHP/MySQL individually.

    Apache is up and running.(2.2.17)

    PHP is up and running.(5.2.14)

    MySQL is up and running. (5.1.51 Community)

    I can connect to MySQL via cmd.

    However when I try to connect to my database using
    PHP Code:
    <?php

    $link 
    mysqli_connect('127.0.0.1''root''x4yu8');
    if (!
    $link)

      
    $output 'Unable to connect to the database server.';
      include 
    'output.html.php';
      exit();


    $output 'Database connection ok.';
    include 
    'output.html.php';


    ?>
    I get the error which is ruining my day:

    Fatal error: Call to undefined function mysqli_connect() in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 3

    PHP is using the correct php.ini file.

    PHP is listing the correct path for my MySQL install.

    The correct ext path is in PHP.ini.

    The link to php_mysqli.dll has had the semi colon removed.

    The .dll exists on my system.

    I have tried copying 2 .dll's to my system32 folder.

    My windows7 HOSTS file is edited correctly for localhost/127.0.0.1.

    As you can see, I'm nearly out of ideas.

    I have a slight feeling it may have something to do with a lib mysql file?

    Any help would be gratefully received.

    Thank you

    Chris

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2010
    Location
    Netherlands
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does phpinfo or 'php.exe -m' list the mysqli module as being loaded?
    Because the error indicates it's not loaded properly.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2010
    Location
    Netherlands
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kai555 View Post
    your calling
    $link = mysqli_connect('127.0.0.1', 'root', 'x4yu8');
    and it should be
    $link = mysql_connect('127.0.0.1', 'root', 'x4yu8');

    typo
    No, it's not. mysqli is the MySQL Improved Extension. It's actually pretty common. See http://php.net/manual/en/mysqli.overview.php

  4. #4
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mysqli is the improved version, however mysql or mysqli both don't work, when php.ini is set correctly anyway.


    in phpinfo() the only MySQL entries are the paths which are correct;

    C:\Program Files\MySQL\MySQL Server 5.1\bin;
    Under modules I have no MySQL.

    core mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias mod_asis mod_auth_basic mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dir mod_env mod_include mod_isapi mod_log_config mod_mime mod_negotiation mod_setenvif mod_php5

    edit: Just to let you all know I've also got XAMP installed on this machine, and it all works fine using that setup. However I want to get this working. Problems need solving.

  5. #5
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ----------------- * SOLVED * -------------------

    Guide to solving this issue;

    If you are running PHP 5.2, as I was delete your main PHP directory.

    Go to http://windows.php.net/download/

    Read "If PHP is used with Apache 1 or Apache 2 then choose PHP 5.3 VC6"

    Download "VC6 x86 Thread Safe (2010-Jul-21 20:06:17)" installer.

    Install to the location that your previous PHP directory was located.

    Select "Apache" for server type on install.

    Point the install to your Apache sub folder "conf"

    when installed, edit the end of "httpd.conf" and remove the lines the book "build your own database driven website using PHP&MYSQL" told you too add.

    Leave only
    AddType application/x-httpd-php .php
    Follow the books guides to modify the PHP.ini file with the correct location of your doc_root.

    Mine was

    doc_root = C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs

    PHP 5.3 has the mysqli extension already enabled and the windows temp folder.

    Last thing to do is to double check the "extension_dir" setting, point it to the "ext" subfolder inside your PHP directory.

    extension_dir = "C:\PHP\ext"

    Save php.ini

    Reload Apache.

    Should fix it.

    Hope that helps someone.

  6. #6
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now when I try to load the connect.php file I dont see anything, but all my other pages work still.

  7. #7
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,100
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You should be seeing what is in output.html.php, make sure it is not an empty file ie... no echo statements. You can point your browser to output.html.php to make sure.
    What I lack in acuracy I make up for in misteaks

  8. #8
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I now have the same problem where nothing shows up when I got to localhost/connect.

    IF I go to localhost/connect/output.html.php it shows that page fine.

    It seems like the connection to sql is timing out as it takes awhile to load the page and then sits there with nothing on it. Like nothing is running.


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
  •