Jump to content

mysqli_connect stops program


NixHex

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/215100-mysqli_connect-stops-program/
Share on other sites

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!

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?

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.