et4891 Posted March 24, 2013 Share Posted March 24, 2013 (edited) 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. Edited March 24, 2013 by et4891 Quote Link to comment Share on other sites More sharing options...
Grumps Posted April 10, 2015 Share Posted April 10, 2015 (edited) your error is line 3... <?php $db = mysqli_connect("localhost", "root", "3308") or die(mysqli_connect_error());mysqli_select_db($db, "booksdb") or die(mysqli_error($db)); line 3 is $db = mysqli_connect("localhost", "root", "3308") or die(mysqli_connect_error()); I have not used mysqli howerver it will be close to mysql which I am still learning. What I would try is combining the 2 lines above to this: $db = mysqli_connect("localhost", "booksdb", "TABLEname") or die(mysqli_connect_error()); Good luck Edited April 10, 2015 by Grumps Quote Link to comment Share on other sites More sharing options...
dalecosp Posted August 11, 2015 Share Posted August 11, 2015 Is the value of extension_dir set correctly? <?php phpinfo(); Load a page with the above code, look in it for the extension paths, and see if the files you need are actually in those folders. 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.