SitePoint Sponsor

User Tag List

Results 1 to 16 of 16

Thread: PHP.ini

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP.ini

    Allright boys and girls...

    I am having a problem getting the apache server on my Vista based computer to load the PHP.ini file. I ran PHP Info and it shows the PHP.ini path as C:\Windows and no configuration file is loaded.

    I have this at the bottom of my httpd.conf file:

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

    Both paths are pointing to the correct directories and I have restarted the apache server a couple of times. Anyone got any ideas?

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I finally got it fixed. I was trying to install PHP 5.3 and dropped back to 5.2.11 and it worked the first time I tried. Which is kinda weird because I had to upgrade to 5.3 before to solve a different problem.


    Something tells me that 5.3 is not quite stable...but that just may be me...

  3. #3
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by michaelk46 View Post
    I finally got it fixed. I was trying to install PHP 5.3 and dropped back to 5.2.11 and it worked the first time I tried. Which is kinda weird because I had to upgrade to 5.3 before to solve a different problem.


    Something tells me that 5.3 is not quite stable...but that just may be me...
    I have the same issue you had except that I am on 5.2.11. I also went from the book and still no dice for me.

    could it be that my error is in the $link = mysql_connect('localhost', 'root', 'password'); string?

    for 'localhost' I leave it as is

    for 'root' I leave as is

    for 'password' I use the password that I created for the mysql database earlier in the book.

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    I dont want to sound rude or anything...I just am that way. While PHP 5.3 may not have work for you that would not mean it is unstable. The problem is a local problem, not a global problem. But lets get a few things out of the way. Did you download the correct version? For Apache using mod_php you want thread safe VC6. For Apache and cgi you wast VC6, thread safety does not matter. For IIS 7 (comes with Vista) it will use FastCGI, VC9 again thread safety non-issue with cgi.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


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

    Exclamation

    Thanks for your feedback. I agree that this is a local problem. It's also a lack of knowledge problem.

    From what I understand what you are saying is that I need VC6?

    I am running Apache 2.2, MySql 5.1, and PHP 5.2.11. Does this qualify for the current version--save PHP 5.3?

    To my knowledge I am not using mod_php. What I know is what I learned thus far to page 121 (chapter 4) in the php my sql book.

    When I attempt to connect php to mysql I get the following error:

    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 anyone help me work this out please?

  6. #6
    SitePoint Zealot Gman's Avatar
    Join Date
    Jan 2002
    Location
    Sarasota, FL
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you need to uncomment this line in your php.ini

    extension=php_mysqli.dll

    then restart apache

  7. #7
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation

    Quote Originally Posted by Gman View Post
    you need to uncomment this line in your php.ini

    extension=php_mysqli.dll

    then restart apache
    By uncomment I assume you mean remove the ; so it looks like this:

    extension=php_mysqli.dll

    I restarted Apache anyway and still received the error. Is it possible that I have the wrong code?

    This is output.html.php
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    <body>
    <p>
    <?php echo $output; ?>
    </p>
    </body>
    </html>

    This is index.php

    <?php
    $link = mysqli_connect('localhost', 'root', 'password');
    if (!$link)
    {
    $output = 'Unable to connect to the database 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';
    ?>

    Am I missing something?

  8. #8
    SitePoint Member
    Join Date
    Feb 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im having exaclty the same problems after following the same instructions in the 'build your own' book.

    Im running apache 2.2.14 , php 5.2.12 and mysql 5.1.43

    i went back and checked all the directed steps for installation and setup (including the editing in the php.ini file), and I am still receiving the same error message as kjt4eva


  9. #9
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello --

    I am having a similar problem. I've installed PHP, Apache, and MySQL, following the instructions in the book and the corrections on the errata page to the dot.

    The PHP works fine, and the MySQL works fine, but when I try to connect it times out.

    The strange thing is that I know the mysqli library is loading because it shows up when I dump the phpinfo() function. I am attaching a screenshot of the configuration.

    Here is the error message I get:

    ***************

    Warning: mysqli_connect() [function.mysqli-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2

    Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2

    Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2

    ***************

    And here is the code I am using:

    Code PHP:
    <?php
    $link = mysqli_connect('localhost', 'root', '------');
    if (!$link)
    {
    	$output = 'Unable to connect to the database 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';
    ?>

  10. #10
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    Error 2002 means a socket couldnt be established to the mysql server. Is MySQL running and online on port 3306?

  11. #11
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    StarLion -- Thank you for your reply.

    Yes, MySQL is running and it is configured to use port 3306.

    Sorry, I forgot to include a screenshot of the configuration last time. Here it is:

    http://www.trilefile.com/phpinfo_mysqli.jpg

  12. #12
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a similar problem:

    I got this error message below when I typed http://localhost/chapter4/connect into my browser:

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

    Please advise! Thank you.

  13. #13
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yuhonwai View Post
    I have a similar problem:

    I got this error message below when I typed http://localhost/chapter4/connect into my browser:

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

    Please advise! Thank you.
    That's a little different error message. Double-check that you have the following uncommented in your php.ini file:

    extension_dir = "C:\PHP\ext"

    (or whatever your directory set-up is)

    Also check that

    extension=php_mysqli.dll

    is uncommented (no semicolon.)

    The mysqli is not recognized on your system for some reason.

  14. #14
    SitePoint Member
    Join Date
    Jun 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply!

    Both are accomplished already, but I still get the same message. What else can I do? I checked phpinfo() and the Loaded Configuration File is currently none. Is that a problem? How can I make it the right path?

  15. #15
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by yuhonwai View Post
    Thanks for your reply!

    Both are accomplished already, but I still get the same message. What else can I do? I checked phpinfo() and the Loaded Configuration File is currently none. Is that a problem? How can I make it the right path?
    Shoot. I honestly don't know. I am not that advanced. I do believe that phpinfo() should give you the configuration, so that seems to be a problem.

    Maybe you should start a new thread on the subject... alternatively, there must be a PHP forum out there somewhere.

    To my judgement, it sounds like you've got an issue with the actual PHP installation.

  16. #16
    SitePoint Enthusiast
    Join Date
    May 2010
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have figured out the answer to the problem I was experiencing. I am documenting below, just in case it helps anyone else.

    =========================

    I recently came across a problem when working through the 4th edition of Kevin Yank's "Build Your Own Data-Driven Website."

    There appears to be an incompatibility between certain software packages and operating systems. In particular, this affects PHP 5.3 when trying to connect to MySQL while running on Windows Vista with Apache. It is not really a bug, but a discrepancy between how far along the different elements are in the transition from IPv4 to IPv6.

    Basically, when PHP tries to connect to the database, it times out because it does not recognize localhost, only 127.0.0.1, and produces the following error message:

    =========================

    Warning: mysqli_connect() [function.mysqli-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2

    Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2

    Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2

    =========================

    There are two possible solutions to this problem:

    =========================

    1. Replace "localhost" with "127.0.0.1" in all PHP files that you wish to have connect to a MySQL database

    2. Locate the "hosts" file on your computer. It is typically at a location such as this:

    C:\Windows\System32\drivers\etc\hosts

    Open it up, and comment out the line that prevents the localhost from "mapping" correctly; in otherwords, change

    ::1 localhost

    to

    #::1 localhost

    This solution was, in fact, presented in the SitePoint forums previously, though without a full explanation of the details.

    http://www.sitepoint.com/forums/showthread.php?t=637612

    =========================

    The issue is described in detail on the PHP forum at the following link:

    http://bugs.php.net/bug.php?id=45150

    Please note that -- from what I understand -- Windows XP does not have this problem, as it is configured only to IPv4. Vista runs into a problem because it is designed to handle both, as is Windows 7.

    Also, I should mention that using PHP 5.2 with the aforementioned book is not recommended because there is a bug in that version -- a veritable one -- that causes Apache to crash when it attempts to open the "deletejoke" file.


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
  •