Jump to content

[SOLVED] Error Help


supanoob

Recommended Posts

I have the following bit of code, but ever since i put in the pagination (SP?) code it keeps throwing out an error (see below)

 

<?php 

//query for main topic
$query="select post_date, post_time, post_body, posted_by, post_topic from tord_forums where post_id='$post_id'";
$result=mysql_query($query);
if (!$result)
{
die (mysql_error());
}

$num_rows=mysql_num_rows($result);

$row=mysql_fetch_array($result);
$post_date_1=($row['post_date']);
$post_time_1=($row['post_time']);
$topic_name_1=($row['post_topic']);
$post_body_1=($row['post_body']);
$posted_by_id_1=($row['posted_by']);

//player query
$query="select username, account_id, post_count, signature from tord_accounts where account_id='$posted_by_id_1'";
$result=mysql_query($query);
if (!$result)
{
die (mysql_error());
}

$num_rows=mysql_num_rows($result);

$row=mysql_fetch_array($result);
$posted_by_1=($row['username']);
$poster_id_1=($row['account_id']);
$poster_post_count_1=($row['post_count']);
$player_signature_1=($row['signature']);

                        echo "
                        <center><a href=\"forum.php?step=forum_index\">Forum</a> >> <a href=\"forum.php?step=view_board&board_id=$board_id\">$board_name</a> >> <a href=\"forum.php?step=view_forum_post&post_id=$post_id&board_id=$board_id\">$topic_name_1</a></center>
                        <table border=\"0\" width=\"100%\" id=\"table29\">
						<tr>
							<td colspan=\"2\" bgcolor=\"#A7A7A7\">Post By: 
							$posted_by_1</td>
						</tr>
						<tr>
							<td width=\"25%\" valign=\"top\" bgcolor=\"#A7A7A7\">
							<table border=\"0\" width=\"100%\" id=\"table30\">
								<tr>
									<td bgcolor=\"#838383\" style=\"border: 1px solid #C0C0C0\">
									Posted -<br> On: $post_date_1<br>At: $post_time_1</td>
								</tr>
							</table>
							<p>Player ID: $poster_id_1<br>
							Post Count: $poster_post_count_1<br>
							Contact Info<br>
 </p>
							<p> </td>
							<td bgcolor=\"#A7A7A7\" valign=\"top\">$post_body_1
 <hr>
							<p>$player_signature_1</td>
						</tr>
						<tr>
							<td colspan=\"2\" bgcolor=\"#A7A7A7\" height=\"10\">
							<table border=\"0\" width=\"100%\" id=\"table31\" cellspacing=\"0\" cellpadding=\"0\">
								<tr>
									<td width=\"25%\">Mail | Challenge</td>
									<td>
									<p align=\"center\">Quote 
								</td>
								</tr>
							</table>
							</td>
						</tr>
					</table>";
            //replies start here
            				echo "<center>Replies</cnter><br>";
            				

if(empty($_GET['page'])){    // Checks if the $page variable is empty (not set)
        $_GET['page'] = 1;      // If it is empty, we're on page 1
    }
    $limitvalue = $_GET['page'] * $limit - ($limit); 
    // Ex: (2 * 25) - 25 = 25 <- data starts at 25
    $board_id=$_GET['board_id'];
    $post_id=$_GET['post_id'];
    $query  = "SELECT post_id, post_date, post_time, post_body, posted_by, post_topic, reply_to, post_type, deleted FROM tord_forums where reply_to='$post_id' and deleted='no' and post_type='reply' order by post_id desc LIMIT $limitvalue, $limit";        
    $result = mysql_query($query) or die("Error: " . mysql_error()); 
    // Selects all the data from table.
    // mysql_error() will print an error if one occurs.
    
    /* Tip: The MySQL LIMIT value syntax is as follows: 
    
    LIMIT $row_to_start_at, $how_many_rows_to_return 
    
    */ 

                      while($row = mysql_fetch_array($result)){
                      $post_id_2=($row['post_id']);
                      $post_date_2=($row['post_date']);
                      $post_time_2=($row['post_time']);
                      $topic_name_2=($row['post_topic']);
                      $post_body_2=($row['post_body']);
                      $posted_by_id_2=($row['posted_by']);
                      
                      echo "<table border=\"0\" width=\"100%\" id=\"table29\">
						<tr>
							<td colspan=\"2\" bgcolor=\"#A7A7A7\">Post By: 
							SuPaNoOb</td>
						</tr>
						<tr>
							<td width=\"25%\" valign=\"top\" bgcolor=\"#A7A7A7\">
							<table border=\"0\" width=\"100%\" id=\"table30\">
								<tr>
									<td bgcolor=\"#838383\" style=\"border: 1px solid #C0C0C0\">
									Posted - <br> On: $post_date_2 <br> At: $post_time_2</td>
								</tr>
							</table>
							<p>Player ID: 1<br>
							Post Count: 999<br>
							Contact Info<br>
 </p>
							<p> </td>
							<td bgcolor=\"#A7A7A7\" valign=\"top\">$post_body_2<hr>
							<p>this will be a siggeh</td>
						</tr>
						<tr>
							<td colspan=\"2\" bgcolor=\"#A7A7A7\" height=\"10\">
							<table border=\"0\" width=\"100%\" id=\"table31\" cellspacing=\"0\" cellpadding=\"0\">
								<tr>
									<td width=\"25%\">Mail | Challenge</td>
									<td>
									<p align=\"center\">Quote</td>
								</tr>
							</table>
							</td>
						</tr>
					</table>";
}


echo"</table>";

if($_GET['page'] != 1){ 
$page=$_GET['page'];
        $pageprev = $page-1;
        $post_id=$_GET['post_id'];
        $board_id=$_GET['board_id'];
        echo("[<a href=\"forum.php?step=view_forum_post&post_id=$post_id&board_id=$board_id&page=$pageprev\">Previous</a>|"); 
    }else{
        echo("[Previous|");
    }

    $numofpages = $totalrows / $limit; 
    
    for($i = 1; $i <= $numofpages; $i++){
    $page=$_GET['page'];
        $post_id=$_GET['post_id'];
        $board_id=$_GET['board_id'];
            if($i == $page){
            echo("$i|");
        }else{
            echo("<a href=\"forum.php?step=view_forum_post&post_id=$post_id&board_id=$board_id&page=$i\">$i</a>|");
        }
    }


    if(($totalrows % $limit) != 0){
    $page=$_GET['page'];
        $post_id=$_GET['post_id'];
        $board_id=$_GET['board_id'];
     if($i == $page){
            echo("$i|");
        }else{
            echo("<a href=\"forum.php?step=view_forum_post&post_id=$post_id&board_id=$board_id&page=$i\">$i</a>|");
        }
    }
    $page=$_GET['page'];
    if(($totalrows - ($limit * $page)) > 0){
    $page=$_GET['page'];
        $pagenext = $page+1;
        $post_id=$_GET['post_id'];
        $board_id=$_GET['board_id'];
         
        echo("<a href=\"forum.php?step=view_forum_post&post_id=$post_id&board_id=$board_id&page=$pagenext\">Next</a>]"); 
    }else{
        echo("Next]"); 
    }
    
    mysql_free_result($result);
            				
            				
	echo "<p>Post Reply</p>";

?>

 

This is the error i recieve

 

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

any ideas why?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.