Jump to content

Fatal error: Call to undefined function mysqli_connect()


et4891

Recommended Posts

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 by et4891
Link to comment
Share on other sites

  • 2 years later...

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 by Grumps
Link to comment
Share on other sites

  • 4 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.