SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  1. #1
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Just starting: loading php.ini

    I'm working through Build Your Own Database-Driven Website Using PHP & MySQL, 4th Edition, by Kevin Yank, and have hit problems when connecting to mysql db using the first example php script. I've run through the windows installation guide and installed Apache and PHP. I've followed the instructions to create the php.ini file in C:\PHP. I've added the following to Apache's httpd.conf:

    LoadModule php5_module "C:/PHP/php5apache2_2.dll"
    AddType application/x-httpd-php .php PHPIniDir "C:/PHP"


    PHP scrips run fine but on trying the first mysql script example I get the following error.

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

    Running phpinfo shows the php.ini file isn't loading, so the mysqli.dll extension isn't active, giving the fatal error. C:\PHP isn't shown as a valid path.

    I've then copied php.ini to C:\WINDOWS, as this is in the path, and restarted apache. The same script runs successfully, but with the following warning:

    Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50144 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2

    Database connection established.


    So, in the immortal words of Marvin Gay, what's going on? Have the installation instructions missed out on adding C:\PHP to the path, or should updating httpd.conf be enough to pick up the php.ini file?

    Is the warning message indicating my installation has a problem?

    The book said to come here with any problems, so here I am! Cheers.

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    uncomment (remove ';')
    ;extension=php_mysqli.dll in php.ini and restart the server
    my mobile portal
    ghiris.ro

  3. #3
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. The php.ini file already has the extension uncommented - mysql works when it's present in c:\windows - the query was really to establish if anything was missing from the configuration instructions in the book? From what's stated in there it seems they expect the change in httpd.conf to be enough to pick up php.ini and therefore complete the configuration.

  4. #4
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having the same problem. Its really annoying. I've followed the exact steps in the book and keep on getting the warning message. Does anyone know how to get rid of this?

  5. #5
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Code:
    AddType application/x-httpd-php .php PHPIniDir "C:/PHP"
    Those should be on two different lines:

    Code:
    AddType application/x-httpd-php .php 
    PHPIniDir "C:/PHP"
    Try changing that and then restarting the webserver.


    Edit>>
    Sorry, was too quick in answering...
    It seems there is a mismatch between your PHP MySQL extension and your database client software.

    You can try lowering error_reporting before calling mysqli_connect() and then increasing it again afterwards.
    PHP Code:
    $err_level error_reporting(0);
    $conn mysqli_connect('params');
    error_reporting($err_level); 
    It's not the nicest way of doing this, and it doesn't actually solve the problem. I think reinstalling MySQL might help, but I'm not sure...

  6. #6
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Immerse, that httpd.conf change did the trick with the fatal error, I'm getting connected with a corrected c:\php version and the c:\windows version of php.ini deleted.

    I'll play around with the code you've given for suppressing the warning message, but if anyone has chapter and verse on whether the installation is corrupted or if the warning can be ignored I'm still all ears. I'll carry on for now until I hit problems, or reinstall once I'm familiar with the code and getting annoyed by the warnings.

  7. #7
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Glad it's fixed!

    It's generally not a good idea to ignore or supress warnings - they're there for a reason.
    I generally tend to stop script execution on even the most trivial notice, that way I know I'm writing error-free code. Sometimes changing the error level can't be avoided though.

  8. #8
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This book has really got me frustrated! I've uninstalled/installed MySQL, Apache and PHP and followed the installation guidelines in the book perfectly and can't get it to work properly. I've even tried it on different operating systems and still get the same problem. There must be an error in the installation guidelines, which is an extremely poor mistake by the writer.

    The warning message that keeps appearing is having an effect. Whenever I try to extract more than one element from a database table my browser messes up and a 'send report to windows' message window appears.

    I'm giving up. I've tried everything and have wasted 4 days. Definitely returning this book!

  9. #9
    SitePoint Zealot
    Join Date
    Oct 2008
    Location
    NE Ohio
    Posts
    117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chris_samsung View Post
    I'm having the same problem. Its really annoying. I've followed the exact steps in the book and keep on getting the warning message. Does anyone know how to get rid of this?
    I'm having the exact same problem, and I am also using Kevin's book. I've been battling this for several weeks, but it was only in the last couple of days that I learned what the real problem was (PHP not loading php.ini).

    I was trying to get Joomla to work. It would not recognize MySQL support. No help from the Joomla forum. They made some suggestions, which didn't help, because I was already set up correctly (per Kevin's book).

    I tried to install phpMyAdmin. Got "Cannot load mysql extension. Check your PHP configuration."

    Many hours later and some Google searching revealed the real problem was as above: Not loading the php.ini file.

    I have still not found the solution. I've put the file in the Windows directory (not recommended by most). Same result. PHP is simply not recognizing this file.

    There has to be a solution, but at this point, I'm stumped.

    I'm running WindowsXP professional with service pack 3 installed, Apache 2.2, PHP 5.2.13 (tried a newer version to see if it would help...didn't) and MySQL 5.1.
    William Otis
    Flamenco aficionado and Freelance Web designer
    www.dreammakergraphics.com/

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Some information that might help is to investigate the errata for the book.

    For example:

    p.7 step 2
    In PHP 5 or later, you must copy the libmysql.dll file from the PHP installation directory to your system32 directory along with php5ts.dll.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  11. #11
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I ve bought the book and flowed the same instruction but unfortunately i had the same problem...is there any solution..?
    thx


    Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50144 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\welcome\index.php on line 11

    Warning: mysqli_connect() [function.mysqli-connect]: (/1207959552): in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\welcome\index.php on line 11
    Unable to connect to the database

  12. #12
    SitePoint Zealot
    Join Date
    Oct 2008
    Location
    NE Ohio
    Posts
    117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    Some information that might help is to investigate the errata for the book.

    For example:

    p.7 step 2
    In PHP 5 or later, you must copy the libmysql.dll file from the PHP installation directory to your system32 directory along with php5ts.dll.
    You have an old book. Mine is the 4th edition. The install instructions are written for PHP5.

    There is no such note on page 7.

    Further, under the Apache configuration instructions, the line is added at the bottom of httpd.conf:

    PHPIniDir "c:/php5/"
    William Otis
    Flamenco aficionado and Freelance Web designer
    www.dreammakergraphics.com/

  13. #13
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Billo...

    is your post an answer to my question:

    Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50144 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\welcome\index.php on line 11

    Warning: mysqli_connect() [function.mysqli-connect]: (/1207959552): in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\welcome\index.php on line 11
    Unable to connect to the database

  14. #14
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,260
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    Hi bmcgill, chris_samsung and hussein82, welcome to the forums,

    I always have problems with installations. Even though the book recommends installing the components separately so you can later upgrade them separately and you will learn more about how the platform works, don't let problems stop you from getting on with the book.

    IMHO you should try something like XAMPP, WAMP, EasyPHP, etc, that will install all the components in one go. You will be somewhat limited to what versions the components are. But you will not need to worry about dependencies, interoperability, etc.

    This book is primarily about learning PHP and MySQL so once you get a platform installed and working you should have no problems with the rest of the book. Then if you want to tackle installing things separately you can always go back and try again later.

  15. #15
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mittingeague for your reply..

    Actually we can use other programmes to run the scrip such as the ones you recommended easyphp, wamp, but the idea behind installing php and mysql separately is to understand how the relationship works between them, the book has recommended that as well so i am trying to flow his methodology to sort the problem step by step and get experience to troubleshoot such problems ....

    Thanks again

  16. #16
    SitePoint Zealot
    Join Date
    Oct 2008
    Location
    NE Ohio
    Posts
    117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hussein82 View Post
    Hi Billo...

    is your post an answer to my question:

    Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50144 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\welcome\index.php on line 11

    Warning: mysqli_connect() [function.mysqli-connect]: (/1207959552): in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\welcome\index.php on line 11
    Unable to connect to the database
    I'm not sure what you are experiencing, but it could be related, I suppose. I was having problems getting php to load the custom php.ini file, and therefore no extensions were being loaded.

    Here is what worked. I read this post this morning. Immediately downloaded the new version of php5.3.2, installed it, configured it, started the troublsome programs, and "boom", they worked. A look at the phpinfo() showed that php was now loading the php.ini file. Link to that SitePoint Forum thread is here: http://www.sitepoint.com/forums/show...7&goto=newpost
    William Otis
    Flamenco aficionado and Freelance Web designer
    www.dreammakergraphics.com/

  17. #17
    SitePoint Enthusiast
    Join Date
    Jul 2009
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi bmcgill...
    i had installed php, mysql and apache some months ago in my computer following the instructions from kevin's book. and there was no problem. everything was working fine.

    i bought a new computer last week and installed the latest versions in the new computer. after installing and running it. i got the error which u got:
    Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50145

    i reinstalled everything and again i was receiving the same error. i had the same conf for mysql, php and apache as u've mentioned.

    i uninstalled apache and php. and installed the earlier versions which i was using: apache- 2.2.11 and php-5.3.0. this time everything was working fine and there was no error

    well it just worked like that for me. that's why i'm telling. i don't know why it worked now.

    i was searching about this issue in net, and in a forum in mysql's website i found that some other person had this problem with a much earlier versions. he reinstalled php and the problem was solved.

  18. #18
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm also stuck on Chapter 4 of 'Build Your Own Database Driven Web Site using PHP and MySQL' 4th Edition.

    My error:
    Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50145 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index.php on line 2

    Warning: mysqli_connect() [function.mysqli-connect]: (/1207959552): in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index.php on line 2

    Unable to connect to the database server.


    Will have a tinker and report back.

  19. #19
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got rid of the "Headers and client library minor version mismatch" error by installing PHP 5.3.2 on my system.

  20. #20
    SitePoint Member
    Join Date
    Jun 2002
    Location
    USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would like to give my 2piece cents to this. I too was struggles with these problems until I followed to where pmw57 (thanks by the way) direction assisted me.
    Okay for this problem: " Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50144 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php"

    The solution can be found right here:
    http://www.sitepoint.com/books/phpmy...792e90dbdfc002

    Confirmed errors in the October 2004 Third Edition:

    Some of the errors listed here may also apply to the previous edition (see below), although page numbers will almost certainly differ.
    p.7 step 2
    In PHP 5 or later, you must copy the libmysql.dll file from the PHP installation directory to your system32 directory along with php5ts.dll.


    I hope this helps!

  21. #21
    SitePoint Member mailtoshree's Avatar
    Join Date
    Apr 2010
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chris_samsung View Post
    I'm having the same problem. Its really annoying. I've followed the exact steps in the book and keep on getting the warning message. Does anyone know how to get rid of this?
    I am also languising with the same problem for 3 weeks or so still no respite. My problem is when i try to fetch multiple columns from the databse i get http 500 error(som process is internally getting aborted abnormally i have tried on IIS as well as Apache). This is really making me go crazy.

  22. #22
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Go to the errata for the book.
    http://www.sitepoint.com/books/phpmy...rect=phpmysql1

    Find out the Month and Year that your book was printed.

    Most likely you will need to copy some dll files across to your windows installation.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  23. #23
    SitePoint Member mailtoshree's Avatar
    Join Date
    Apr 2010
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pmw57 View Post
    Some information that might help is to investigate the errata for the book.

    For example:

    p.7 step 2
    In PHP 5 or later, you must copy the libmysql.dll file from the PHP installation directory to your system32 directory along with php5ts.dll.
    I did as PMW (paul) said now i hav no issues with my setup i feel others having the same problem should give a try. Thanks PMW

  24. #24
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    pmw's solution for the:
    "Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50144 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php" problem works for me too. Using xp sp2, php 5.2.13, mysql 5.1.48


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
  •