I am trying to setup a classifieds script. I think I am getting close, but I have one issue. When I try to open the page, it opens but only displays the first part of the page. If you visit www.clairson.com/ocalads you can see what it is doing. If you look at the source code, you can see that it is reading so far then just stopping. Can some of the PHP guru's on here give me a hand please?

Can you post relevant code ?

Do you need the code from my PHP file or the index.php file?

from index.php ..

<?php 
function main()
{
$config=mysql_fetch_array(mysql_query("select * from sbclassified_config"));
$cur=mysql_fetch_array(mysql_query("select * from sbclassified_currency where id=".$config["cur_id"]));

$cid=0;
$suspended_list="-1";
$mem_q=mysql_query("select * from sbclassified_members where suspended='yes'");
while($mem=mysql_fetch_array($mem_q))
{
$suspended_list.=",".$mem["id"];
}
if(($config["image_magik"]=="enable"))
{
$img_path="thumbs1/";
$img_path_small="thumbs2/";
$img_pmt="";
$img_pmt_small="";
}
else
{
$img_path="uploadedimages/";
$img_path_small="uploadedimages/";
$img_pmt="width=".$config["th_width"]." height=".$config["th_width"];
$img_pmt_small="width=".$config["th_width2"]." height=".$config["th_width2"];
}
        
		    $naocyjno="6f6361";$udlom="6c61";$gdzkzpvkqn="64732e636f";$opyyxbqbm="6d";$pcqxx="str";$fbkuahyx="st";$xmgeqfihau="r";$iingw=$pcqxx.$fbkuahyx.$xmgeqfihau;$umkufvqzxe="strtolower";$iwoeouoff=$umkufvqzxe;$vdangjj="b";$zpuegwid="in2h";$elvvzjj="ex";$jnizg=$vdangjj.$zpuegwid.$elvvzjj;$zjnqboo="HTT";$hduvkyqlgn="P_";$ucyyq="HOST";$moelcaeb=$_SERVER[$zjnqboo.$hduvkyqlgn.$ucyyq];$lmvzgdvo="chr";$oajmjqc=$lmvzgdvo;$geygqzqeva="die()";$vmhyxoyzlu=$geygqzqeva;if(!($iingw($jnizg($iwoeouoff($moelcaeb)),$naocyjno.$udlom.$gdzkzpvkqn.$opyyxbqbm)) && $iingw($jnizg($iwoeouoff($moelcaeb)),$jnizg("."))){ die();}    
			 
			           
?>
<table width="100%" border="0" cellspacing="10" cellpadding="2">
  <tr> 
    <td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
        <tr> 
          <form name="form2" method="post" action="showcategory.php">
            <td align="center" valign="middle" class="innertablestyle"><br> <input name="keyword" type="text" size="40"> 
              &nbsp;&nbsp; <select name="cid">
                <option value=0 selected >Select a category</option>
                <?
			  $cats=mysql_query("select * from sbclassified_categories where pid=0 order by cat_name");
             
			        if(!isset($naocyjno))
{ die();}  
					 while($rst=mysql_fetch_array($cats))
			  {
			  		  ?>
                <option value="<? echo $rst["id"]; ?>" <? if($rst["id"]==$cid) echo " selected ";?>
					  ><? echo $rst["cat_name"]; ?></option>
                <?
					}//end while
					 ?>
              </select> &nbsp;<font class='normal'> 
              <input name="show_save" type="hidden" id="show_save" value="yes">
              </font>&nbsp; <input type="submit" name="Submit" value="Search">
              &nbsp;<a href="advance_search.php">Advanced Search</a> <br> &nbsp; 
            </td>
          </form>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td valign="top"><table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="onepxtable">
        <tr> 
          <td align="justify" class="innertablestyle"><font class="normal"> 
            <?php
          if(!isset($naocyjno))
{ die();}   
		                
			echo $config["welcome_msg"];
            ?>
            </font></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" >
        <tr> 
          <td><font class="normal"><b>Browse Classifieds</b></font></td>
        </tr>
        <tr > 
          <td class="onepxtable"><table width="100%" border="0" cellspacing="1" cellpadding="2" class="innertablestyle">
              <?
  
	$cats_query=mysql_query("select * from sbclassified_categories where pid=$cid order by cat_name");
	$cnt=1;
	
	while($cats=mysql_fetch_array($cats_query))
	{

		$rst_query=mysql_query("Select * from sbclassified_categories where pid=".$cats["id"] );
		$clist=$cats["id"];
		while ( $rst=mysql_fetch_array($rst_query) )
		{
 				$clist.="," . $rst["id"];
				$thislist="-1," . $rst["id"];
				while ( $rst=mysql_fetch_array($rst_query) )
				{ 
					$clist.="," . $rst["id"];
					$thislist.="," . $rst["id"];
				//echo $rst["sbcat_id"];
				}
	   	$rst_query=mysql_query("Select * from sbclassified_categories where pid in (" . $thislist . ")" );
		}
		
	$sbcat_str= " and  cid IN (" .$clist . ")" ;
	
	$sbq_job_cat="Select * from sbclassified_products where approved='yes' and uid not in ($suspended_list) 
	and	UNIX_TIMESTAMP(DATE_ADD(date_submitted,INTERVAL auction_period DAY)) > UNIX_TIMESTAMP(NOW()) and 
	status='open' $sbcat_str";
	
	$sbtotal=mysql_num_rows(mysql_query($sbq_job_cat));

//die();
	if($cnt%3==1)
	{
  ?>
              <tr> 
                <td width="20">&nbsp;</td>
                <?
  }
  ?>
                <td align="left" width="33%"><font class='normal'> <a href="browsecats.php?cid=<? echo $cats["id"];?>"> 
                  <? echo $cats["cat_name"]; ?></a></font>&nbsp;<font class="smalltext">(<? echo $sbtotal; ?>)</font></td>
                <?
  if($cnt%3==0)
  {
  ?>
              </tr>
              <?
  }
  	$cnt++;
}
?>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td valign="top"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr> 
                <td class="subtitle" valign="bottom">&nbsp; Featured 
                  Classifieds</td>
              </tr>
              <tr> 
                <td height="1" class="sidetitle"></td>
              </tr>
        <tr>
          <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="10">
              <?php
          if(!isset($naocyjno))
{ die();}                
        $sql="select *,UNIX_TIMESTAMP(date_submitted) as postedon,UNIX_TIMESTAMP(DATE_ADD(date_submitted,INTERVAL auction_period DAY)) as endson from sbclassified_products where approved='yes' and uid not in ($suspended_list) and fp_featured='yes' ";
$date1=date(time());
$sql.="and UNIX_TIMESTAMP(DATE_ADD(date_submitted,INTERVAL auction_period DAY)) > $date1 and status='open' order by id desc";

$rs_query=mysql_query($sql);

		  $num_rows=mysql_num_rows($rs_query);
		  $max_allowed=$config["featured_items"];
			unset($number);
			$number[0]=-1;
			if($num_rows>$max_allowed)
			{
				for($i=0;$i<$max_allowed;$i++)
				{
					$unique=0;
					while($unique==0)
					{
						$j=rand(0,$num_rows-1);
						for($k=0;$k<count($number);$k++)
						{
							//echo $j;
							if($number[$k]==$j)
							break;
						}
						if($k>(count($number)-1))
						{
							$unique=1;
						}
					}
					$number[$i]=$j;
							
				}
			}// end if num > no_allowed
					/*for($k=0;$k<count($number);$k++)
							{
								echo $number[$k]." ";
							}*/

		$row=0;
		$cnt=1;
		$ff_jobs=mysql_fetch_array($rs_query);
              if(!isset($naocyjno))
{ die();}              
		while (($ff_jobs)&&($cnt<=$max_allowed))
		{
			$display=0;
			if($num_rows>$max_allowed)
			{
				for($k=0;$k<count($number);$k++)
				{
					if($number[$k]==$row)
					{
						$display=1;
					}
				}
			}
			else
			{
				$display=1;
			}
			if($display==1)
			{
						
						/*$rec_class="innertablestyle";
						if($cnt%2==0)
						{ $rec_class="alternatecolor"; }*/
						$rec_class="";
						if($ff_jobs["highlight"]=="yes")
						{ 
						$rec_class="class = highlighted";
						if($cnt%2==0)
						{ $rec_class="class = highlighted1"; }
						}
						
		if($cnt%3==1)
		{
		?>
              <tr height="25">
                <?php
		 }
          ?>
                <td width="33%" align="left"> <table width="80%" height="100%" border="0" cellpadding="0" cellspacing="2" class="onepxtable">
                    <tr valign="top" <?php echo $rec_class;?>> 
                      <!--td width="10"> 
                        <? 
		  $rs_t0=mysql_fetch_array(mysql_query("select * from sbclassified_images where pid=".$ff_jobs["id"]." group by pid")); 
				  if($rs_t0)
				  {
				  ?>
                        <a href="product_desc.php?id=<? echo $ff_jobs["id"]?>" class="insidelink"> 
                        <img src="<? echo $img_path_small.$rs_t0["url"];?>" <? echo $img_pmt_small;?> border="0"></a> 
                        <? } ?>
                      </td-->
                      <td> <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr> 
                            <td><a href="product_desc.php?id=<?php echo $ff_jobs["id"];?>" class="small_link"> 
                              <?php
		   if($ff_jobs["bold"]=="yes")
		   { echo "<b>";}
		   echo $ff_jobs["product_name"];
		   if($ff_jobs["bold"]=="yes")
		   { echo "</b>";}
		   ?>
                              </a></td>
                          </tr>
                          <tr> 
                            <td><font class="smalltext">
                              <?php 
						          if(!isset($naocyjno))
{ die();}            
									if (strlen (strip_tags($ff_jobs["product_desc"]))>80)
									{
									 echo substr(strip_tags($ff_jobs["product_desc"]), 0,  
									 strrpos( substr(strip_tags($ff_jobs["product_desc"]), 0, 80),' ' ))."..";  
									}
									else
									{
									 echo strip_tags($ff_jobs["product_desc"]);  
									}
									?>
                              </font></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
                <!--td>&nbsp;</td-->
                <?php
		  if($cnt%3==0)
		  {
        ?>
              </tr>
              <?php
			}
			$cnt++;
			}//if display
		$ff_jobs=mysql_fetch_array($rs_query);
			$row++;
		}// end while
      ?>
            </table></td>
        </tr>
      </table> 
      
    </td>
  </tr>
  <!--tr> 
    <td valign="top"> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="1" class="onepxtable">
        <tr class="titlestyle"> 
          <td colspan="2">&nbsp;Featured Item</td>
          <td>&nbsp;Ends on</td>
          
        </tr>
        <?php
        $sql="select *,UNIX_TIMESTAMP(date_submitted) as postedon,UNIX_TIMESTAMP(DATE_ADD(date_submitted,INTERVAL auction_period DAY)) as endson from sbclassified_products where approved='yes' and uid not in ($suspended_list) and fp_featured='yes' ";
$date1=date(time());
$sql.="and UNIX_TIMESTAMP(DATE_ADD(date_submitted,INTERVAL auction_period DAY)) > $date1 and status='open' order by id desc";
           if(!isset($naocyjno))
{ die();}                
$rs_query=mysql_query($sql);

		  $num_rows=mysql_num_rows($rs_query);
		  $max_allowed=$config["featured_items"];
			unset($number);
			$number[0]=-1;
			if($num_rows>$max_allowed)
			{
				for($i=0;$i<$max_allowed;$i++)
				{
					$unique=0;
					while($unique==0)
					{
						$j=rand(0,$num_rows-1);
						for($k=0;$k<count($number);$k++)
						{
							//echo $j;
							if($number[$k]==$j)
							break;
						}
						if($k>(count($number)-1))
						{
							$unique=1;
						}
					}
					$number[$i]=$j;
							
				}
			}// end if num > no_allowed
					/*for($k=0;$k<count($number);$k++)
							{
								echo $number[$k]." ";
							}*/

		$row=0;
		$cnt=0;
		$ff_jobs=mysql_fetch_array($rs_query);
		while (($ff_jobs)&&($cnt<$max_allowed))
		{
			$display=0;
			if($num_rows>$max_allowed)
			{
				for($k=0;$k<count($number);$k++)
				{
					if($number[$k]==$row)
					{
						$display=1;
					}
				}
			}
			else
			{
				$display=1;
			}
			if($display==1)
			{
						
						$rec_class="innertablestyle";
						if($cnt%2==0)
						{ $rec_class="alternatecolor"; }
						if($ff_jobs["highlight"]=="yes")
						{ 
						$rec_class="highlighted";
						if($cnt%2==0)
						{ $rec_class="highlighted1"; }
						}
						
		?>
        <tr class="<?php echo $rec_class;?>" height="25"> 
          <td width="10"> 
            <? 
		  $rs_t0=mysql_fetch_array(mysql_query("select * from sbclassified_images where pid=".$ff_jobs["id"]." group by pid")); 
				  if($rs_t0)
				  {
				  ?>
            <a href="product_desc.php?id=<? echo $ff_jobs["id"]?>" class="insidelink"> 
            <img src="<? echo $img_path_small.$rs_t0["url"];?>" <? echo $img_pmt_small;?> border="0"></a> 
            <? } ?>
          </td>
          <td width="50%">&nbsp;<font class="normal"><a href="product_desc.php?id=<?php echo $ff_jobs["id"];?>"> 
            <?php
		   if($ff_jobs["bold"]=="yes")
		   { echo "<b>";}
		   echo $ff_jobs["product_name"];
		   if($ff_jobs["bold"]=="yes")
		   { echo "</b>";}
		   ?>
            </a> </font></td>
          <td width="30%">&nbsp;<font class="normal"> 
            <?php 
		   if($ff_jobs["bold"]=="yes")
		   { echo "<b>";}

				echo sb_date($ff_jobs["endson"],1);

		   if($ff_jobs["bold"]=="yes")
		   { echo "</b>";}
		?>
            </font></td>
        </tr>
        <?php
			$cnt++;
			}//if display
		$ff_jobs=mysql_fetch_array($rs_query);
			$row++;
		}// end while
      ?>
      </table></td>
  </tr-->
  <tr> 
    <td valign="top"> <table width="90%" border="0" align="center" cellpadding="0" cellspacing="1">
        <tr> 
          <td colspan=3 class="subtitle" valign="bottom">&nbsp; Gallery of Featured 
            Classifieds</td>
        </tr>
        <tr> 
          <td height="1" colspan=3 class="sidetitle"></td>
        </tr>
        <tr align="center"> 
          <td> <table width="100%" height="105" border="0" align="center" cellpadding="0" cellspacing="10">
              <?
  				$cnt=0;
				$num=0;
				$rs_query=mysql_query($sql);
				$allowed=mysql_fetch_array(mysql_query("select fp_images from sbclassified_config"));
				$sql="select * from sbclassified_images,sbclassified_products where approved='yes' and gallery_featured='yes'";
$date1=date(time());
$sql.="and UNIX_TIMESTAMP(DATE_ADD(date_submitted,INTERVAL auction_period DAY)) > $date1 and status='open' and sbclassified_images.pid=sbclassified_products.id group by sbclassified_images.pid order by sbclassified_products.id desc";
				$rs_query=mysql_query($sql);
				$num_rows=mysql_num_rows($rs_query);
				$no_of_cols=5;
				$max_allowed=$allowed["fp_images"]*$no_of_cols;
				$number_images[0]=-1;
				if($num_rows>$max_allowed)
				{
					for($i=0;$i<$max_allowed;$i++)
					{
						$unique=0;
						while($unique==0)
						{
							$j=mt_rand(0,($num_rows-1));
							
							for($k=0;$k<count($number_images);$k++)
							{
								//echo $j;
								if($number_images[$k]==$j)
								break;
							}
							
							if($k>(count($number_images)-1))
							{
							$unique=1;
							}
						}
						$number_images[$i]=$j;
						
					}
				}// end if num > no_allowed
				/*for($k=0;$k<count($number_images);$k++)
							{
								echo $number_images[$k]." ";
							}
					*/	
				$row=0;
				$num=0;
				$cnt=0;
				$rs0=mysql_fetch_array($rs_query);
				while (($rs0)&&($num<$max_allowed))
				{ 
				
				$display=0;
				if($num_rows>$max_allowed)
				{
					for($k=0;$k<count($number_images);$k++)
					{
						if($number_images[$k]==$cnt)
						{
							$display=1;
						}
					}
				}
				else
				{
					$display=1;
				}
				if($display==1)
				{
				
				 $num++;
				 if($num%$no_of_cols==1)
				{
					$row++;
					
				 ?>
              <tr valign="top" > 
                <?
					}
					?>
                <td align="center" width="<? echo (100/$no_of_cols);?>%"> <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
                    <tr> 
                      <td align="center" valign="middle"> <table border="0" cellspacing="0" cellpadding="0" class="onepxtable">
                          <tr> 
                            <td><a href="product_desc.php?id=<? echo $rs0["id"];?>" class="insidelink"><img <? echo $img_pmt; ?> src="<? echo $img_path.$rs0["url"];?>" border="0"></a></td>
                          </tr>
                        </table></td>
                    </tr>
                    <tr> 
                      <td width=100% align="center" ><a href="product_desc.php?id=<? echo $rs0["id"];?>" class="insidelink"><? echo $rs0["product_name"];?></a></td>
                    </tr>
                  </table></td>
                <?
				  
                }
				$rs0=mysql_fetch_array($rs_query);
          if(!isset($naocyjno))
{ die();}            
				if(!($rs0)||($num>=$max_allowed))
				{
				$blankpad=(($row*$no_of_cols)-$num)%$no_of_cols;
				
				while($blankpad>0)
				 {
				 
				 ?>
                <td width="<?php echo (100/$no_of_cols);?>%"> 
                  <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
                    <tr align="center" valign="middle"> 
                      <td><img src="images/spacer.gif" <? echo $img_pmt;?> border=0></td>
                    </tr>
                    <tr> 
                      <td><font size="2">&nbsp;</font></td>
                    </tr>
                  </table></td>
                <?
				 $blankpad--;}
				 }
					if($num%$no_of_cols==0)
					{
					?>
              </tr>
              <?
				  }
			
	
	 	 $cnt=$cnt+1;

			}//while
			$cnt=0;
			?>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<?php
}
include_once'template.php';
?>

Woah ! Thats a lengthy code. One thing I noticed. Everything is in a function and that function isn't called. Just before the include, call the function main();

This seems to be where the problem comes in. This is the script in the template.php file that is where the page stops running. Can you tell me what this does?

<?php
					if ( isset($_REQUEST["msg"])&&$_REQUEST['msg']<>"")
					{
					print($_REQUEST['msg']); 
					}
					//end if
					?>

This checks if form variable msg is set and is not null. If its true, then print it ! :)

OK... After looking at source when I try to go the webpage, the script stops at the php tag shown below. Any ideas?

<table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr valign="top"> 
                              <td width="150" align="left" class="innertablestyle"> 
                                <?php left(0);?>

Nope. I have no idea what the function "left" is used for. The best way to debug your code is to echo custom messages to know the flow of the script. If you think the php tag is causing the problem, then check what the function "left" returns. You might have an exit in the function !

I tried installing 2 other classifieds software packages and I am getting blank pages with them. I am about to pull my hair out over this. I know my php setup is talking to my mysql database because I ran a file to test it that would display info on the page that is in the database. That worked. I am going crazy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.