...

View Full Version : Fatal error: Call to undefined function mysqli_connect()



et4891
03-24-2013, 06:41 AM
I installed mysql server 5.1 and no error happens during the installation so I assume everything is fine but when I'm learning and trying to use php and to connect through mysql and there is this error message saying


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


My codes are here


<?php

$db = mysqli_connect("localhost", "root", "3308") or die(mysqli_connect_error());

mysqli_select_db($db, "booksdb") or die(mysqli_error($db));

mysqli_query($db, "CREATE TABLE books(
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
title VARCHAR(64) NOT NULL)") or die(mysqli_error($db));

mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'the nose')") or die(mysqli_error());

mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'the overcoat')") or die(mysqli_error());

mysqli_query($db, "INSERT INTO books(id, title) VALUES(NULL, 'war and peace')") or die(mysqli_error());

$result = mysqli_query($db, "SELECT id, title FROM books") or die(mysqli_error());

while($record = mysqli_fetch_assoc($result)){
echo $record['id'];
echo " ";
echo $record['title'];
echo "<hr/>";
}
?>

in my php.ini file I did uncomment both


extension=php_mysql.dll
extension=php_mysqli.dll

and of course restarted apache. Also restarted the who machine too but that error message keeps on coming up and I have no idea how to fix it. I searched a few forums and they all asked to make sure the extension is uncommented which they are.

Old Pedant
03-24-2013, 07:58 AM
Well, not to ask a silly question, but how about trying to connect using the old mysql library, instead of mysqli??? If that doesn't work, either, than you have a flawed installation. Missing stuff. If that works, then you may still have a flawed installation, but at least you know it isn't because you forgot to uncomment the DLL.

et4891
03-24-2013, 09:25 PM
Well, not to ask a silly question, but how about trying to connect using the old mysql library, instead of mysqli??? If that doesn't work, either, than you have a flawed installation. Missing stuff. If that works, then you may still have a flawed installation, but at least you know it isn't because you forgot to uncomment the DLL.

how can I do that connecting using old mysql? Sorry I'm really new at this and I was taught using mysqli in the codes. Does that mean I should try typing mysql instead of mysqli?

Old Pedant
03-24-2013, 10:59 PM
http://www.php.net/manual/en/mysql.examples-basic.php

But you don't really want to use the older interface.

Just try to make a connection using mysql_connect(), to see if the interface is there at all.

Fou-Lu
03-25-2013, 06:52 PM
You're using a windows build of PHP with mysqli.
Make sure you follow this documentation exactly: http://www.php.net/manual/en/mysqli.installation.php
Also, check your httpd error logs. I'm willing to bet that its not finding libmysql.dll (which also assumes you are on < 5.3 PHP).

vincewicks
03-28-2013, 08:43 AM
create a php info file and check mysqli is included in your PHP installation. If it's not you'll have to recompile php with mysqli included (on Linux) or include the dll in php.ini (in Windows).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum