Jump to content

What to change to test PHP at home


jayson
 Share

Recommended Posts

I want ot make sure my php coding works before I upload it, this is what I have now:

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<META NAME="Generator" CONTENT="Stone's WebWriter 3.5">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title></title>

<link rel="stylesheet" type="text/css" media="screen" title="Defined Style" href="mnafra.css" />

<style>

html {height:100%;}

* html #wrap {height:100%}

</style>

 

</head>

 

<body>

 

<div id="wrap">

<div id="header">

 

<!-- Starting Header Include -->

<?php include $_SERVER['DOCUMENT_ROOT']."/inc/header.php"; ?>

<!-- Ending Header Include -->

</div>

 

<div id="menu">

<!-- Starting Menu Include -->

<?php include $_SERVER['DOCUMENT_ROOT']."/inc/menu.php"; ?>

<!-- Ending Menu Include -->

</div>

 

 

<div id="main">

Main text

</div>

 

 

<div id="clearfooter"></div>

 

<div id="footer">

<!-- Starting footer Include -->

<?php include $_SERVER['DOCUMENT_ROOT']."/inc/footer.php"; ?>

<!-- Ending footer Include -->

</div>

 

 

</div>

</div>

</body>

</html>

 

(I can not add color) (The color selector is not working)

I would like to know how to change this to make it work on my home computer, so I can try the PHP scripting before I publish it...

This is the coding I need help with

<?php include $_SERVER['DOCUMENT_ROOT']."/inc/header.php"; ?>

 

Thanks

Link to comment
Share on other sites

This is the coding I need help with

<?php include $_SERVER['DOCUMENT_ROOT']."/inc/header.php"; ?>

 

$_SERVER['DOCUMENT_ROOT'] just references your public_html (root of your web tree).

 

You can change it to be an absolute path for testing at home if you want:

<?php include "/whereveronyourharddrive/inc/header.php"; ?>

 

You still need php on your computer, obviously, to parse it though, since even the include file is in PHP.

Link to comment
Share on other sites

K, so I have downloaded Xampplite, and have it on my thumbdrive. When I type http://127.0.0.1 into my browser I get that working. I cant however seem to get the settings right for dreamweaver.

 

I assume once I get them right, I can preview the page, and it will use the test server.

These are the settings I have, But I have no idea if they are right

 

post-5391-1144194529_thumb.jpg

 

(a years collection of belly button lint to the person who is the most helpfull)

Link to comment
Share on other sites

Ok, I am going to be a complete idiot here, this program installs on MY computer to view PHP files and get them to work as if they were on a server...right?

Haven't used the apache2triad setup, but that's what it looks like. That's what I use xampp for anyway.

Link to comment
Share on other sites

Xampp installs in the root directory of a drive or USB Jump Drive.

I used the lite version for windows.

in the Xampp folder there batch files to start and stop Apache and MySql

I put shortcuts to them in the Quick Launch tray.

you put you files in \xampp/htdocs\folder_name\

 

you point your browser to

http://localhost to access Xampp control panel

or http://localhost/folder_name/ to see the site you are working on.

 

I have a favorite folder in my browser for Xampp

where I keep favorites for each folder I use.

 

Its easy to use an html editor to save updates then switch to the browser and refresh to see the changes.

Link to comment
Share on other sites

Jayson,

I was able to download it. Im not sure whats happening to make it stop @ 50% for you.

 

I do have another question for everyone though

 

I am able to put the files in the htdocs folder, and view them. My problem now, is that ll of my paths are relative to the root. When I look at them using Xampplite, it appears as though my relative paths are messed up.

 

Any ideas as to what I am doing wrong?

Link to comment
Share on other sites

The path to the image on the index page of my site is

/assets/jensen_family.jpg

When I look at it Via XAMPPLITE it doesnt show up.

I assume it is because it is looking for it in "xampplite/assets/" and not in "xampplite/jensenconnection/assets/"

Does that make sense?

 

I just tried making Xampplite the root to solve the problem and that didnt work either.

I got the following screen. (which should look like the homepage on my site)

 

post-5391-1144275061_thumb.jpg

