How do you stop errors of invalid .inc files?
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?
Ok - I should be trying this out tomorrow so will update this page when testing done.
Thanks everyone.
Thanks everyone.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
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?
[text]Parse error: syntax error, unexpected ':' in C:\xampp\phpMyAdmin\site\index.php on line 90[/text]
I've getting this error, based on
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.
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?
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?
[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.
I'm now getting this error.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
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?
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
}
-
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?
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.
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?
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.
-
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?
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]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
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?
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;
}