SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    header("Location:"

    I have a script where has this code after includes:

    {
    $cat_query=mysql_query("Select * from sbbleads_categories where sb_pid=" . $_REQUEST["cid"]);
    $rs=mysql_num_rows($cat_query);

    if(($rs<=0)||($_REQUEST["cid"]==0))
    {
    header("Location:"."cat_sell.php?cid=".$_REQUEST["cid"]); die();
    }
    }

    I did mod rewrite and it works fine on index page: After I try to access to other links on site it says:

    Warning: Cannot modify header information - headers already sent by .....

    or it returns a blank 404 page.

    Do anyone can help with this. I doubt that there's some major change in code but since I'm new in PHP this is hard to me to resolve.

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    San Diego, CA (USA)
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you paste all of the lines of code above what you posted? some information is obviously being outputted before it should be...

  3. #3
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put an ob_start(); at the top of your script before any output.

  4. #4
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?
    include_once "myconnect.php";
    include_once "date_time_format.php";

    if(isset($_REQUEST["cid"]))
    {
    $cat_query=mysql_query("Select * from sbbleads_categories where sb_pid=" . $_REQUEST["cid"]);
    $rs=mysql_num_rows($cat_query);

    if(($rs<=0)||($_REQUEST["cid"]==0))
    {
    header("Location:"."cat_sell.php?cid=".$_REQUEST["cid"]);
    die();
    }
    }

    function main()
    {
    $keyword="";
    if(isset($_REQUEST["keyword"])&&($_REQUEST["keyword"]<>""))
    {
    $keyword=$_REQUEST["keyword"];
    }

    $config=mysql_fetch_array(mysql_query("select * from sbbleads_config"));
    if(($config["sb_image_magik"]=="enable"))
    {
    $img_path="thumbs1/";
    $img_pmt="";
    }
    else
    {
    $img_path="uploadedimages/";
    $img_pmt="width=".$config["sb_th_width"]." height=".$config["sb_th_width"];
    }

    $cid=0;
    if(isset($_REQUEST["cid"])&&($_REQUEST["cid"]<>"")) {
    $cid=$_REQUEST["cid"];
    $sbqu_off="update sbbleads_categories set sb_visit_sell=sb_visit_sell+1 where sb_id=$cid";
    mysql_query($sbqu_off);
    }

    /*$sell_num=mysql_num_rows(mysql_query("select * from sbbleads_offers where sb_approved='yes'"));
    $buy_num=mysql_num_rows(mysql_query("select * from sbbleads_offers_buy where sb_approved='yes'"));
    $product_num=mysql_num_rows(mysql_query("select * from sbbleads_products where sb_approved='yes'"));
    $profile_num=mysql_num_rows(mysql_query("select * from sbbleads_companyprofiles where sb_approved='yes'"));*/

    $catname="";
    $category=0;

    $cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $cid );
    if ($cat=mysql_fetch_array($cat_query))
    {
    $catname=$cat["sb_cat_name"];
    $category=$cat["sb_id"];
    }

    $catpath="";
    $cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $cid );
    while ($rs=mysql_fetch_array($cat_query))
    {
    $catpath =" > <a href=\"cat_sell/cid/" . $rs["sb_id"] . ".html" . "\">" .$rs["sb_cat_name"]."</a>".$catpath;
    $cat_query=mysql_query("Select * from sbbleads_categories where sb_id=" . $rs["sb_pid"] );
    }

    function redirect($url = NULL, $relative = FALSE) {
    header("Location: http://".$_SERVER['HTTP_HOST'].(($relative) ? dirname($_SERVER['PHP_SELF'])."/" : "/").$url);
    exit;
    }

    ?>

    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber5">
    <tr>
    <td width="100%">

    <!-- top nav -->

    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
    <tr>
    <td align="left"><font class="normal">&nbsp;<a href="index.php">Home</a><? echo $catpath;?></font></td>
    <td align="right"><a class="linkstyle2" href="post_offer.php">Post Sell Offer</a></td>
    </tr>
    <tr>
    <td colspan="2" height="10"></td>
    </tr>

    <tr>
    <td colspan="2"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="titlestyle">
    <tr>
    <td align="center" valign="middle" >↓ &nbsp;Sell Offers</td>
    <td align="center" valign="middle" class="subtitle" >→ &nbsp;<a href="cat_buy/cid/<?php if($cid<>0) echo "".$cid;?>.html">Buy Offers</a></td>
    <td align="center" valign="middle" class="subtitle" >→ &nbsp;<a href="cat_products/cid/<?php if($cid<>0) echo "".$cid;?>.html">Product Catalogs</a></td>
    <td align="center" valign="middle" class="subtitle" >→ &nbsp;<a href="cat_profiles/cid/<?php if($cid<>0) echo "".$cid;?>.html">Companies</a></td>
    </tr>
    </table></td>
    </tr>
    </table>

    <br>
    <!-- top nav -->
    </td></tr>

    <tr>
    <td width="100%">


    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#C0C0C0" width="100%" id="AutoNumber6">
    <tr>
    <td width="100%">




    <!-- Browse Sell Offers -->

    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber26">
    <tr>
    <td width="5%" background="images/title_bg.gif"><b>
    <img border="0" src="images/right_corner.gif" width="20" height="21"></b></td>

    <?
    if(isset($_REQUEST["cid"])&&($_REQUEST["cid"]<>"")) {
    ?>
    <td width="26%" background="images/title_bg.gif" valign="middle">
    <font color="#FFFFFF"><b>Browse Sell Offers</b></font></td>
    <td width="66%" align="right" background="images/title_bg.gif" valign="middle">
    <font color="#FFFFFF"><b><a href="selloffers/cid/<?=$cid?>.html">See All Sell Offers in <?=$catname?></a></b></font></td>
    <?
    } else {
    ?>
    <td width="92%" background="images/title_bg.gif" valign="middle">
    <font color="#FFFFFF"><b>Browse Sell Offers</b></font></td>
    <?
    }
    ?>
    <td width="4%" background="images/title_bg.gif">
    <img border="0" src="images/left_corner.gif" width="20" height="21"></td>
    </tr>
    </table>

    </td>
    </tr>

    <tr>
    <td width="100%" bgcolor="#F8F8F8">
    <table border="0" cellpadding="6" cellspacing="6" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber7">
    <tr>
    <td width="100%">
    <table border="0" cellpadding="3" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber8" cellspacing="3">


    <?

    $cats_sql="select * from sbbleads_categories where sb_pid=$cid ";
    if($config["sb_cat_listing"]=="alpha")
    {
    $cats_sql.=" order by sb_cat_name";
    }
    else
    {
    $cats_sql.=" order by sb_order_index";
    }
    $cats_query=mysql_query($cats_sql);
    $cnt=1;

    while($cats=mysql_fetch_array($cats_query))
    {
    $rst_query=mysql_query("Select * from sbbleads_categories where sb_pid=".$cats["sb_id"] );
    $clist=$cats["sb_id"];
    while ( $rst=mysql_fetch_array($rst_query) ) {
    $clist.="," . $rst["sb_id"];
    $thislist="-1," . $rst["sb_id"];
    while ( $rst=mysql_fetch_array($rst_query) )
    {
    $clist.="," . $rst["sb_id"];
    $thislist.="," . $rst["sb_id"];
    //echo $rst["sbcat_id"];
    }
    $rst_query=mysql_query("Select * from sbbleads_categories where sb_pid in (" . $thislist . ")" );
    }

    $sbcat_str= " and sb_cid IN (" .$clist . ")" ;

    $sbq_off_cat="select * from sbbleads_offer_cats, sbbleads_offers where sb_approved='yes' and sbbleads_offers.sb_id=sbbleads_offer_cats.sb_offer_id and DATE_ADD(sb_postedon,INTERVAL ".$config["sb_expiry_sell"]." MONTH) > NOW() $sbcat_str";
    $sboff_count=mysql_num_rows(mysql_query($sbq_off_cat));

    $sbq_buy_cat="select * from sbbleads_offer_cats_buy, sbbleads_offers_buy where sb_approved='yes' and sbbleads_offers_buy.sb_id=sbbleads_offer_cats_buy.sb_offer_id and DATE_ADD(sb_postedon,INTERVAL ".$config["sb_expiry_buy"]." MONTH) > NOW() $sbcat_str";
    $sbbuy_count=mysql_num_rows(mysql_query($sbq_buy_cat));

    $sbq_product_cat="select * from sbbleads_product_cats, sbbleads_products where sb_approved='yes' and sbbleads_products.sb_id=sbbleads_product_cats.sb_offer_id $sbcat_str";
    $sbproduct_count=mysql_num_rows(mysql_query($sbq_product_cat));

    $sbq_profile_cat="select * from sbbleads_profile_cats, sbbleads_companyprofiles where sb_approved='yes' and sbbleads_companyprofiles.sb_id=sbbleads_profile_cats.sb_profile_id $sbcat_str";
    $sbprofile_count=mysql_num_rows(mysql_query($sbq_profile_cat));
    $sbtotal=$sboff_count;//$sboff_count+$sbbuy_count+$sbproduct_count+$sbprofile_count;
    //die();
    if($cnt%2==1)
    {
    ?>
    <tr>
    <?
    }
    ?>
    <td width="7"><img border="0" src="images/red_arrow.gif" width="10" height="10"></td>
    <td><a href="cat_sell/cid/<? echo $cats["sb_id"];?>.html"><? echo $cats["sb_cat_name"]; ?></a>&nbsp;(<? echo $sbtotal; ?>)</td>

    <?
    if($cnt%2==0)
    {
    ?>
    </tr>
    <?
    }
    $cnt++;
    }
    ?>


    </table>
    </td>
    </tr>
    </table>


    <!-- End Browse Sell Offers -->
    </td>

    </tr>
















    <!-- Featured - Sub Cats Based -->
    <?
    # if category selected
    if((isset($_REQUEST["cid"]) & ($_REQUEST["cid"]<>"")) & ($_REQUEST["cid"]!=0)) {
    include("templates/cat_sell_featured.php");
    # echo "</td></tr><tr><td>";
    # include("templates/latest_sell_offers.php");
    }
    else {
    # if top nav - sell offers selected.. (no category selected)
    # then show latest mixed sell offers as home page
    include("templates/latest_sell_offers.php");
    }
    ?>

    <!-- End Featured - Sub Cats Based -->

    </table>
    </td>
    </tr>
    </table>

    <?
    }// end main
    include "template.php";
    ?>

  5. #5
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    SitePoint Member
    Join Date
    Jun 2005
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found a solution but anyway thanks.

  7. #7
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You should post the solution for others to learn from.

  8. #8
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To use the header function you must have not output any HTML to the web page.

    Hope that helps.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •