Jump to content

PHP Code error (hide)


knnakai

Recommended Posts

:-\

I can't find where and why it only see the first 6 lines executing the topiclist.php not going Thu the code?

 

Please any suggestion??

 

hesre is the code:

 

<?php

//check for required information from the query string

if ( !isset( $_GET["topic_id"])) {

header("Location: topiclist.php");

exit;

}

 

//connect to server

$mysqli = mysqli_connect("localhost", "root", "root", "test");

 

//verify the topic exists

$verify_topic_sql = "SELECT topic_title FROM forum_topics

WHERE topic_id = '".$_GET["topic_id"]."'";

$verify_topic_res = mysqli_query($mysqli, $verify_topic_sql)

or die(mysqli_error($mysqli));

 

if (mysqli_num_rows($verify_topic_res) < 1 ) {

//this topic doens not exist

$display_block = "<p><em>You have selected an invalid topic.<br/>

Please <a href=\"topiclist.php\">Try again</a>.</em></p>";

} else {

//get the topic title

while ($topic_info = mysqli_fetch_array ( $verify_topic_res)) {

$topic_title = stripslashes($topic_info['topic_title']);

}

 

//gether the posts

$get_posts_sql = "SELECT post_id, post_text

DATE_FORMAT(post_create_time,

'%b %e %Y at %r') AS fmt_post_create_time, post_owner

FROM forum_posts

WHERE topic_id = '".$_GET["topic_id"]."'

ORDER BY post_create_time ASC";

$get_posts_res = mysqli_query($mysqli, $get_posts_sql)

or die(mysqli_error($mysqli));

 

//create the display string

$display_block = "

<p>Showing posts for the <strong>".$topic_title."</strong> Topic:</p>

<table width=\"100%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\">

<tr>

<th>AUTHOR</th>

<th>POST</th>

</tr>";

 

while ($posts_info = mysqli_fetch_array($get_posts_res)) {

$post_id = $posts_info['post_id'];

$post_text = nl2br(stripslashes($posts_info['post_text']));

$post_create_time = $posts_info['fmt_post_create_time'];

$post_owner = stripslashes($posts_info['post_owner']);

 

//aad to display

$display_block .= "

<tr>

<td width=\"35%\" valign=\"top\">".$post_owner."<br/>

[".$post_create_time."]</td>

<td width=\"65%\" valign=\"top\">".$post_text."<br/><br/>

<a href=\"replaytopost.php?post_id=".$post_id."\">

<strong>REPLAY TO POST</strong></a></td>

</tr>";

}

 

//free result

mysqli_free_result($get_posts_res);

mysqli_free_result($verify_topic_res);

 

//close connection to MySQL

mysqli_close($mysqli);

 

//Close up table

$display_block .= "</table>";

}

?>

<html>

<head>

<title>Posts in Topic</title>

</head>

<body>

<h1>Posts in Topic</h1>

<?php echo $display_block; ?>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/166627-php-code-error-hide/
Share on other sites

first, please use [ code ] [ /code ] tags (without the spaces)...it's the button in the toolbar with the # sign on it

 

next, is the name of this file topiclist.php? because the first block of code will produce a infinite redirect loop:

if ( !isset( $_GET["topic_id"])) {
   header("Location: topiclist.php");
   exit;
}

 

are you getting any PHP errors? make sure error reporting is on:

<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

Link to comment
https://forums.phpfreaks.com/topic/166627-php-code-error-hide/#findComment-878633
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.