I’m getting this error, I’m on page 120 of Chap 4:
Fatal error: Call to undefined function mysqli_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2
I can sign in MySQL console with my password so I know I typed in the right password. I checked C:\download\Wampserver\php\php.ini to ensure mysqli_connect was not commented out. Can anyone tell me what I’m doing wrong? Below is the output for: <?php phpinfo(); ?>
PHP Version 5.2.12
System Windows NT CDLW079 5.1 build 2600
Build Date Dec 16 2009 17:01:16
Configure Command cscript /nologo configure.js “–enable-snapshot-build” “–enable-debug-pack” “–with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\ emplate” “–with-php-build=d:\php-sdk\snap_5_2\vc6\x86\php_build” “–with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared” “–with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared” “–without-pi3web”
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File C:\download\Wampserver\php\php.ini
Scan this dir for additional .ini files (none)
additional .ini files parsed (none)
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, data, http, ftp, compress.zlib
Registered Stream Socket Transports tcp, udp
Registered Stream Filters convert.iconv., string.rot13, string.toupper, string.tolower, string.strip_tags, convert., consumed, zlib.*
Hi, I am have the same issue as the original poster, but none of the suggestions has resolved the issue.
I recently purchased the book Build Your Own Database Driven Web Site Using PHP & MySQL and have become stuck with the error: Call to undefined function mysqli_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\connect\index.php on line 2
I am running Windows Vista x64 w/ Apache 2.2.14 and PHP 5.2.13 and MySQL 5.1.44.
Here are my checks:
MySQL process is running in Win
Apache is running with PHP
php.ini is correct in phpinfo()
php.ini => extension=php_mysqli.dll has no (;) preceeding it
php.ini => extension_dir = “C:\PHP\ext” is pointing correctly
Here is the code being executed:
[COLOR=“Red”]<?php
$link = mysqli_connect(‘localhost’, ‘root’, ‘nathaniel’);
if (!$link)
{
$output = ‘Unable to connect to the database server.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_set_charset($link, ‘utf-8’))
{
$output = ‘Unable to set database connection encoding.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_select_db($link, ‘ijdb’))
{
$output = ‘Unable to locate the joke database.’;
include ‘output.html.php’;
exit();
}
$output = 'Database connection established.';
include 'output.html.php';
?>
[/COLOR]
I may try to continue with book using my remote host, but what will I have learned?
Which version of php did you install? There is a note about the versions on the corrections and typos page for the book:
Although this book provides download and installation instructions for PHP 5.2, the newly-released (at the time of this writing) PHP 5.3 includes some new download options that aren’t covered in the book.
There are four different versions of PHP 5.3. for Windows: VC6 Non Thread Safe, VC6 Thread Safe, VC9 Non Thread Safe, and VC9 Thread Safe. Talk about confusing!
First of all, you definitely want a Thread Safe version of PHP. The Non Thread Safe versions are not suitable for use as a plugin for Apache.
Secondly, assuming you will install (or have already installed) a version of the Apache HTTP Server from httpd.apache.org (see page 13), you will need the VC6 version of PHP.
In short, to follow the instructions in this book, you need the VC6 Thread Safe version of PHP 5.3 for Windows.
Hi there!
i’m stuck on the same page, same code, exept for this:
dreamweaver doesn’t recognize mysqli_set_charset, nor does my browser, it gives me this error:
Notice: Undefined variable: output in C:\wamp\www\connect\output.html.php on line 9
now this is my code…
for index.php
<?php
$link = mysqli_connect(‘localhost’, ‘root’, ‘mischa1938’);
if (!$link)
{
$output = ‘Unable to connect to the database server, please try again later.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_set_charset($link, ‘utf8’))
{
$output = ‘Unable to set database connection encoding.’;
include ‘output.html.php’;
exit();
}
if (!mysqli_select_db($link, ‘ijdb’))
{
$output = ‘Unable to locate the jokes database.’;
include ‘output.html.php’;
exit();
}
$outpu = ‘Database conection established.’;
include ‘output.html.php’;
?>
winxp pro / apache 2.2.14 / php 5.2.12 / mysql 5.1.43
anyone figure this one out?
I never figured it out. I updated to the thread safe version of PHP 5.3 and triple checked everything and still no go. I installed Wampserver 2.0 inplace of the individual parts and so far smooth sailing.
idk what the problem was but i fixed it. i updated to php 5.3.2 VC6 (thread safe) and mysql 5.1.44. i also changed my pw for mysql, had some #@ symbols, but i dont think that did anything. but it works now!