1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

include not working

Discussion in 'PHP' started by Notting, Apr 11, 2007.

  1. #1
    Notting, Apr 11, 2007 IP
    SEMrush
  2. sarahk

    sarahk iTamer Staff

    Messages:
    26,936
    Likes Received:
    4,106
    Best Answers:
    117
    Trophy Points:
    665
    #2
    You'll need to include the relevant parts of the script... and wrap it in [ php ] tags.
     
    sarahk, Apr 11, 2007 IP
  3. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #3
    Can also require the file.
    same rules apply may need to use quotes or hashes depending on the setup of your php script and version php you are running.

    Hope this helps.
     
    lowridertj, Apr 11, 2007 IP
  4. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just to kind of go on what lowridertj said... you should always use either double or single quotes ("" or '') around your strings. PHP will generally work out what you are trying to do if you don't quote your strings but it's not right. When lowridertj said hash I think he meant single quotes. Where I'm from, at least, a hash is a '#' symbol.

    Anyway, remember to include your file via the filesystem, as opposed to trying to include if via HTTP. I'm going to assume you're doing the latter: for some reason a lot of people think that's right and for 99.999% of the cases, it's not.

    As sarahk said: it would have helped if you gave us some code, just for more information, but if you do something like:
    include( 'linkmanager/links.php' );

    it would probably work.
     
    TwistMyArm, Apr 11, 2007 IP
  5. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #5
    As others posted, without seeing the portion of your page where the include is no one can give you a definate answer.

    However; based on this error message:
    I think you may have used a full url in your include statement and the sever is refusing to include it because of the configuration of the server.

    This syntax will work on most servers: include('http://www.yourdomain.com/yourdirectory/yourfilename');

    This syntax is better and works on all: include('/yourdirectory/yourfilename');
     
    Colbyt, Apr 11, 2007 IP
    commandos likes this.
  6. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #6
    My fault you are correct ment single quotes.. lol busy busy this morning. was typing fast.

    also in the string for include or require make sure to use the full path to the file. not url.

    example.
    <?php include("/home/username/public_html/path_to_file");?>

    helps php recongize exactly where a file is. may want to look at using require_once("path_to_file");
     
    lowridertj, Apr 11, 2007 IP
  7. NetworkTown.Net

    NetworkTown.Net Well-Known Member

    Messages:
    2,022
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    165
    #7
    IF you are working on localhost include using url dose not work it will work on a server tho,
     
    NetworkTown.Net, Apr 11, 2007 IP
  8. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #8
    It might work on yours, but I can guarantee you it doesn't work on mine. On top of that, I would say that if it does work on yours, it's a BIG security issue. I'd also love to know how it actually does work on yours, but that's something different.

    To test my theory, I created a couple of files (all attached as a ZIP file). function.php is a simple script that defines a function that prints a string. fs.php includes that file via the filesystem, then calls the function. localhost.php calls the file via HTTP on the localhost and http.php calls the file via HTTP on your host (it will also tell you the exact way that it's including the file).

    Now, when I call the fs.php file on my remote server, the function runs correctly. When I call the http.php file on my remote server, I see that it's supposedly including the file correctly, but the function call fails.

    Networktown.net: any chance of you testing this script and telling us the results? If it works, do you know why it works, why mine doesn't and how, exactly, yours does work?
     

    Attached Files:

    TwistMyArm, Apr 11, 2007 IP
  9. Notting

    Notting Notable Member

    Messages:
    3,210
    Likes Received:
    335
    Best Answers:
    0
    Trophy Points:
    280
    #9
    Got it sorted now. But have had another problem pop up....will it never end!!

    Thanks for all your replies
    Notting
     
    Notting, Apr 11, 2007 IP
    commandos likes this.
  10. minute

    minute Peon

    Messages:
    443
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #10
    sometimes I have had to use curl library for different servers instead of include.

    Pain in the butt.
     
    minute, Apr 13, 2007 IP
  11. PresFox

    PresFox Active Member

    Messages:
    218
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #11
    just use fopen then, works fine with urls
     
    PresFox, Apr 14, 2007 IP
  12. Notting

    Notting Notable Member

    Messages:
    3,210
    Likes Received:
    335
    Best Answers:
    0
    Trophy Points:
    280
    #12
    I messed around with the code and now it's not working again. What is wrong with this:
    
    <html>
    <head>
    	<meta http-equiv="Content-Language" content="en-gb">
    	<title>African Grey Parrot - Links</title>
    <META NAME="keywords" CONTENT="african grey parrot, african grey parrots">
    <META NAME="description" CONTENT="African Grey Parrot information, guide, articles, care, buying guide and community">
    <META NAME="Theafricangreyparrot.co.uk" CONTENT="manager@theafricangreyparrot.co.uk">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta http-equiv="Content-Language" content="en-gb">
    <link rel="shortcut icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="style.css">
    	<style type="text/css">
    <!--
    #Layer2 {	position:absolute;
    	width:120px;
    	height:19px;
    	z-index:2;
    	left: 27px;
    	top: 199px;
    }
    .style2 {color: #000000}
    -->
        </style>
    </head>
    
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    _uacct = "UA-265014-1";
    urchinTracker();
    </script>
    
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    
    
    <script language="javascript" src="http://thumbnails.iwebtool.com/src.js?border=004891" type="text/javascript"></script>
    
    
    
    <!-- PAGE TABLE; BEGIN -->
    <table width="750" border="0" cellpadding="0" cellspacing="0" align="center">
    	<tr valign="top">
    		<td>
    			<!-- HEADER TABLE; BEGIN -->
    			<table width="750" border="0" cellpadding="0" cellspacing="0">
    				<form method="POST" action="_derived/nortbots.htm" onSubmit="location.href='_derived/nortbots.htm';return false;" webbot-onSubmit webbot-action="--WEBBOT-SELF--">
    				<!--webbot bot="SaveResults" S-Email-Address="manager@theafricanparrot.com" S-Email-Format="TEXT/PRE" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot bot="SaveResults" i-checksum="43374" endspan -->
    				<tr>
    					<td colspan="3">
    						<a href="/index.html">
    							<img src="images/home_button.gif" width="51" height="16" border="0" alt=""></a></td>
    					<td colspan="5">
    						  	<a href="javascript:window.external.AddFavorite('http://www.theafricangreyparrot.com','Theafricangreyparrot.com')">							
    							<img src="images/favourites_button.gif" width="94" height="16" border="0" alt=""></a></td>
    					<td colspan="4">
    						<img src="images/header_01.gif" width="371" height="16" alt=""></td>
    					<td rowspan="2">
    						<img src="images/header_03.gif" width="31" height="22" alt=""></td>
    					<td rowspan="2">
    						<img src="images/header_search.gif" width="62" height="22" alt=""></td>
    					<td colspan="2" rowspan="2" background="images/header_search_background.gif">
    						<img src="images/spacer.gif" width="96" height="1" alt=""><br>
    						<input type="text" size="15" name="search" value="" class="forminputsmall"></td>
    					<td rowspan="2">
    							<input type="image" src="images/search_button.gif" width="22" height="22" alt="Go"></td>
    					<td rowspan="2">
    						<img src="images/header_04.gif" width="23" height="22" alt=""></td>
    				</tr>
    				</form>
    				<tr>
    					<td colspan="12">
    						<img src="images/header_02.gif" width="516" height="6" alt=""></td>
    				</tr>
    				<tr>
    					<td colspan="18">
    						<a href="/index.html"><img src="images/header_image.gif" alt="African Grey Parrot" width="750" height="84" border="0"></a></td>
    				</tr>
    				<tr>
    					<td colspan="9">
    						<img src="images/header_05.gif" width="166" height="22" alt=""></td>
    					<td>
    						<a href="/African-Grey-Parrot-Bio.html">
    							<img src="images/button_1.gif" width="116" height="22" border="0" alt="African Grey Parrot Bio"></a></td>
    					<td>
    						<a href="/African-Grey-Parrot-Care.html">
    							<img src="images/button_2.gif" width="117" height="22" border="0" alt="African Grey Parrot Care"></a></td>
    					<td>
    						<a href="/African-Grey-Parrot-Buying-Guide.html">
    							<img src="images/button_3.gif" width="117" height="22" border="0" alt="African Grey Parrot buying Guide"></a></td>
    					<td colspan="3">
    						<a href="/African-Grey-Parrot-Articles.html">
    							<img src="images/button_4.gif" width="117" height="22" border="0" alt="African Grey Parrot Articles"></a></td>
    					<td colspan="3">
    						<a href="/African-Grey-Parrot-Community-forum.html">
    							<img src="images/button_5.gif" width="117" height="22" border="0" alt="African Grey Parrot Community"></a></td>
    				</tr>
    				<tr>
    					<td rowspan="2">
    						  <img src="images/icon_1.gif" width="24" height="25" border="0" alt=""></td>
    					<td rowspan="2">
    						<a href="/index.html">
    							<img src="images/icon_2.gif" width="23" height="25" border="0" alt=""></a></td>
    					<td colspan="2" rowspan="2">
    						  <img src="images/icon_3.gif" width="23" height="25" border="0" alt=""></td>
    					<td rowspan="2">
    						  <img src="images/icon_4.gif" width="23" height="25" border="0" alt=""></td>
    					<td rowspan="2">
    						  <img src="images/icon_5.gif" width="23" height="25" border="0" alt=""></td>
    					<td rowspan="2">
    						  <img src="images/icon_6.gif" width="23" height="25" border="0" alt=""></td>
    					<td colspan="2" rowspan="2">
    						  <img src="images/icon_7.gif" width="27" height="25" border="0" alt=""></td>
    					<td colspan="9">
    						<img src="images/header_grey_bar.gif" width="584" height="17" alt=""></td>
    				</tr>
    				<tr>
    					<td colspan="9">
    						<img src="images/header_spacer.gif" width="584" height="8" alt=""></td>
    				</tr>
    				<tr>
    					<td>
    						<img src="images/spacer.gif" width="24" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="23" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="4" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="19" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="23" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="23" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="23" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="6" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="21" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="116" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="117" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="117" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="31" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="62" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="24" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="72" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="22" height="1" alt=""></td>
    					<td>
    						<img src="images/spacer.gif" width="23" height="1" alt=""></td>
    				</tr>
    			</table>
    			<!-- HEADER TABLE; END -->
    		</td>
    	</tr>
    	<tr valign="top">
    		<td>
    			<table width="734" border="0" cellpadding="0" cellspacing="0">
    				<tr valign="top">
    					<td>
    						<!-- SIDE NAV TABLE; BEGIN -->
    						<!-- SIDE NAV TABLE; END -->
    						<table width="749" border="0" cellpadding="0" cellspacing="0">
    							<tr>
    								<td height="21" width="1">
    									</td>
    								<td width="23">
    									<img src="images/main_icon.gif" width="23" height="21" alt=""></td>
    							  <td background="images/main_background.gif" class="title" width="725">
    									<h1 class="title"><img src="images/spacer.gif" width="400" height="1" alt=""><br>
    									African Grey Parrot Links</h1></td>
    							</tr>
    							<tr>
    								<td colspan="3">
    									</td>
    							</tr>
    							</table>
    									</p>
    						
    								
    		<p align="right"> <u><b><a href="linkmanager/form.html">Add your link to this page</a></b></u>
    												
    				</p>		
    				<p>
    <?php include('/linkmanager/links.php'); ?>
    						</p>
    						
    						
    								</p>
    		<p> <u><b><a href="linkmanager/form.html">Add your link to this page</a></b></u></p>
    		
    		
    		
    					
    						<a href="http://www.seomoz.org/page-strength/www.theafricangreyparrot.com">
    <img src="http://www.seomoz.org/img/page_strength/badges/badge3_0.gif" alt="Page Strength SEO Tool - SEOmoz.org" style="border: 0;" /></a> </br>SEOmoz Page Strength 3!
    
    						<p> 
    						<!-- WINDOW 3; END -->
    					</td>
    				</tr>
    				</table>
    			<!-- BODY TABLE; END -->
    		</td>
    	</tr>
    </table>
    	<div align="center">
    		<table cellpadding="0" cellspacing="0" width="755" height="102" id="table3">
    			<!-- MSTableType="nolayout" -->
    			<tr>
    				<td valign="top" height="11" width="173">
    				<p align="center">
    				&nbsp;</td>
    				<td valign="top" height="11" width="435" colspan="2">
    				</td>
    				<td valign="top" height="16" width="147">
    				</td>
    			</tr>
    			<tr>
    				<td valign="top" height="70" width="173">
    						<table width="166" border="0" cellpadding="0" cellspacing="0" id="table4" height="70">
    							<tr>
    							  <td bgcolor="#E1DFDF" style="border: 1px solid #C0C0C0">
    									<p align="center">									</p>
    									<p align="center"></td>
    							</tr>
    							</table>
    						</td>
    				<td valign="top" height="70" width="423" style="border: 1px solid #C0C0C0">
    				The RSPB do brilliant work for the protection of bird species. 
    				This site supports the work of the RSPB and we hope you will do 
    				the same. Visit their website by clicking below.
    				<span id="Description">From as little as £2.50 a month you can 
    				help protect the some amazing species of birds and the 
    				countryside.</span></td>
    				<td valign="top" height="70" width="7">
    				&nbsp;</td>
    				<td valign="top" height="70" width="147" style="border: 1px solid #C0C0C0">
    				<a href='http://scripts.affiliatefuture.com/AFClick.asp?affiliateID=33825&merchantID=917&programmeID=3146&mediaID=16707&tracking=&url='>
    				<img border=0 src='http://banners.affiliatefuture.com/917/16707.gif' align="left"></a></td>
    			</tr>
    			<tr>
    				<td valign="top" height="16" width="755" colspan="4">
    				</td>
    			</tr>
    		</table>
    </div>
    <div align="center">
    	<table cellpadding="0" cellspacing="0" width="755" height="29" id="table1">
    		<!-- MSTableType="nolayout" -->
    		<tr>
    			<td valign="top" height="29" width="755">
    			<img border="0" src="images/footer.jpg" width="754" height="26"></td>
    		</tr>
    	</table>
    </div>
    <!-- PAGE TABLE; END -->
    
    </body>
    </html>
    
    
    PHP:
    the include is about 3/4 of the way down. Could it be due to the permissions set on the file it is supposed to include. Or some other settings?

    The file im trying to include is:

    http://www.theafricangreyparrot.com/linkmanager/links.php

    Cheers
    Notting
     
    Notting, Apr 14, 2007 IP
  13. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #13
    put in teh full path to file

    example
    <?php include('/home/username/public_html/pat_to_file/links.php'); ?>

    rep posts.
     
    lowridertj, Apr 15, 2007 IP
  14. Notting

    Notting Notable Member

    Messages:
    3,210
    Likes Received:
    335
    Best Answers:
    0
    Trophy Points:
    280
    #14
    What you've suggested didn't work lowridertj.

    What do you mean "rep posts". I'm very generous with giving out rep to people that have helped me out. What you've just posted is an insult.

    notting
     
    Notting, Apr 15, 2007 IP
  15. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #15
    Might not work on all servers.

    <?php include('http://domainname.xxx/pat_to_file/links.php'); ?>

    will work on most servers but it adds a little to the load.
     
    Colbyt, Apr 15, 2007 IP
  16. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #16
    You must not program very often. before php 5 full path was needed in most include statements also depending on how the age was coded as well. THink before you speak.

    this works up till php4 and most scripts don't like live links. specially if its calling a database hookup.

    thats why full path is normally used.
     
    lowridertj, Apr 15, 2007 IP
    Notting likes this.
  17. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Notting: the problem with that include is that you have the forward slash at the start which means it starts looking in the root of the filesystem. It doesn't just start looking in the document root of your web server. Get rid of it (the initial forward slash) and it should be fine.

    Colbyt: including via HTTP only includes output of PHP files, not the code itself. There seems to be a growing trend of people including files via HTTP then complaining that it doesn't work... where does this start / get taught?
     
    TwistMyArm, Apr 15, 2007 IP
  18. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #18
    was wondering the same questions.


    What I've always done to get away of mis directed paths is full path normally setup in my main config file full path to main directory then just include that to call areas. much easier.
     
    lowridertj, Apr 15, 2007 IP
  19. Notting

    Notting Notable Member

    Messages:
    3,210
    Likes Received:
    335
    Best Answers:
    0
    Trophy Points:
    280
    #19
    I'm certain its not a problem to do with that line. Ive tried every combination of suggestions above and it won't work. Sod it!

    Notting
     
    Notting, Apr 16, 2007 IP
  20. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #20

    I really think it is your server configuration as I stated earlier.

    As proof here is your link page on my site http://jkin.com/notting.php

    The header could be anything you want as could the footer. The complete text of the file notting.php:

    Edit: and here it is on a godaddy server that has a different configuration than the above:

    I will take this down after you have seen it.
     
    Colbyt, Apr 16, 2007 IP