NixHex Posted October 4, 2010 Share Posted October 4, 2010 Hi, this is my first post but I hope it's fruitful. First, I am running PHP 5.1.6 on my VPS and I am trying to write a Leaderboard script for a game that takes place on my server. The game was not written by me and I know it works perfectly. I have also accessed the database through shell multiple times, so I know that works fine. Here is the code for my leaderboard script: <html> <title>Middle Cup Leaderboard</title> <body> <?php echo "about to connect\n"; $dbc = mysqli_connect ('localhost','root', 'password', 'shoddybattle') OR die ('sql error:' . mysqli_connect_error() ); echo "Debugging point: connected\n"; //$query = "SELECT estimate FROM users"; //$result = mysqli_query($dbc,$query) or die ('Could not retrieve ratings!'); //echo 'Debugging point: requested\n'; //mysqli_close($dbc); //echo 'Debugging Point: closed\n'; //echo 'Middle Cup Leaderboard Results\n'; //echo $result; ?> </body> </html> Here is the source code of the output when I navigate to it: <html> <title>Middle Cup Leaderboard</title> <body> about to connect As you can see, it looks as if the program stops indefinitely when I try to connect to the database. Does anyone know what could be wrong with this? Any help would be greatly appreciated! Quote Link to comment Share on other sites More sharing options...
objnoob Posted October 4, 2010 Share Posted October 4, 2010 try using ini_set('display_errors', '1'); at the top of your page, and try using echo function_exists('mysqli_connect'); before using mysqli_connect Quote Link to comment Share on other sites More sharing options...
NixHex Posted October 4, 2010 Author Share Posted October 4, 2010 Fatal error: Call to undefined function mysqli_connect() in /var/www/html/phpstuff/leaderboard/index.php on line 8 I don't know why I'm getting this. Mysql is installed and so is PHP. Any plausible explanation? Thanks for the quick reply! Quote Link to comment Share on other sites More sharing options...
objnoob Posted October 4, 2010 Share Posted October 4, 2010 There are 2 distinct modules/extensions for mysql One is mysql.[so|dll] and the other is mysqli.[so|dll] The latter stands for mysql improved, which allows for different mysql server default character sets, but not it's critical! If your runnings windows, check your drive:\PHP_Directory\ext\ folder. If you see php_mysqli.dll you're in good shape! You just need to enable this module by modifying your php.ini file... open php.ini and edit find ;extension=php_mysqli.dll... You should uncomment this line by removing the semi colon. If you cannot find this line in your php.ini file, add the line below to the end of the file! extension=php_mysqli.dll P.S. Don't forget to restart apache after modifying your php.ini file! Quote Link to comment Share on other sites More sharing options...
NixHex Posted October 4, 2010 Author Share Posted October 4, 2010 It's a remote server running CentOS, if that helps. I'll try to find the file you told me about. Quote Link to comment Share on other sites More sharing options...
objnoob Posted October 4, 2010 Share Posted October 4, 2010 In that case the file is called mysqli.so. If you dont have it you will need compile it using phpize or recompile your whole PHP install --with-mysqli! Quote Link to comment Share on other sites More sharing options...
NixHex Posted October 4, 2010 Author Share Posted October 4, 2010 I went into shell and ran a few commands [root@middlecup ~]# whereis php php: /usr/bin/php /etc/php.ini /etc/php.d /usr/lib/php /usr/share/man/man1/php.1.gz [root@middlecup ~]# whereis mysql. mysql: /usr/bin/mysql /usr/lib/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz [root@middlecup ~]# whereis mysqli mysqli: As for the php build; interestingly enough php was not included with my server package! I had a friend go in and install it. Also, I ran phpinfo() ... '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter' So, it looks like it was installed without mysqli. How would I go about getting that? Quote Link to comment Share on other sites More sharing options...
objnoob Posted October 4, 2010 Share Posted October 4, 2010 it depeneds on whether you wish to build your own PHP install or just build the extension. In any case you need to point to the mysql header libraries when building!! Quote Link to comment Share on other sites More sharing options...
gizmola Posted October 4, 2010 Share Posted October 4, 2010 Usually with a centos box a mysql and apache are installed using Yum. Yum wraps rpm and also handles dependencies. You can see for example what php packages are installed doing: rpm -qa | grep php The php-mysql package includes both mysql and mysqli so it sounds like you're using a compiled from source version, which is in my experience a lot of trouble that in most cases can be easily avoided by using yum instead. Quote Link to comment Share on other sites More sharing options...
NixHex Posted October 4, 2010 Author Share Posted October 4, 2010 I had a friend, who also installed the game server with YUM, install PHP, so I'm sure he used YUM for that too. I contacted him but he probably won't get back to me until tomorrow morning. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.