Re: How do you stop errors of invalid .inc files?
Posted: Wed Apr 25, 2012 11:13 am
Ok - I should be trying this out tomorrow so will update this page when testing done.
Thanks everyone.
Thanks everyone.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
header(Location: '/book' );Code: Select all
header('Location: /book');That was a function I used as an example. You need to implement it (whether you store it in a DB, or write it to file, or just do nothing, its up to you). For now you can just write a function with empty body so the error won't show up.simonmlewis wrote:[text]Fatal error: Call to undefined function processBook() in C:\xampp\phpMyAdmin\site\index.php on line 86[/text]
I'm now getting this error.
Code: Select all
function processBook() {
//TODO need to implement this function
}
Can you send me the source code you have so far?simonmlewis wrote:Whether I put that 'function' outside <?php or inside it, I still get the same undefined function error.
Code: Select all
<?php
function processBook() {
//TODO need to implement this function
}
if ($_GET['page'] == 'book') {
if (!empty($_POST)) {
$errorCode = processBook();
if ($errorCode == 0) {
header('Location: /book' );
} else {
header('Location: /book'); //or if showing errors in form header(Location: "/book?errorCode=$errorCode");
}
} else {
//show form html for '/book' request
//(and error message if passing the error code)
}
}And line 103 in book.inc is? Line 60 in index.php? Also, return something from "processBook()" function:simonmlewis wrote:I originally had this in the index.php file, but it is now in book.inc.Code: Select all
<?php function processBook() { //TODO need to implement this function } if ($_GET['page'] == 'book') { if (!empty($_POST)) { $errorCode = processBook(); if ($errorCode == 0) { header('Location: /book' ); } else { header('Location: /book'); //or if showing errors in form header(Location: "/book?errorCode=$errorCode"); } } else { //show form html for '/book' request //(and error message if passing the error code) } }
I now get:
[text]Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\phpMyAdmin\site\index.php:60) in C:\xampp\phpMyAdmin\site\includes\book.inc on line 103[/text]
Code: Select all
function processBook() {
//TODO need to implement this function
$errorCode = 0;
return $errorCode;
}