It looks like I am partway there, just still having issues (my life story)

Link to comment
Share on other sites

htdocs is the root

so

/assets/jensen_family.jpg

is like htdocs/assets/jensen_family.jpg

do you have a folder assets below htdocs?

I didnt at first. THen after I tried that, the css and the photos worked, but the includes didnt.

 

If I have to use htdocs as the root, then I cant use it for multiple sites. Perhaps this isnt what Im looking for.

 

Don, You are a gentleman and a scholar. thanks for your help!

Link to comment
Share on other sites

ok, this is what I did/do

 

1] extract it to I:\xampplite

2] doubled clicked apache_start (not the black screen telling me that apache was starting)

3] I put the folder here {I:\xampplite\htdocs\php)

4] opened browser entered in {http:/localhost/php/

5] the browser opens, and I get a blank screen, and in the tab it says (GIF Image, 2x2 pixels)

 

Nothing else shows, what did I do wrong...B)

Thanks

Link to comment
Share on other sites

I happened to format my laptop the other day and I am in the process of reinstalling everything. I figured I'd write down the steps I took to install Xampp (not Xampp Lite) on WinXP SP2. Follow this step-by-step and it should work. If it would be useful to have screenshots of each step, I'm more than happy to do so.

 

Go:

 

1. Download the Xampp 1.5.1 for Windows installer (the 29MB exe, not the zip file) here.

2. Double click xampp-win32-1.5.1-installer.exe to start the installation process.

3. Choose English as my language.

4. Choose D:\ as my installation location (you can put it anywhere, including a USB drive or Program Files if you prefer). It will create a xampp folder in your specified location.

5. Watch it do it's thing.

6. Click Finish.

7. It asks if I would like to install Apache, MySQL, or FileZilla Server as services. I decline.

8. Congratulations, the install was successful. Start Xampp Control Panel Now? I say sure.

