Local server is displaying index.php text

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Local server is displaying index.php text

Postby gary hawkins » 16. October 2012 15:25

Hi all.

I have been trying to get my website, which runs fine on my hosts server, to run on my local server for updating.

It has taken me weeks and i am now at a point where i have to ask for help!

So, I copied my htdocs using filezilla. Installed Xampp. I used mysqlog to make a copy of my datbase which is set to localhost and appears in myphpadmin. I have apache running and tested PHP pages work.

In my config.db page I changed it to connect to my local Mysql database. I tested that page and it connected to server.

I can acces my htdocs but it shows them as a folder, when I click on the folder it reads the index.php page but just displays whats on it underneath the mysql connect. which is this

\n"; //breadcrumbs if ($page != 'home'){ $breadcrumbs = getBreadcrumbs($db, $page); echo "
"; echo stripslashes($breadcrumbs); echo '
'; } //include content if (file_exists("content/$page.inc")){ include ("content/$page.inc"); } else { include ("content/error.inc"); } echo "\n"; include ('includes/footer.inc'); //pages with redirects cannot have header included at beginning } else { if (file_exists("content/$page.inc")){ include ("content/$page.inc"); } else { include ("content/error.inc"); } include ('includes/footer.inc'); } ?>


If I open any other pages they do not full load, no images, products or basically anything thats in my database. Its all in my datbase though as I have checked the local one.

I would be so gratefull of some help.

Thanks in advance :?
Last edited by gary hawkins on 16. October 2012 20:16, edited 1 time in total.
gary hawkins
 
Posts: 9
Joined: 16. October 2012 15:12
XAMPP Version: 5.6.3
Operating System: windows

Re: Please help me!

Postby Altrea » 16. October 2012 17:27

Hi gary hawkins,

first: do you think, you have choosen a self speaking headline for your thread?
What should someone expect if he/she reads that headline?
99% of the threads here are requests for help. That is an unneeded information and don't tell anything about that, what you are reporting here.

gary hawkins wrote:I can acces my htdocs but it shows them as a folder

HOW do you access your htdocs? What does your browsers address bar show if you are in your htdocs?

And my second guess is: Do you use short_open_tag to begin your php files?

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6829
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Please help me!

Postby gary hawkins » 16. October 2012 17:42

My apologies for the headline and thank you for pointing that out.

I access the htodocs through localhost/htdocssolo That is the folder i put in Xampp/htdocs


And my second guess is: Do you use short_open_tag to begin your php files?
Sorry I dont know what that means
gary hawkins
 
Posts: 9
Joined: 16. October 2012 15:12
XAMPP Version: 5.6.3
Operating System: windows

Re: Please help me!

Postby Altrea » 16. October 2012 17:51

gary hawkins wrote:
And my second guess is: Do you use short_open_tag to begin your php files?
Sorry I dont know what that means

Thats okay, but google knows:
http://www.php.net/manual/en/ini.core.p ... t-open-tag
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6829
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Please help me!

Postby JonB » 16. October 2012 17:57

Altrea is referring to the great PHP debate - To Short Open Tag or not, that is the question...

Google "short open tag php' and you will see its a hot topic.

GENERALLY its now considered better practice to not use Short Open Tags.
meaning no constructs like this:
<?
.... code
?>

Its a parameter in php.ini

short_open_tag = Off

If it is set to Off, then code that is delimited by the 'old' short open tags, will not be interpreted by the PHP handler...

http://perishablepress.com/php-short-open-tag/

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
XAMPP Version: 1.8.3-2
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Please help me!

Postby gary hawkins » 16. October 2012 18:19

That makes so much sense. The whole site is using <? ?>. When I added <?php to a page earlier it worked differently.

So now all I need to do is update the php.ini file.

Thanks guys. I will let you know how I get on.
gary hawkins
 
Posts: 9
Joined: 16. October 2012 15:12
XAMPP Version: 5.6.3
Operating System: windows

Re: Please help me!

Postby Altrea » 16. October 2012 18:24

gary hawkins wrote:So now all I need to do is update the php.ini file.

Or change your open tags to the much cleaner, self speaking, configuration independend version <?php, which is just a one time effort for you.

P.S.:
JonB wrote:Altrea is referring to the great PHP debate - To Short Open Tag or not, that is the question...

Well, since <?= is no longer effected by the short_open_tag setting (which is in heavy use by CMS for templating and views), i don't think it is a big discussion any more.
But before PHP 5.4 it was something like religious flamewar ^^
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6829
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Please help me!

Postby gary hawkins » 16. October 2012 20:09

Ok so I have gone through the php.ini and turned short_open_tag on. I still get the directory and the index page is displaying text.

There are to many pages to add <?php into and some I tried like mod.functions.inc stopped anything displaying. I have pasted my db connect file and index, I am sure there is something wrong in them. Please could you take a look.

<?php
//DB details


define ("DB_TYPE", "mysql");
define ("DB_HOST", "localhost");
define ("DB_USERNAME", "root");
define ("DB_PASSWORD", "test123");
define ("DB_DATABASE", "solotest");

?>

index page

<?php


session_start();

error_reporting(0);

include ("system/config.db.inc");
include ("system/adodb5/adodb.inc");
include ("system/mod.functions.inc");

// create DB connection
$db = &ADONewConnection(DB_TYPE);
$db ->NConnect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE);

//$db_type = "mysql";
//$db_host = "localhost";
//$db_username = "root";
//$db_password = "test123";
//$db_database = "solotest";

//@mysql_connect ("$db_host","$db_username","$db_password","$db_database") or die ("Could not connect to mysql");
//@mysql_select_db ("$db_database") or die ("No Database");

