Forum Moderators: coopster
But I am getting this error when I click on links
5
6
7
in the red.html page
--------------------
i am posting the full red.php script. Please help me debug this or please if you can, do it for me(post reply).
<?php
/*
?id=any number
*/
/* url to be displayed */
$pages = array(
\'5\' => [\'http://www.nasa.gov\'],
\'6\'=> [\'http://www.example.com/home.css\'],
\'7\'=> [\'http://www.warnerbrothers.com\'],
);
//if the file exist, and is in the array it will display the url.
if(array_key_exists($_GET[\'id\'], $pages))
{
foreach($pages as $id => $name) {
if($_GET[\'id\'] == $id && file_exists($name)) {
include $name;
}
}
}
else {
//We will now display the home page, but if u enter the wrong id it will display this page.
include(\"http://www.example.com/index.html\");
}
?>
---------------------
[edited by: jatar_k at 3:50 pm (utc) on July 10, 2005]
[edit reason] removed urls [/edit]
No need for escaping all those apostrophes and also the last value in the array has no comma after it. Try:
$pages = array(
5 => 'http://www.nasa.gov',
6 => 'http://www.example.com/home.css',
7 => 'http://www.warnerbrothers.com'
);
dc
[edited by: jatar_k at 3:50 pm (utc) on July 10, 2005]
Thank you
RH
----------------------
<?php
/*
?id=any number
*/
/* url to be displayed */
$pages = array(
5 => 'http://www.nasa.gov',
6 => 'http://www.example.com/home.css',
7 => 'http://www.warnerbrothers.com',
);
//if the file exist, and is in the array it will display the url.
if(array_key_exists($_GET['id'], $pages))
{
foreach($pages as $id => $name) {
if($_GET['id'] == $id && file_exists($name)) {
include $name;
}
}
}
else {
//We will now display the home page, but if u enter the wrong id it will display this page.
include("http://www.example.com/index.html");
}
?>
[edited by: jatar_k at 3:50 pm (utc) on July 10, 2005]
Help me it's getting on my nerves as to why this prob. is recurring. Its not getting redirected.
Sincerely
RH
/* url to be displayed */
$pages = array(
5 => 'http://www.nasa.gov',
6 => 'http://www.example.com/home.css',
7 => 'http://www.warnerbrothers.com'
);
//if the file exist, and is in the array it will display the url.
if(array_key_exists($_GET['id'], $pages))
{
foreach($pages as $id => $name) {
if($_GET['id'] == $id && file_exists($name)) {
include $name;
}
}
}
else {
//We will now display the home page, but if u enter the wrong id it will display this page.
include("http://www.example.com/index.html");
}
?>
[edited by: jatar_k at 3:51 pm (utc) on July 10, 2005]
But after putting include($name); also it's still not redirecting. Please help me it's very urgent...
But thanks anyway....waiting
The first thing I would do is start exiting the script, line by line until I figured out how far it is getting before it fails or doesn't work the way I expect it too. Usually that is a logic statement, in this case more than likely your if statement. See if the id is in the $_GET superglobal array, and then take a closer look at that file_exists function return value.
jatar_k is correct here as well. If you truly want to redirect you should be using header [php.net], not include.
Thanks
RH
-------------------
<?php
/*
?id=any number
*/
/* url to be displayed */
$pages = array(
5 => 'http://www.nasa.gov',
6 => 'http://www.example.com/a2zdownload_home.css',
7 => 'http://www.warnerbrothers.com'
);
//if the file exist, and is in the array it will display the url.
if(array_key_exists($_GET['id'], $pages))
{
foreach($pages as $id => $name) {
if($_GET['id'] == $id && file_exists($id)) {
include($name);
}
}
}
else {
//We will now display the home page, but if u enter the wrong id it will display this page.
include("http://www.example.com/index.html");
}
?>
[edited by: jatar_k at 4:52 am (utc) on July 11, 2005]
[edit reason] no personal urls thanks [/edit]
Try something simple like this:
$id = $_GET['id'];
$pages = array(
5 => 'http://www.nasa.gov',
6 => 'http://www.example.com/a2zdownload_home.css',
7 => 'http://www.warnerbrothers.com'
);if ($id==5 ¦¦ $id==6 ¦¦ $id ==7)
{
header("Location: {$pages[$id]}");
}
else
{
header("Location: http://www.example.com/index.html");
}
That looks like all you need.
dc
Warning: Unexpected character in input: ' ' (ASCII=11) state=1 in /usr/www/virtual/kamranjilani123/www.example.com/red1.php on line 17
Warning: Unexpected character in input: ' ' (ASCII=11) state=1 in /usr/www/virtual/kamranjilani123/www.example.com/red1.php on line 17
Warning: Unexpected character in input: ' ' (ASCII=11) state=1 in /usr/www/virtual/kamranjilani123/www.example.com/red1.php on line 17
Parse error: parse error, unexpected T_STRING in /usr/www/virtual/kamranjilani123/www.example.com/red1.php on line 18
[edited by: jatar_k at 4:22 pm (utc) on July 11, 2005]
[edit reason] no personla urls thanks [/edit]
[edited by: jatar_k at 4:24 pm (utc) on July 11, 2005]
[edit reason] no personal urls thanks [/edit]
sincerely
RH
[edited by: jatar_k at 4:25 pm (utc) on July 11, 2005]
[edit reason] no personal urls thanks [/edit]