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
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.
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();
}
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).