Jump to content

Recommended Posts

I'm working out of a book introducing PHP 5 and MySQL. I am doing a search that pulls from a MySQL database
but I'm getting this error:

Fatal error: Class 'mysqli' not found in /usr/local/www/apache22/data/PHP&MySQL/results.php on line 26

I added extension=mysqli.so to php.ini and restarted Apache, but still get the same error. Any ideas?

I'm using Apache 2.2.0, MySQL 5.0.18 and PHP 5.1.2 on a PC-BSD 1.1 machine. Thanks.
Link to comment
https://forums.phpfreaks.com/topic/11891-fatal-error-question/
Share on other sites

[!--quoteo(post=383350:date=Jun 13 2006, 05:48 PM:name=jefrat72)--][div class=\'quotetop\']QUOTE(jefrat72 @ Jun 13 2006, 05:48 PM) [snapback]383350[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I'm working out of a book introducing PHP 5 and MySQL. I am doing a search that pulls from a MySQL database
but I'm getting this error:

Fatal error: Class 'mysqli' not found in /usr/local/www/apache22/data/PHP&MySQL/results.php on line 26

I added extension=mysqli.so to php.ini and restarted Apache, but still get the same error. Any ideas?

I'm using Apache 2.2.0, MySQL 5.0.18 and PHP 5.1.2 on a PC-BSD 1.1 machine. Thanks.
[/quote]
Hi can we please have a look at your code

thanks.
Link to comment
https://forums.phpfreaks.com/topic/11891-fatal-error-question/#findComment-45107
Share on other sites

[!--quoteo(post=383354:date=Jun 13 2006, 12:51 PM:name=avo)--][div class=\'quotetop\']QUOTE(avo @ Jun 13 2006, 12:51 PM) [snapback]383354[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi can we please have a look at your code

thanks.
[/quote]


Sure, here it is

<html>
<head>
<title>Book-O-Rama Search Results</title>
</head>
<body>
<h1>Book-O-Rama Search Results</h1>
<?php
// create short variable names
$searchtype=$_POST['searchtype'];
$searchterm=$_POST['searchterm'];

$searchterm= trim($searchterm);

if (!$searchtype || !$searchterm)
{
echo 'You have not entered search details. Please go back and try again.';
exit;
}

if (!get_magic_quotes_gpc())
{
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
}

$db = new mysqli('PCBSD.localhost', 'bookorama', 'bookorama123', 'books');

if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}

$query = "select * from books where ".$searchtype." like '%".$searchterm."%'";
$result = $db->query($query);

$num_results = $result->num_rows;

echo '<p>Number of books found: '.$num_results.'</p>';

for ($i=0; $i <$num_results; $i++)
{
$row = $result->fetch_assoc();
echo '<p><strong>'.($i+1).'. Title: ';
echo htmlspecialchars(stripslashes($row['title']));
echo '</strong><br />Author: ';
echo stripslashes($row['author']);
echo '<br />ISBN: ';
echo stripslashes($row['isbn']);
echo '<br />Price: ';
echo stripslashes($row['price']);
echo '</p>';
}

$result->free();
$db->close();

?>
</body>
</html>
Link to comment
https://forums.phpfreaks.com/topic/11891-fatal-error-question/#findComment-45115
Share on other sites

[!--quoteo(post=383364:date=Jun 13 2006, 06:06 PM:name=jefrat72)--][div class=\'quotetop\']QUOTE(jefrat72 @ Jun 13 2006, 06:06 PM) [snapback]383364[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Sure, here it is

<html>
<head>
<title>Book-O-Rama Search Results</title>
</head>
<body>
<h1>Book-O-Rama Search Results</h1>
<?php
// create short variable names
$searchtype=$_POST['searchtype'];
$searchterm=$_POST['searchterm'];

$searchterm= trim($searchterm);

if (!$searchtype || !$searchterm)
{
echo 'You have not entered search details. Please go back and try again.';
exit;
}

if (!get_magic_quotes_gpc())
{
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
}

$db = new mysqli('PCBSD.localhost', 'bookorama', 'bookorama123', 'books');

if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}

$query = "select * from books where ".$searchtype." like '%".$searchterm."%'";
$result = $db->query($query);

$num_results = $result->num_rows;

echo '<p>Number of books found: '.$num_results.'</p>';

for ($i=0; $i <$num_results; $i++)
{
$row = $result->fetch_assoc();
echo '<p><strong>'.($i+1).'. Title: ';
echo htmlspecialchars(stripslashes($row['title']));
echo '</strong><br />Author: ';
echo stripslashes($row['author']);
echo '<br />ISBN: ';
echo stripslashes($row['isbn']);
echo '<br />Price: ';
echo stripslashes($row['price']);
echo '</p>';
}

$result->free();
$db->close();

?>
</body>
</html>
[/quote]

Hi Are you running the script on a windows server ?
or a linux server?

try changing line 26 to
$db = new mysql('PCBSD.localhost', 'bookorama', 'bookorama123', 'books');
let me know how you get on

cheers

also

check your php.ini file

does it look like this

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]extension=php_mbstring.dll
;extension=php_bz2.dll
;extension=php_cpdf.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll
extension=php_pdo.dll
extension=php_pdo_sqlite.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_sqlite.dll[/quote]
Link to comment
https://forums.phpfreaks.com/topic/11891-fatal-error-question/#findComment-45121
Share on other sites

Thanks for the help.

I'm running it on a linux server FreeBSD (actually UNIX)

I tried removing the "i" in mysqli and got the same errror, just about mysql instead of mysqli


My php.ini looks like this:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=msql.dll
;
; ... or under UNIX:
;
; extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here. Specify the location of the extension with the
; extension_dir directive above.

extension=mysqli.so

; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.

;extension=php_mbstring.dll
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_ifx.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_mysql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
Link to comment
https://forums.phpfreaks.com/topic/11891-fatal-error-question/#findComment-45129
Share on other sites

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.