Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysqli_Query problem

Status
Not open for further replies.

alohaaaron

Programmer
Mar 27, 2008
80
US
Hi, I have PHP 5.2.0 running on IIS, ISAPI installation. I cannot get any MYSQLI_Connect or MYSQLI queries to work properly. When I run phpinfo() there is no listing for MYSQLI.

I have checked that the libmysql.dll is present and the php_mysqli.dll is in the extension directory.

I have also checked that the PHP directory is in the PATH of the computer and checked to see that the correct php.ini file is being used.

Regular MYSQL queries work fine but I need MYSQLI queries to work. Thanks!
 
My PHP.ini file settings are here: I have set the username, host and password in the mysqli_connect() function.

[MySQLi]

mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
 
How are they not working? Do you get an error?




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
No errors at all, I get a completely blank screen when I try to test the connection.

$cnx = mysqli_connect($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");

if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
 
From your code that would be correct. As you are only actually outputting anything if there was an error.

Perhaps adding an else statement when it was successful may prove more fruitful.

Code:
$cnx = mysqli_connect($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
} 
[red]
else{
echo "Connection Successful";
}
[/red]





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks but yeah, I had a bunch of code that should have executed if it were true and none of it did. I also tried the else statement and it is still a blank screen.

Basically any statement after the mysqli_connect does not execute. If I put a simple echo "test"; before the mysqli_connect it does output correctly.

echo "test"; //works fine

$cnx = mysqli_connect($hostname,$username,$password) or DIE("DATABASE FAILED TO RESPOND.");

echo "success"; //not displayed
 
make sure that display_errors and display_startup_errors are turned on and that error_reporting is set to E_ALL. this will provide valuable debugging information.

have you added mysqli to the list of extensions? in php.ini?
and is the extension_dir directive properly set?

is libmysql.dll in the system path? if not, add the relevant directory to your path (instructions here

i would rather see you expressly testing $cnx too
Code:
if ([red]!$cnx[/red]) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top