9. In the Xamp control panel, click the Start button next to Apache to start the Apache web server, and it starts. The control panel is also where you go to start MySQL, FileZilla Server, or Mercury. It is accessible from your Start Menu ((Start --> Programs --> apachefriends --> xampp --> control xampp server panel).

10. Open up my favorite web browser and go to http://localhost (or http://127.0.0.1). I am redirected to http://localhost/xampp/splash.php, which is a listing of languages. I click on English and am sent to /xampp/index.php, which has all kinds of info about my installation. From now on, http://127.0.0.1 redirects to /xampp/index.php. I like to leave this in place as it's a handy place to look at server status info, get to phpMyAdmin, read the instructions for switching from PHP 5 to 4, and other junk.

11. Copy my websites into the htdocs folder. For me, D:\xampp\htdocs\site1 and D:\xampp\htdocs\site2. In the Start Menu program group that is created during the installation there is a shortcut to the htdocs folder, just in case you can't find it.

12. I can now access my sites individually by navigating to http://127.0.0.1/site1 and http://127.0.0.1/site2. I can see images and CSS, and PHP includes work just fine. Just have to make sure relative paths are correct. Remember that your site is in a folder, not the root directory. If you only want to work on one site, remove the redirect to /xampp/index.php and dump your files directly into the htdocs folder.

13. When I'm done working, I click on the Xampp Control Center icon in my system tray to bring up the control panel. I click Stop next to Apache to stop the server, and I click Exit to exit the control panel. (Clicking the X just minimizes it to the system tray.)

 

That should do it.

Edited by timhodge
Link to comment
Share on other sites

10. Open up my favorite web browser and go to http://localhost (or http://127.0.0.1). I am redirected to http://localhost/xampp/splash.php, which is a listing of languages. I click on English and am sent to /xampp/index.php, which has all kinds of info about my installation. From now on, http://127.0.0.1 redirects to /xampp/index.php. I like to

 

Ok, I did all that, but I get this page:

 

http://www.anonymizer.com/consumer/product.../blockpage.html

 

I had spyblocker plus, but disabled it, and still will not work

Blocked URL: localhost

Blocked Resource: Default

 

This page has been blocked by SpyStopper Pro due to security

and Privacy concerns. Some Possible Reasons:

 

# Tracks or Profiles you.

# Gathers Private and Confidential Information from you.

# Installs software on your machine without your approval.

# Has Unsafe Content.

# No Content other than Advertisements and Popup windows.

 

If you are sure you want to visit this site, please click the link below:

http://localhost

 

NOTE: The above link will open site with a protected proxy. You

&nbspshould take due care regardless and open this link with caution.

 

 

but I will try to get it to work, maybe use IE and not firefox

ok, disabled spyblocker, and now I get this:

 

Unable to connect

 

Firefox can't establish a connection to the server at localhost.

 

* The site could be temporarily unavailable or too busy. Try again in a few

moments.

 

* If you are unable to load any pages, check your computer's network

connection.

 

* If your computer or network is protected by a firewall or proxy, make sure

that Firefox is permitted to access the Web.

 

Ok, got past that problem, winxp was waiting for me to ask if I wanted apache to block or unblock the apache program

Edited by jayson
Link to comment
Share on other sites

Ok, I posted this question ( it disapeared)and maybe I canceled the post..

 

I get this error, now...

 

Warning: include(I:/xampp/xampp/htdocs/inc/header.php) [function.include]: failed to open stream: No such file or directory in I:\xampp\xampp\htdocs\php\index.php on line 20

 

Warning: include() [function.include]: Failed opening 'I:/xampp/xampp/htdocs/inc/header.php' for inclusion (include_path='.;I:\xampp\xampp\php\pear\') in I:\xampp\xampp\htdocs\php\index.php on line 20

 

Warning: include(I:/xampp/xampp/htdocs/inc/menu.php) [function.include]: failed to open stream: No such file or directory in I:\xampp\xampp\htdocs\php\index.php on line 26

 

Warning: include() [function.include]: Failed opening 'I:/xampp/xampp/htdocs/inc/menu.php' for inclusion (include_path='.;I:\xampp\xampp\php\pear\') in I:\xampp\xampp\htdocs\php\index.php on line 26

 

Warning: include(I:/xampp/xampp/htdocs/inc/footer.php) [function.include]: failed to open stream: No such file or directory in I:\xampp\xampp\htdocs\php\index.php on line 86

 

Warning: include() [function.include]: Failed opening 'I:/xampp/xampp/htdocs/inc/footer.php' for inclusion (include_path='.;I:\xampp\xampp\php\pear\') in I:\xampp\xampp\htdocs\php\index.php on line 86

Link to comment
Share on other sites

Your index.php file is looking in /inc/, should it maybe be looking in /php/inc?

 

What is the trick.. I just noticed that it installed to:

 

I:/xampp/xampp

 

Is that right? Could that be the problem.

 

I 5 sites I have to work on and having the inc folders all in the same area is going to be a problem

:?:

Link to comment
Share on other sites

Everything is relative to htdocs, which is /.

 

If you have two sites, let's call them site1, site2, etc. They each live in their own folder: /site1/, /site2/, etc. Each site has an index.php: /site1/index.php, /site2/index.php, etc. Each index.php references the same include file, let's call it header.php, which lives in the includes folder /inc/.

 

You should be able to write the include in each index.php as:

><?php include("/inc/header.php"); ?>

This tells it to start at htdocs, or /, and work it's way up.

 

If each site was to have it's own include folder, such as: /site1/inc/, /site2/inc/, etc., then you could write the include as:

><?php include("inc/header.php"); ?>

This tells it to start in the folder that index.php is in (/site1/, /site2/, etc.) and work up from there.

 

You could also do:

><?php include("/site1/inc/header.php"); ?>

which tells it to start in htdocs, or /, and work its way up from there.

 

Maybe you should post the include line that is giving you problems, and we can compare that with your directory structure.

Link to comment
Share on other sites

this is the include for the header, all the includes are the same:

 

<div id="header">

<!-- Starting Header Include -->

<?php include $_SERVER['DOCUMENT_ROOT']."/inc/header.php"; ?>

<!-- Ending Header Include -->

</div>

Link to comment
Share on other sites

If I do that, and then I publish it back to the server, no I need to rewrite it as

 

<div id="header">

<!-- Starting Header Include -->

<?php include $_SERVER['DOCUMENT_ROOT']."/inc/header.php"; ?>

<!-- Ending Header Include -->

</div>

Link to comment
Share on other sites

If each site was to have it's own include folder, such as: /site1/inc/, /site2/inc/, etc., then you could write the include as:

CODE

 

<?php include("inc/header.php"); ?>

 

This tells it to start in the folder that index.php is in (/site1/, /site2/, etc.) and work up from there.

 

got it to work thins way, now will I have to add back the server.root, when I publish it.

Link to comment
Share on other sites

I've found that xampp did not like the $_SERVER['DOCUMENT_ROOT'] so I wrote my includes as Tim describes.

My site was using $_SERVER['DOCUMENT_ROOT'] for the includes. I have changed them to <?php include("/pool/top.php"); ?>, but no luck. I do get everything else working, just not the includes. I downloaded my .htaccess file and put it in the root as well. I assume that I need that to tell XAMPPLITE to parse my html as PHP.

Any Ideas as to what I am missing?

Link to comment
Share on other sites

Ok I have a question about paths. I am trying to expermint with a xoops cms site on my pc. Whic is this http://localhost/xoop/ Now my mainfile.php file which also acts as a config file wants the correct path. The path to my xoop folder is this C:\Program Files\xampp\htdocs\xoop which is not correct for my mainfile.php How would I format that into the correct path. Below is the part of the mainfile.php code i am talking about.

 

 

>// XOOPS Physical Path
// Physical path to your main XOOPS directory WITHOUT trailing slash
// Example: define('XOOPS_ROOT_PATH', '/C:\Program Files\xampp\htdocs\xoop');
define('XOOPS_ROOT_PATH', '/C:\Program Files\xampp\htdocs\xoop');

// XOOPS Virtual Path (URL)
// Virtual path to your main XOOPS directory WITHOUT trailing slash
// Example: define('XOOPS_URL', 'http://localhost/xoop');
define('XOOPS_URL', 'http://localhost/xoop');

Link to comment
Share on other sites

not sure this is what you mean, but I found that:

 

<?php include("inc/header.php"); ?>

 

That worked great

Yes, when your inc folder is a subfolder of site1, etc.

 

Did you try the /inc/header.php with the common inc folder? I'm confused as to why that won't work for you.

Link to comment
Share on other sites

Ok, I got one more question problem..

 

I have a site

 

www.domain.com/sitea

 

ok I got the inc in that folder, now can I have a inc in a second folder

 

www.domain.com/sitea/folder2

 

does that make sense?

Link to comment
Share on other sites

ok, I had to shut my computer down, but now when I try to access the site, from localhost, it will not load, and when I try to click on start next to apache, I get below:

busy

apache started, but as before, the Admin button does not become available....Can someone tell me what is wrong?

 

One other thing, it does not tell me that Apache is running, "running" flashes on, then goes away

Edited by jayson
Link to comment
Share on other sites

Which part of that is the error message? Just "Busy"?

 

Did you install Apache as a service? If you did, you could try stopping/starting the service with the Windows service manager.

 

Does xampp start up with Windows? If so, try disabling that and starting it up yourself after Windows loads.

Link to comment
Share on other sites

It worked wonderful till last night when I shut the computer down. Everything was running good, I could enter in localhost\folder, and had no problem, now I can not get the apache server to start, and yes the busy is the error

 

thnaks Ti,.

 

PS the setup guide that you posted is the one I used.

 

Thanks

Link to comment
Share on other sites

NEVER MIND...it was my Spystopper pro, I trink I need to stop it, now it is working.. Got to figure out a way to allow SSP to except my Apache program

This is an important note that should probably be added to the install instructions.

 

Your firewall/security/spyware programs might take issue with you running a web server on your machine and they should be configured accordingly. If your firewall doesn't take issue with it, you should probably get something else.

Link to comment
Share on other sites

If you have XP with service pack 2, goto start >control panel >security. At the bottom should mention something about your firewall. If you don't have it or its not reconsing the firewall, find the third party firewall program, and open it up, its probably running already

 

JimE

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...