Forum Moderators: coopster

Message Too Old, No Replies

php script get the bottom of my page to disappear

         

marchy

6:55 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



Maybe someone can help me with this. I am just a beginner with PHP. I have put this code to include a php file on an html file. <?php include("include/fetchBlog.php"); ?> when I include it everything below this on my html page disappear when I upload it on the internet but I am able to see the included file. When I take off that code the page is ok.

This is what's in my htaccess file

Options +Indexes +FollowSymLinks +Includes +ExecCGI
AddType text/html .shtml

AddHandler server-parsed .htm

AddHandler application/x-httpd-php5 .php .php3 .phtml .html .php4 .php5 .htm

Anyone has ever encounter this type of problem?

Demaestro

7:09 pm on Sep 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



marchy,

Without seeing everything my first guess would be that the PHP file you are including has some html markup in it and that the markup isn't flowing with what you have in the original page.

Simple Example.

Orig page:
<table>
<tr>
<td>
A bunch of stuff
</td>
</tr>
<tr>
<td>
More Stuff
</td>
</tr>
</table>

Lets pretend the php include file starts out with a </tr> so when placed in the table, it breaks it and causes everything below it to be hidden

<table>
<tr>
<td>
A bunch of stuff
<?php include("include/fetchBlog.php"); ?>
</td>
</tr>
<tr>
<td>
More Stuff
</td>
</tr>
</table>

The above would render as this:

<table>
<tr>
<td>
A bunch of stuff
</tr>
</td>
</tr>
<tr>
<td>
More Stuff
</td>
</tr>
</table>

This would cause bad HTML and make the rest of the table hidden.

I am guessing a more complex version of my example is what is happening.

Look at the HTML source of the page with the include and see if you can find some bad HTML that may be the cause.

CyBerAliEn

7:39 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



Check your include/fetchBlog.php file.

Does it contain the PHP function exit()? (or 'die', etc)

marchy

8:28 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



yes it does it ends by this <?php endwhile; endif; ?>

CyBerAliEn

9:36 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



Can you post the complete code for the PHP file? (assuming it is not too long)

Since including this PHP file causes the rest of your page to "not exist", I am guessing that this PHP file includes the PHP function 'exit' (or one of its siblings), which results in PHP terminating all parsing, and hence would result in nothing rendering beyond this file.

It is quite possible this is not what is going on, but it seems reasonable.

marchy

10:03 pm on Sep 9, 2009 (gmt 0)

10+ Year Member



This is the whole page

<?php

function fetchBlog($words,$count=4)
{
$conID = mysql_connect("localhost","xx","xx") or die(mysql_error());
$DB = mysql_select_db("cn1634_wrdp1") or die(mysql_error());
$count = (int)$count;
$res = mysql_query(
"SELECT wp_posts.post_title,wp_posts.post_excerpt,wp_posts.post_name,wp_terms.slug FROM `wp_posts`
LEFT JOIN `wp_term_relationships` ON wp_posts.ID = wp_term_relationships.object_id
LEFT JOIN `wp_terms` ON wp_terms.term_id = wp_term_relationships.term_taxonomy_id
LEFT JOIN `wp_term_taxonomy` ON wp_terms.term_id = wp_term_taxonomy.term_id
WHERE wp_posts.post_status = 'publish'
AND wp_posts.post_type = 'post'
AND wp_term_taxonomy.taxonomy = 'category'
ORDER BY `ID` DESC LIMIT $count");

while ( $row = mysql_fetch_array($res) )
{
$title = $row["post_title"];
$content = $row["post_excerpt"];
$url = "http://find.example.com/".$row["slug"]."/".$row["post_name"]."/";

echo '<div id="news"><b><a href="'.$url.'">'.$title.'</b></a>'."\n";
echo '<p>';
echo $content.'...<a href="'.$url.'">Read more</b></a>'."\n";
echo '</p></div>'."\n";
}
}

fetchBlog(4);

include('http://find.example.com/wp-blog-header.php'); //Load wordpress blog API
define('WP_USE_THEMES', false);

//*/ #//*/ to enable, */ to disable

?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php //if ( in_category('Drug Rehabilitation Stories') ) : ### ENTER CATEGORY HERE ?>

<div class="news"><a class="news" href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
<p>
<?php the_excerpt(); ?>
</p></div>
<?php endwhile; endif; ?>

[edited by: eelixduppy at 10:22 pm (utc) on Sep. 9, 2009]
[edit reason] removed specifics [/edit]