Help please. Site's content disappears with php include

Hello,
I was designing a site and a php script I wrote works fine my itself; however, the moment I add include to the PHP script that writes it all of my site except the background disappears; however, it is shifted. :eek:

This image is what my site looks like without the include
and
This image is what happens after the include

Here is the area of code where I believe the issue is:
Line 136 without include:

<div class="rssTicker">Put script  here</div>

Line 136 with Include:

<div class="rssTicker"><? include('newsfeed/rss_slide.php'); ?> </div>

I hope someone can please help me fix and understand why this is happening.
If you have any questions, comments, concerns, suggestions, or solution :slight_smile: Please reply.

Thanks in Advance and Best Regards

If you look at the page’s view-source, what do you see between the div tags?
<div class=“rssTicker”>Anything at all here?</div>

I don’t use short tags, and maybe your config does have them enabled, but if you see the PHP code between the div tags try changing <? to <?php

And you can try making a direct HTTP request to the include file. eg.
http://yourdomain/newsfeed/rss_slide.php
Do you see the output OK (albeit unstyled)?

Also, for testing only, make sure this is at the beginning of your file


/* Development and Debugging */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);

There could well be an error of some sort within the rss_slide.php file. If it fails then nothing past that gets displayed.

What are your error settings in php.ini?
Can you post the rss_slide code?
Does the rss_slide use any header() statements?

I tried changing it to normal notation as my code on line 136 now says

<div class="rssTicker"><?php include('newsfeed/rss_slide.php'); ?></div>

And of course the code without the include just does not have the php code in that line.

Do you have any other ideas because this is quite strange, I do not understand why the rest of my site is gone :eek::eek::eek:

I checked the view-source of what the page looks like, and I found out that nothing after line 136 is there. And all of my content is after line 136.

The code just stops at line 136, even though there is much more code after than. I attached a screenshot of the view source here

Any ideas on why this is happening and why none of my code after line 136 is being parsed even though it is just html and not php. Maybe is there a tag not closed or a function not closed in the php.

I hope this helps you to help me

Thanks in Advance,
Team 1504

can you pasted the contents in rss_slide.php please? so we can find out if there are some mistake

EDIT: I found the solution after I carefully read my code. It is explained below. I guess the lessoned learned is to read code carefully and make sure all necessary resources are included. However, I do not understand why an error was not parsed saying the necessary class was not included. How do I make sure the errors are parsed. Do i have to add a php.ini file ? And how do I do that?

when looking at the code of testServer/smartSearch/newsfeed/index.php
I realised that there is another PHP include to the PHP class which I based this entire script off of and I kept that include when I copied the script to smartSearch/ticker.php

but I do not have it in /smartSearch/index.php
I believe i forgot to add it to the file where my site and the news ticker are added together because it is above the doctype and I never look above the doctype because I usually never put anything before it.

This seems like the only sensible explanation because that would cause the script to not parse because it can not find the class it is derived from and therefore stops and does not parse the rest of the html below it.

cracking effort mate :tup:

If you dont have direct access to the ini file then you can use this code


/** error handler
    ** set error reporting level to 0 for live site, 1 for dev */
ini_set("display_errors", 1); 
ERROR_REPORTING(E_ALL);

That should give you some messages.

well because this is on my testServer I have no php.ini file in the root directory.

the RSS Slide works fine it is own directory.

the root of my testserver is myUsername/proejcts/testServer/

In there are two directories
newsfeed/
and
smartSearch/

smartSearch is where my main site is. In newsfeed is the php script I wrote working on its own. I copied the newsfeed dir and pasted it into the smartSearch dir.
then when I go to smartSearch/newsfeed/
it displays the index.php file which contains this:

<? include "class/lastRSS.php"; // Include lastRSS ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Single ticker test</title> 
<link href="ticker.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.innerfade.js"></script>
<script type="text/javascript" src="js/jquery.jigowattrss.js"></script>

<script type="text/javascript">
$(document).ready(

 function(){				

	
	$('#headline_slide').innerfade({
		animationtype: 'slide',
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: ''
	});

});
</script>

</head>

<body style="background:#000;">
<div style="float:right">
        <? include('rss_slide.php'); ?>
</div>
</body>
</html>

I then copied and pasted that index.php into the directory one up, which is just /smartSearch/
and I renamed it ticker.php and updated all the links so they can still find the resources.
when I go to my testServer/smartSearch/ticker.php
everything works fine.

So there are no errors in rss_slide.php

Then I simply copied the resource links in to index.php in /smartSearch/ and then added the include in line 136. And my problem occurs.

I hope this made it more clear and you can help with my problem.

I can attach some screenshots or link a video of me showing all this if it helps