Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-13-2005, 12:03 PM problem with php
Junior Talker

Posts: 3
Trades: 0
i am having aan issue with php ...
I am not an beginer with website but im not experienced with php .

the url of the aforementioned script is http://www.simonhealy.co.uk/FLASH/index.php
here is the script :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<body>
<div style="height:50px;border:1px solid #000;margin-bottom:10px">

</div>

<div style="float:left;width:15%;border:1px solid #000">
<ul style="margin-left:10px;list-style-type:none">
<li><a href="index.php">Home</a></li>
<li><a href="index.php?page=about">About</a></li>
<li><a href="index.php?page=contact">Contact</a></li>
</ul>
</div>

<div style="float:right;width:80%;border:1px solid #000">
<div style="padding:4px">
<!-- content here -->
<?php

# default page
$default = 'home.php';

# set document root path
$base = $_SERVER['DOCUMENT_ROOT'];

# list of all site pages + the id they will be called by
$pages = array('about' => 'about.php','contact' => 'contact.php');

if(array_key_exists($_GET['page'], $pages))
{
foreach($pages as $pageid => $pagename) {
if($_GET['page'] == $pageid && file_exists($base.$pagename))
{
/* if somebody's making a request for ?page=xxx and
the page exists in the $pages array, we display it
checking first it also exists as a page on the server */
include $base.$pagename;
}
} // end foreach
}
else {
/* if the page isn't listed in $pages, or there's no ?page=xxx request
we show the default page, again we'll also just make sure it exists as a file
on the server */
if(file_exists($base.$default)) include $base.$default;
}

?>
</div>
</div>
</body>
</html>


now when i view it in the browser , it just shows the raw code as if it is not processing the script ... do you nned to set a specific file permission for php scripts ?
Darkstaruk is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-13-2005, 12:06 PM
leavethisplace's Avatar
Ultra Talker

Posts: 297
Trades: 0
It shows me simply a page with a few boxes and hyperlinks.

Are you sure PHP is installed on the server you're running the PHP file?
__________________
A lie gets halfway around the world before the truth has a chance to get its pants on. - Sir Winston Churchill

Please visit my sites:
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
leavethisplace is offline
Reply With Quote
View Public Profile
 
Old 04-13-2005, 12:08 PM
Junior Talker

Posts: 3
Trades: 0
yes i am totaly sure
i am paying for it

it is also suupposed to have ssi/cgi aswell
Darkstaruk is offline
Reply With Quote
View Public Profile
 
Old 04-13-2005, 12:12 PM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
You have missed out a couple of characters:

PHP Code:
 if(file_exists($base.$default)) include $base.$default
This should read:

PHP Code:
 if(file_exists($base.$default)) { include '$base.$default'; } 
Steve.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by Gaffer Sports; 04-13-2005 at 12:15 PM..
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Old 04-13-2005, 12:16 PM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
also

PHP Code:
 include $base.$pagename
Should be :

PHP Code:
 include '$base.$pagename'
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Old 04-13-2005, 12:17 PM
Junior Talker

Posts: 3
Trades: 0
i tried the code that you supplied but it didn`t work . I simply havent a clue what is wrong .
I have sent a e mail to my web space service provider i cant work it out .
Darkstaruk is offline
Reply With Quote
View Public Profile
 
Old 04-13-2005, 12:37 PM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Website</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<body>
<div style="height:50px;border:1px solid #000;margin-bottom:10px">

</div>

<div style="float:left;width:15%;border:1px solid #000">
<ul style="margin-left:10px;list-style-type:none">
<li><a href="index.php">Home</a></li>
<li><a href="index.php?page=about">About</a></li>
<li><a href="index.php?page=contact">Contact</a></li>
</ul>
</div>

<div style="float:right;width:80%;border:1px solid #000">
<div style="padding:4px">
<!-- content here -->
<?php

# default page
$default = 'default.php';

# set document root path
$base = $_SERVER[DOCUMENT_ROOT]."/";

# list of all site pages + the id they will be called by
$pages = array('about' => 'about.php','contact' => 'contact.php');

if(array_key_exists($_GET['page'], $pages))
{
foreach($pages as $pageid => $pagename) {
if($_GET['page'] == $pageid && file_exists($base.$pagename))
{
/* if somebody's making a request for ?page=xxx and
the page exists in the $pages array, we display it
checking first it also exists as a page on the server */
$filename = $base.$pagename;
include ($filename);
}
} // end foreach
}
else {
/* if the page isn't listed in $pages, or there's no ?page=xxx request
we show the default page, again we'll also just make sure it exists as a file
on the server */
$filename = $base.$default;
if(file_exists($filename)) { include ($filename); }
}

?>
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by Gaffer Sports; 04-13-2005 at 03:42 PM..
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Old 04-13-2005, 12:37 PM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
The above works for default, although as you are setting base to ROOT, you will need the default at root and not in the flash folder.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Old 04-13-2005, 12:53 PM
KML9870's Avatar
One Bad Mamma :-)

Posts: 5,489
Name: Kandi
Location: Western NY
Trades: 0
I am by no means an expert with php, but it looks to me like it is processing the code. Do you have an echo statement telling php what to output? It looks to me like that may be where the problem lies.
KML9870 is offline
Reply With Quote
View Public Profile
 
Old 04-13-2005, 02:06 PM
Novice Talker

Posts: 9
Trades: 0
This code is OK:
PHP Code:
if(file_exists($base.$default)) include $base.$default
Quote:
Originally Posted by Gaffer Sports
also

PHP Code:
 include $base.$pagename
Should be :

PHP Code:
 include '$base.$pagename'
Wouldn't that require double quotes? They're not necessary anyway. The code should be valid, but I prefer to parenthesise

PHP Code:
 include ($base.$pagename); 
If your code is being output to the browser, your host has server problems. Try this script:

PHP Code:
<?PHP
phpinfo 
();
?>
If this doesn't give you a page of PHP data, you need to talk to your host about PHP hosting. Maybe they require you to upload some .htaccess files.
MarkyH is offline
Reply With Quote
View Public Profile
 
Old 04-13-2005, 03:40 PM
Gaffer Sports's Avatar
Ultra Talker

Posts: 397
Name: Steve
Location: Scotland
Trades: 1
Quote:
Originally Posted by MarkyH
This code is OK:
PHP Code:
if(file_exists($base.$default)) include $base.$default


Wouldn't that require double quotes? They're not necessary anyway. The code should be valid, but I prefer to parenthesise

PHP Code:
 include ($base.$pagename); 
If your code is being output to the browser, your host has server problems. Try this script:

PHP Code:
<?PHP
phpinfo 
();
?>
If this doesn't give you a page of PHP data, you need to talk to your host about PHP hosting. Maybe they require you to upload some .htaccess files.


If you guys had tried the code on a test server you would have realised it was not working, rather than telling him to check his php info or server.

The code that I posted earlier worked fine for the default page, but I had not fixed his other bit for the different pages - something that I did mention and something I have now fixed.

Steve.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by Gaffer Sports; 04-13-2005 at 03:47 PM..
Gaffer Sports is offline
Reply With Quote
View Public Profile Visit Gaffer Sports's homepage!
 
Reply     « Reply to problem with php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39364 seconds with 12 queries