I am using Php 4.3.4 now, and some parts of my code can't work.
I used Php 4.0.5 before and this code worked fine.
Now: (WinXP, Apache 1.3.6, Php 4.3.4, register_globals=off)
Please, I need answer for this example (page name one.php):
<?php
if ($page=="two")
{ include ("two.php"); }
else if ($page=="three")
{ include ("three.php"); }
else if ($page=="four")
{ include ("four.php"); }
else
{
?>
<a href="one.php?page=two>Page two</a>
<a href="one.php?page=three>Page three</a>
<a href="one.php?page=four>Page four</a>
<?php
}
?>
When I click on some links, I always get one.php page with lots of errors like: Undefined variable, Undefined index...
I tried to use $_GET, but something is wrong again.
HOW can I make this code to work with Php 4.3.4?
Problems with new PHP version
Moderator: General Moderators
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
Hi
short version
empty() will not return a error if the $var is not defined, isset() will...
$default equals the value of $page, only if $_GET['page'] is not defined or if the $_GET['page'] value does not fall in the (min = 2, max = 4) number that you wish to use for your include();!
[syntax=php]<?
$default = 1;
$page = ( !empty( $_GET['page'] ) && ( $_GET['page'] >= 2 && $_GET['page'] <= 4 ) ) ? $_GET['page'] : $default ;
include( $page . '.php' );
?>[/syntax]
F!
short version
empty() will not return a error if the $var is not defined, isset() will...
$default equals the value of $page, only if $_GET['page'] is not defined or if the $_GET['page'] value does not fall in the (min = 2, max = 4) number that you wish to use for your include();!
[syntax=php]<?
$default = 1;
$page = ( !empty( $_GET['page'] ) && ( $_GET['page'] >= 2 && $_GET['page'] <= 4 ) ) ? $_GET['page'] : $default ;
include( $page . '.php' );
?>[/syntax]
F!
-
AnonymousPHP
- Forum Newbie
- Posts: 1
- Joined: Mon Jan 19, 2004 1:47 am
Your error reporting level is set too high in the IIS+PHP configuration.
There is nothing wrong with the code.
Checking is a variable is set is one way to go. You can assign a default value like in Fataqui example.
There is another way using error_reporting() function. You can find out more in PHP manual.
If you include in your code one line at the beginning of the script:
error_reporting(7);
all your problems will be solved. (i think so
).
This will only show E_ERROR | E_WARNING | E_PARSE.
I hope it will help you.
Bye bye
There is nothing wrong with the code.
Checking is a variable is set is one way to go. You can assign a default value like in Fataqui example.
There is another way using error_reporting() function. You can find out more in PHP manual.
If you include in your code one line at the beginning of the script:
error_reporting(7);
all your problems will be solved. (i think so
This will only show E_ERROR | E_WARNING | E_PARSE.
I hope it will help you.
Bye bye