How do you stop errors of invalid .inc files?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you stop errors of invalid .inc files?

Post by simonmlewis »

Ok - I should be trying this out tomorrow so will update this page when testing done.
Thanks everyone.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you stop errors of invalid .inc files?

Post by simonmlewis »

[text]Parse error: syntax error, unexpected ':' in C:\xampp\phpMyAdmin\site\index.php on line 90[/text]
I've getting this error, based on

Code: Select all

    header(Location: '/book' );
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
x_mutatis_mutandis_x
Forum Contributor
Posts: 160
Joined: Tue Apr 17, 2012 12:57 pm

Re: How do you stop errors of invalid .inc files?

Post by x_mutatis_mutandis_x »

That was my bad. "Location:" should be in quotes as well, sorry about that

Code: Select all

header('Location: /book');
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you stop errors of invalid .inc files?

Post by simonmlewis »

[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.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
x_mutatis_mutandis_x
Forum Contributor
Posts: 160
Joined: Tue Apr 17, 2012 12:57 pm

Re: How do you stop errors of invalid .inc files?

Post by x_mutatis_mutandis_x »

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.
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.

Code: Select all

function processBook() {
     //TODO need to implement this function
}
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you stop errors of invalid .inc files?

Post by simonmlewis »

Whether I put that 'function' outside <?php or inside it, I still get the same undefined function error.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
x_mutatis_mutandis_x
Forum Contributor
Posts: 160
Joined: Tue Apr 17, 2012 12:57 pm

Re: How do you stop errors of invalid .inc files?

Post by x_mutatis_mutandis_x »

simonmlewis wrote:Whether I put that 'function' outside <?php or inside it, I still get the same undefined function error.
Can you send me the source code you have so far?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: How do you stop errors of invalid .inc files?

Post by simonmlewis »

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 originally had this in the index.php file, but it is now in book.inc.

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]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
x_mutatis_mutandis_x
Forum Contributor
Posts: 160
Joined: Tue Apr 17, 2012 12:57 pm

Re: How do you stop errors of invalid .inc files?

Post by x_mutatis_mutandis_x »

simonmlewis wrote:

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 originally had this in the index.php file, but it is now in book.inc.

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]
And line 103 in book.inc is? Line 60 in index.php? Also, return something from "processBook()" function:

Code: Select all

function processBook() {
     //TODO need to implement this function
    $errorCode = 0;
    return $errorCode;
}
Post Reply