xf220 Posted January 28, 2010 Share Posted January 28, 2010 The website is http://www.grlistingservices.com The code block is as follows: <?php if (!isset($id)) { include 'home.php'; } else { include "$id.php"; } ?> All files are in the same directory, I am running php5.x on a windows server with GoDaddy. This website used to work at my hold host, I just switched it today. Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/ Share on other sites More sharing options...
dbradbury Posted January 28, 2010 Share Posted January 28, 2010 The website is http://www.grlistingservices.com The code block is as follows: <?php if (!isset($id)) { include 'home.php'; } else { include "$id.php"; } ?> All files are in the same directory, I am running php5.x on a windows server with GoDaddy. This website used to work at my hold host, I just switched it today. you tried using the double quote? "home.php" also you have to concatenate the variable with .php include "".$id.".php"; that may work..., i havent tried it... or even include $id.".php"; Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003354 Share on other sites More sharing options...
Yucky Posted January 28, 2010 Share Posted January 28, 2010 From what it looks like, PHP is looking for a file called $id, rather than whatever he has set in that variable. Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003355 Share on other sites More sharing options...
teamatomic Posted January 28, 2010 Share Posted January 28, 2010 maybe the server is picky. try: include("D:\Hosting\5574555\html\$id.php"); Failed opening '$id.php' for inclusion, tells me that the var is not getting extrapolated. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003356 Share on other sites More sharing options...
dbradbury Posted January 28, 2010 Share Posted January 28, 2010 also what is on line 73 of index.php? Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003357 Share on other sites More sharing options...
xf220 Posted January 28, 2010 Author Share Posted January 28, 2010 I apologize, I had different code running from trying to solve my problem, I put the original code back in. Again so you do not have to scroll up. <?php if (!isset($id)) { include 'home.php'; } else { include "$id.php"; } ?> This code includes home.php correctly. When you click a link, it doesnt change the page included. Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003358 Share on other sites More sharing options...
dbradbury Posted January 28, 2010 Share Posted January 28, 2010 that is just the actual setting the links, like <a href="contactus.php"> and using template if you dont want the header to change... Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003362 Share on other sites More sharing options...
xf220 Posted January 29, 2010 Author Share Posted January 29, 2010 The links are set correctly, this exact website functioned perfectly on my old webhost, this has something to do with my new server. Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003364 Share on other sites More sharing options...
dbradbury Posted January 29, 2010 Share Posted January 29, 2010 huh... erm? dont suppose you could post your code for that page, the home page, with removing personal info please? Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003366 Share on other sites More sharing options...
xf220 Posted January 29, 2010 Author Share Posted January 29, 2010 index.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>GRListing Services-</title> <meta name="keywords" content="GRListing Services, Real Estate Listings, Real Estate, WNY, Buffalo, Property Staging "> <meta name="description" content="Property/real estate staging and preparation in Western NY."> <link rel=stylesheet href="styles.css" type="text/css" /> </head> <body> <table width="864" align="center" cellpadding="0" cellspacing="0" border="0" class="main"> <tr> <td class="green" align="right">GRListing Services - Williamsville, New York 14221</td> </tr> <tr cellpadding="0"> <td cellpadding="0"> <img src="images/topheader.png" /> </td> </tr> <tr> <!-- ==================== LINKS =========================== --> <td class="green" align="center"> <table width="100%" cellspacing="0" cellpadding="0" width="center" border="0"> <tr> <td align="center"><a href="index.php?id=home">Home</a> </td> <td align="center"><a href="index.php?id=services">Services</a></td> <td align="center"><a href="index.php?id=contact">Contact</a></td> </tr> </table> </td> </tr> <tr> <td> <img src="images/header.png" /> </td> </tr> <tr> <td> <?php if (!isset($id)) { include 'home.php'; } else { include "$id.php"; } ?> </td> </tr> <tr> <td class="green"> © 2010 GRListing Services. All rights reserved. </td> </tr> </table> </body> </html> home.php <table width="100%" cellpadding="5" cellspacing="0" align="center" border="0"> <tr> <td colspan="2" align="center"> <h2>Let us help you improve the quality of your property!</h2> </td> </tr> <tr> <td> <h3>How can we help?</h3> GRListing Services is committed to helping Western New York sell properties by: <ul> <li>New Listing Preperation</li> <li>Property Clean Up</li> <li>Property Checks</li> <li>General Maintainence</li> <li>Sign Placement and Removal</li> </ul> </td> <td> <img src="images/forsale.png" align="right" /> </td> </tr> <tr> <td colspan="2"> <center><h2><a href="index.php?id=contact"/> Get started today! </a></h2></center> <p>GRListing Services is here to help any one sell a property for more! We specialize in prepping properties for sale so that the seller can earn the most for their property! Not only does GRListing Services advise homeowners and real estate agents of how to make the most of a sale, we do the work. The team at GRListing Services is dedicated and ready to help you; <a href="index.php?id=contact">contact us</a> today to learn more about what GRListing Services can do for you.</p> </td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003367 Share on other sites More sharing options...
dbradbury Posted January 29, 2010 Share Posted January 29, 2010 im not sure you can have links with ?id=home in them... as this is referencing to a file on your host, and i thought that it wouldnt allow special characters in filenames? Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003369 Share on other sites More sharing options...
xf220 Posted January 29, 2010 Author Share Posted January 29, 2010 Ive been using this code block for three years, godaddy is the first host it isnt working on. Im so stumped! For example it works here, this website is with the host grlistingservices was on. http://tmd-music.com/ Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003370 Share on other sites More sharing options...
dbradbury Posted January 29, 2010 Share Posted January 29, 2010 hmm, have you tried 000webhost.com ? they seem to be okay for me... they might not fit your spec, but it worth a shot... can try a free one, then if it works, get a proper domain?? Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003371 Share on other sites More sharing options...
teamatomic Posted January 29, 2010 Share Posted January 29, 2010 globals were on now their off. Fix the code $id = $_GET['id']; HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003372 Share on other sites More sharing options...
Yucky Posted January 29, 2010 Share Posted January 29, 2010 Take care with including files based on user input. If it weren't for the security restrictions on the account, a user could include anything they wanted on your site. They could still include any PHP file of yours though, including your config file if you have one. http://www.grlistingservices.com/index.php?id=index Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003383 Share on other sites More sharing options...
teamatomic Posted January 29, 2010 Share Posted January 29, 2010 Just for giggles I clicked on the link above. It brought the server to its knees. xf220: The link above output your header till php puked. You have a loop you should fix, PDQ! HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1003393 Share on other sites More sharing options...
xf220 Posted January 30, 2010 Author Share Posted January 30, 2010 Hey thanks, it was as simple as declaring the variable. And thank you for the advice, Is there a way I can say if the file is not from my server then it skipped the include code? Link to comment https://forums.phpfreaks.com/topic/190173-php-include-not-working/#findComment-1004048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.