Server warning

Hello. I’m a newbie into the PHP/MYSQL web coding, using the very excellent sitepoint book that teaches designing a database driven web site using php/mysql. There are these warning messages that are displayed on the page at the level of connecting to the MYSQL database engine and the other is a header function warning which does not automatically show the updated page. But when I close the browser and re-lunch the addjoke url, what I will see is a series of the same joke added depending on the number of times the page was refreshed.Beneath are the two warning messages. I will greatly appreciate your assistance.

Warning: mysqli_connect() [function.mysqli-connect]: Headers and client library minor version mismatch. Headers:50051 Library:50153 in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\addjoke\index.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\addjoke\index.php:25) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\addjoke\index.php on line 60

bernym,

Welcome to SitePoint’s Apache forum!

Please show both line 25 (and the line before) and line 60 (and the line before).

I suspect that it’s a mismatch in the version (big surprise!) of (a) your PHP, (b) your MySQL (with your database) or with enabling the mysqli in php.ini but more information is required.

Regards,

DK

Hi I wish to say thanks a lot for your assistance. Here is an except of the code from line 19 to 61.

if (isset($_GET[‘addjoke’]))
{
include ‘form.html.php’;
exit();
}

$link = mysqli_connect(‘localhost’, ‘root’, ‘ndah3mneung’);
if (!$link)
{
$error = ‘Unable to connect to the database server.’;
include ‘error.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’))
{
$error = ‘Unable to locate the joke database.’;
include ‘error.html.php’;
exit();
}

if (isset($_POST[‘joketext’]))
{
$joketext = mysqli_real_escape_string($link, $_POST[‘joketext’]);
$sql = ‘INSERT INTO joke SET
joketext="’ . $joketext . ‘",
jokedate=CURDATE()’;
if (!mysqli_query($link, $sql))
{
$error = 'Error adding submitted joke: ’ . mysqli_error($link);
include ‘error.html.php’;
exit();
}

header('Location: .');
exit();

bernym,

If you had output ANYTHING (including a blank line before <?php), you will ALWAYS get the ‘headers already output’ message. If you will show your entire code, we can point it out to you - or I can move you to the PHP board, if you prefer.

I’m not thrilled with your “handler” scripts but the only thing that I saw that looked like an error to me is the header(‘Location: .’); statement. To me (in other words, I may be wrong), you need to provide a location for the Location to redirect to (if the headers had not been sent).

Regards,

DK

The 2nd block of errors appears to be generated because of the mysql connection error - in this case, have you recently updated your server?

It looks like mysql has been upgraded but PHP has been left behind, so they are running different library versions.

First off, if you’ve updated Apache / mysql / php I would make sure you restart the relevant services (all of them?).

Check the versions of any copy of libmysql.dll you may have - its possible PHP is not using the same one as MySQL.