jayson Posted April 4, 2006 Posted April 4, 2006 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 Quote
MikeJ Posted April 4, 2006 Posted April 4, 2006 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. Quote
TCH-Tim Posted April 4, 2006 Posted April 4, 2006 You might want to check out Xampp. It's got Apache, PHP, mySQL, etc. so you can test everything on your PC before you upload. And you won't have to mess with your include paths. Quote
kfordham281 Posted April 4, 2006 Posted April 4, 2006 You can also try this: http://apache2triad.net It's a full LAMP install with just a few clicks. Quote
wampthing Posted April 4, 2006 Posted April 4, 2006 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 (a years collection of belly button lint to the person who is the most helpfull) Quote
jayson Posted April 5, 2006 Author Posted April 5, 2006 You can also try this: http://apache2triad.net It's a full LAMP install with just a few clicks. 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? Quote
TCH-Tim Posted April 5, 2006 Posted April 5, 2006 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. Quote
jayson Posted April 5, 2006 Author Posted April 5, 2006 how techinal or hard or complicated is it to set up xampp? Quote
TCH-Bruce Posted April 5, 2006 Posted April 5, 2006 If you follow the instructions it's not difficult at all. Quote
wampthing Posted April 5, 2006 Posted April 5, 2006 Now dont make me feel stupid. While I do have it set up, I am still trying to figure out the settings so that I can actually use it. Am I missing something? Perhaps I should retract the years worth of bellybutton lint comment. Quote
TCH-Bruce Posted April 5, 2006 Posted April 5, 2006 Maybe we can get one of our members using it to write a short tutorial on how to install and use it. I haven't used it in over a year myself. Quote
TCH-Don Posted April 5, 2006 Posted April 5, 2006 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. Quote
jayson Posted April 5, 2006 Author Posted April 5, 2006 Well I am going to install it and see how bad I screw up my computer Quote
TCH-Tim Posted April 5, 2006 Posted April 5, 2006 Well I am going to install it and see how bad I screw up my computer It shouldn't screw up your computer. Uninstall is very clean. And like Don said, you could even run it off a USB drive if you wanted to. Quote
jayson Posted April 5, 2006 Author Posted April 5, 2006 2 part, problem 1] still can not get the BBcodes to work in FF 2] having problems downloading the xampp, it gets to 50/51 percent and then just stops...anyone else have this problem.... Quote
wampthing Posted April 5, 2006 Posted April 5, 2006 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? Quote
TCH-Don Posted April 5, 2006 Posted April 5, 2006 What version are you trying to download? I just downloaded the lite version, both the zip and exe with no problems. They are big 35 meg and 13 meg. Quote
TCH-Don Posted April 5, 2006 Posted April 5, 2006 Dave how are you using paths? or can you give an example. Quote
wampthing Posted April 5, 2006 Posted April 5, 2006 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) It looks like I am partway there, just still having issues (my life story) Quote
TCH-Don Posted April 5, 2006 Posted April 5, 2006 htdocs is the root so /assets/jensen_family.jpg is like htdocs/assets/jensen_family.jpg do you have a folder assets below htdocs? Quote
jayson Posted April 5, 2006 Author Posted April 5, 2006 Ojk, IO extracted the exe file, of xampp, I get this error: xampplite-win32-1.5.1 is not supported archive.. Should I go for the .zip xampplite-win32-1.5.1 Quote
jayson Posted April 5, 2006 Author Posted April 5, 2006 Ok, I downloaded the xampplite-win32-1.5.1.zip, got it installed, now comes the hard part, getting it to work for me. java script:emoticon(':(', 'smid_2') Quote
jayson Posted April 5, 2006 Author Posted April 5, 2006 ok, I admit it, I have no right doing this, I have no idea what to do or what I am doing, we need a simple tutorial Quote
wampthing Posted April 5, 2006 Posted April 5, 2006 htdocs is the rootso /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! Quote
jayson Posted April 5, 2006 Author Posted April 5, 2006 Ok, I gave up, do not know how to do this, so I will work with the script when it is on the server... Quote
JTD Posted April 6, 2006 Posted April 6, 2006 Not hard at all jayson. Actually I had Carbonize explain it to me. Very easy after he did that. Quote
TCH-Don Posted April 6, 2006 Posted April 6, 2006 If I have to use htdocs as the root, then I cant use it for multiple sites. Perhaps this isnt what Im looking for. Dave I use a folder below htdocs for each site I work on. Quote
TCH-Don Posted April 6, 2006 Posted April 6, 2006 Jayson did you use the batch file to start apache first and put your files in the folder you created below C:\xampp\htdocs\ ( or whatever drive you installed on ) and then pointed your browser to http:/localhost/folder_name/ ? Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 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... Thanks Quote
TCH-Tim Posted April 6, 2006 Posted April 6, 2006 (edited) 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 April 6, 2006 by timhodge Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 Ok, I will give this a try, and hope I have better luck this one then the lite version. Thanks Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 (edited) 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  should 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 April 6, 2006 by jayson Quote
TCH-Tim Posted April 6, 2006 Posted April 6, 2006 So then it works? Keep in mind that firewall/security stuff may restrict loopback connections. Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 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 Quote
TCH-Tim Posted April 6, 2006 Posted April 6, 2006 Your index.php file is looking in /inc/, should it maybe be looking in /php/inc? Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 ok, I have no idea how to fix that, so I moved my INC file to the htdocs, and now it works,, Thanks all for putting up with me Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 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 :?: Quote
TCH-Tim Posted April 6, 2006 Posted April 6, 2006 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. Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 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> Quote
TCH-Bruce Posted April 6, 2006 Posted April 6, 2006 I've found that xampp did not like the $_SERVER['DOCUMENT_ROOT'] so I wrote my includes as Tim describes. Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 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> Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 This is what I get now Warning: include(/php/inc/header.php) [function.include]: failed to open stream: No such file or directory in I:\xampp\xampp\htdocs\php\index.php Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 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. Quote
wampthing Posted April 6, 2006 Posted April 6, 2006 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? Quote
jayson Posted April 6, 2006 Author Posted April 6, 2006 not sure this is what you mean, but I found that: <?php include("inc/header.php"); ?> That worked great Quote
TCH-Bruce Posted April 6, 2006 Posted April 6, 2006 Dave ~ is pool a sub-folder of the folder your calling php files are located in? If it is remove the leading /. Making it /pool/whatever.php is forcing it to look in the /httpdocs folder. Jayson ~ that is correct Quote
jayson Posted April 7, 2006 Author Posted April 7, 2006 WOW!!! I am right about something, now I wish I knew what I was right about.. Quote
JTD Posted April 7, 2006 Posted April 7, 2006 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'); Quote
TCH-Don Posted April 7, 2006 Posted April 7, 2006 Normally xampp is to be installed from the root of your hard drive like c:\xampp did you really install it under your program files folder? Quote
JTD Posted April 7, 2006 Posted April 7, 2006 Yes but I have since uninstalled it. Ill try the other approach. Quote
TCH-Tim Posted April 7, 2006 Posted April 7, 2006 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. Quote
jayson Posted April 7, 2006 Author Posted April 7, 2006 Tim not sure if that was directed at me, but got to work link a charm, I am now working on the second site, so all is good Thanks again for your help... Quote
jayson Posted April 7, 2006 Author Posted April 7, 2006 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? Quote
TCH-Tim Posted April 7, 2006 Posted April 7, 2006 technically you can put an include anywhere you want, just make sure your paths are correct. Quote
jayson Posted April 10, 2006 Author Posted April 10, 2006 (edited) 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 April 10, 2006 by jayson Quote
TCH-Tim Posted April 10, 2006 Posted April 10, 2006 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. Quote
jayson Posted April 10, 2006 Author Posted April 10, 2006 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 Quote
jayson Posted April 10, 2006 Author Posted April 10, 2006 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 Quote
TCH-Tim Posted April 11, 2006 Posted April 11, 2006 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. Quote
jayson Posted April 11, 2006 Author Posted April 11, 2006 how do I check my firewall? Is it automaticly on? Quote
TCH-JimE Posted April 11, 2006 Posted April 11, 2006 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 Quote
jayson Posted April 11, 2006 Author Posted April 11, 2006 (edited) Yea, I looked yesterday, it says my firewall was running. Thanks all and sorry I am a pest at times.. Edited April 11, 2006 by jayson Quote
TCH-JimE Posted April 12, 2006 Posted April 12, 2006 No one is a pest, everyone wants to learn so don't stop asking! JimE Quote
TCH-Don Posted April 12, 2006 Posted April 12, 2006 jayson, we all started with the help of others. Soon you will answering the same questions for others. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.