//get page to include
if (isset($_GET['p'])){
$page = $_GET['p'];
} else {
$page = 'home';
}

//check to ensure user is logged in to gain access to following pages.
if (($page == 'member_area')||($page == 'edit_registered')||($page == 'change_password')||($page == 'stack_admin')||($page == 'custom_stack')){

if (!isset($_SESSION['customer_id'])){
//if not logged in do not allow access this page
//echo 'Not logged in';
header("location: ?p=no_access&pageFrom=$page");
}
}


//include header etc. for pages that have no redirects
if (($page != 'login')&&($page != 'register')&&($page != 'edit_registered')&&($page != 'change_password')&&($page != 'checkout')&&($page != 'custom_stack')){
include ('includes/header.inc');
echo "<div id=\"main\">\n";

//breadcrumbs
if ($page != 'home'){
$breadcrumbs = getBreadcrumbs($db, $page);
echo "<div class=\"breadcrumbs\">";
echo stripslashes($breadcrumbs);
echo '</div>';
}

//include content
if (file_exists("content/$page.inc")){
include ("content/$page.inc");
} else {
include ("content/error.inc");
}

echo "</div>\n";
include ('includes/footer.inc');

//pages with redirects cannot have header included at beginning
} else {

if (file_exists("content/$page.inc")){
include ("content/$page.inc");
} else {
include ("content/error.inc");
}
include ('includes/footer.inc');
}

?>
gary hawkins
 
Posts: 9
Joined: 16. October 2012 15:12
XAMPP Version: 5.6.3
Operating System: windows

Re: Local server is displaying index.php text

Postby Altrea » 16. October 2012 21:18

The first thing to debug is always display the messages.

So you should change
Code: Select all
error_reporting(0);


to
Code: Select all
error_reporting(-1);
ini_set('display_errors' , 1);


You are using AdoDB. Do you have checked if this module version is compatible with PHP 5.4?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6829
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Local server is displaying index.php text

Postby gary hawkins » 16. October 2012 21:46

Thank you for your time on this Altrea.

How would I find out what AdoDb version I am using?
gary hawkins
 
Posts: 9
Joined: 16. October 2012 15:12
XAMPP Version: 5.6.3
Operating System: windows

Re: Local server is displaying index.php text

Postby Altrea » 16. October 2012 22:01

gary hawkins wrote:How would I find out what AdoDb version I am using?

Take a look into your adodb5 folder. There should be a docs folder with documentations. They should have the version number on the top of the page.

btw: are you shure adodb.inc is the correct and full filename?
In the current package the file has a .php extension at the end.
But if this is an issue you should get php messages after enabling them.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6829
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Local server is displaying index.php text

Postby gary hawkins » 16. October 2012 23:52

Excellent work! Error report showed this

Warning: include(system/adodb5/adodb.inc): failed to open stream: No such file or directory in C:\xampp\htdocs\htdocssolo\htdocs\index.php on line 20

Warning: include(): Failed opening 'system/adodb5/adodb.inc' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\htdocssolo\htdocs\index.php on line 20

Now I am sorry my friend but this still leaves me clueless. I have found the xampp\php\pear file but what should I do with it?
gary hawkins
 
Posts: 9
Joined: 16. October 2012 15:12
XAMPP Version: 5.6.3
Operating System: windows

Re: Local server is displaying index.php text

Postby Altrea » 17. October 2012 05:24

gary hawkins wrote:Now I am sorry my friend but this still leaves me clueless. I have found the xampp\php\pear file but what should I do with it?

Nothing, that information is just giving to you, because the PEAR directory is in the php include path.

by far more important is the first message:
Warning: include(system/adodb5/adodb.inc): failed to open stream: No such file or directory in C:\xampp\htdocs\htdocssolo\htdocs\index.php on line 20

Take a look into your system/adodb5/ folder and search for the correct filename. If i should guess it will be adodb.inc.php.
Your include() command needs to be corrected, thats for true.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6829
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Local server is displaying index.php text

Postby gary hawkins » 17. October 2012 12:55

Good afternoon

Today I have made progress. i have manged to get my website running but still with errors. I put <?php everywhere I could find it to get it running to a point but it still dosnt find my products. The errors are saying these two line are wrong

elseif($_GET['p']=='product_details' && isset($_GET['prod_id']) ){
$prod_details = getProduct($db, $_GET['prod_id']);
$title=$prod_details[1];

elseif($_GET['p']=='stack_details' && isset($_GET['stack_id']) ){
$stack_details = getStack($db, $_GET['stack_id']);
$title=$stack_details[0];
}

To make sure I hadnt missed any short open tags I put in a php_flag short_open_tag on into my htaccess file and now I get this error

Parse error: syntax error, unexpected '=' on several lines and no website displayed. Is there something in php.ini I need to change?

The confusing thing is my website runs like a dream on the hosts server. I am having to change a lot to get it working locally?
gary hawkins
 
Posts: 9
Joined: 16. October 2012 15:12
XAMPP Version: 5.6.3
Operating System: windows

Re: Local server is displaying index.php text

Postby Altrea » 17. October 2012 15:23

gary hawkins wrote:now I get this error

Parse error: syntax error, unexpected '=' on several lines and no website displayed.

I can't say anything about that without knowing the full exact error message(s) and knowing your script (at least the full if() elseif control block).

gary hawkins wrote:Is there something in php.ini I need to change?

No. Parse error is parse error.

gary hawkins wrote:I am having to change a lot to get it working locally?

Maybe. That all depends of the apache/php/mysql/os version your live server is using and how different they are compared to your local stack and how different the components are configurated.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6829
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 50 guests