#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    8
    Rep Power
    0

    Mysql_connect failure


    Hi. Up until this point I have had mysql, php, and apache up and running just fine. Recently I made a little change. I configured Apache to read my .php pages from /home/user/code/php instead of /srv/http. It wasn't working originally so I created a new http user using this command:

    Code:
    useradd -d /srv/http -r -s /bin/false -U http
    And replaced /srv/http with the directory of my choice. Almost everything went fine. I was able to see all my .php files. The problem was with one file. This is the code for it:

    Code:
    <?php
    mysql_connect("localhost", "root", "mypass") or die(mysql_error());
    echo "Connected to MySQL<br />";
    ?>
    Originally it displayed everything fine but once I made the switch it displayed this error:

    Code:
     Fatal error: Call to undefined function mysql_connect() in /home/'user'/code/php/connect.php on line 2
    I tried to login to phpMyAdmin as well and this error is displayed:

    Code:
    The mysqli extension is missing. Please check your PHP configuration. <a href="Documentation.html#faqmysql" target="documentation"><img src="themes/dot.gif" title="Documentation" alt="Documentation" class="icon ic_b_help" /></a>
    Not sure if it matters but I have made the switch to a systemd only installation and have run systemctl enable httpd.service, systemctl enable mysqld.service, systemctl start httpd.service, and systemctl start mysql.service countless times just to be sure. I have also made sure that

    Code:
    extension=mysqli.so
    extension=mysql.so
    Are both uncommented in /etc/php/php.ini
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,993
    Rep Power
    9397
    Use phpinfo() to see which php.ini is being parsed. Also check error logs for messages from PHP - maybe about being unable to load extensions.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    8
    Rep Power
    0
    Originally Posted by requinix
    Use phpinfo() to see which php.ini is being parsed. Also check error logs for messages from PHP - maybe about being unable to load extensions.
    I'm sorry, I'm pretty new to LAMP. But here's what I'm thinking you want me to look at:

    (oops, didn't realize I couldn't do that)

    Anyway, It says that there are no additional .ini files parsed besides php.ini. There are no files in conf.d..
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,993
    Rep Power
    9397
    You can post URLs, just don't make them look like URLs

    What phpinfo() will tell you is the exact location of the php.ini it's using. That's where you need to make sure the extension= lines are.
    Also, with Apache you need to restart it when you make php.ini changes (or other significant changes). Settings won't take effect until you do.

    As for errors, check Apache's error log. And maybe some of the other /var/log files.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    8
    Rep Power
    0
    Originally Posted by requinix
    You can post URLs, just don't make them look like URLs

    What phpinfo() will tell you is the exact location of the php.ini it's using. That's where you need to make sure the extension= lines are.
    Also, with Apache you need to restart it when you make php.ini changes (or other significant changes). Settings won't take effect until you do.

    As for errors, check Apache's error log. And maybe some of the other /var/log files.
    Ah I see:

    ht tp://i.imgur.com/O1iKN.png

    I'm hoping that is the relevant part of phpinfo(). Also, I'm not sure if this is relevant but:

    Code:
    ; Directory in which the loadable extensions (modules) reside.
    ; http://php.net/extension-dir
    extension_dir = "/usr/lib/php/modules/"
    ; On windows:
    ; extension_dir = "ext"
  10. #6
  11. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,993
    Rep Power
    9397
    Then you're editing the right file. Make sure you're restarting Apache after you make php.ini changes and check its logs (/var/log/apache* probably) for errors.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    8
    Rep Power
    0
    Originally Posted by requinix
    Then you're editing the right file. Make sure you're restarting Apache after you make php.ini changes and check its logs (/var/log/apache* probably) for errors.
    I've restarted relentlessly...I will check phpinfo() more. It obviously has something to do with the fact that I temporarily changed the Document_root for user http.

    EDIT: I don't suppose I could do something so simple as reinstalling could I?

    UPDATE: Fixed the errors. It was a simple random syntax error in the /etc/php/php.ini file. Found it after running php -m. I can't believe I didn't try that sooner. *facepalm*

    The only trouble now is that I can't get php to display any errors. I definitely have it enable in /etc/php/php.ini:

    Code:
     error_reporting
       error_reporting E_ERROR  E_WARNING  E_PARSE
       Default Value: E_ALL E_NOTICE E_STRICT E_DEPRECATED
       Development Value: E_ALL
       Production Value: E_ALL E_DEPRECATED E_STRICT

IMN logo majestic logo threadwatch logo seochat tools logo