Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2003
    Posts
    137

    Unanswered: problem reading a URL

    I am using this code to read the URL but getting an error:

    <?
    <?
    $billing_sql = "SELECT billing.* FROM billing WHERE account_id = ".$_GET['account']." AND amount >= 0 ORDER BY start_date_time desc LIMIT 12";
    $billing_result = pg_exec($pg_connection, $billing_sql);

    if(!$billing_result || (pg_num_rows($billing_result) < 1))
    {
    header('Location: index.php');
    }
    ?>



    this is the error:

    Warning: Cannot modify header information - headers already sent by (output started at /var/www/jassim.tmp.2connectbahrain.com/www/my2connect.php:26) in /var/www/jassim.tmp.2connectbahrain.com/www/my2connect.php on line 106

  2. #2
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    The most common reason for this error message is that something in your code (at or around line 26) is sending output to the browser.

    Could you post the code starting a few lines before line 26 through to a few lines after line 26...

  3. #3
    Join Date
    Apr 2003
    Posts
    137
    HERE IS THE FULL PAGE:


    <?
    session_start();

    $pg_connection = pg_connect("dbname=ivr_db_ro user=ivr_fakhro host=www.2connect.com password=xxxxxxx");
    $accounts_sql = "SELECT * FROM accounts where customer_id = '".$_SESSION['customer_id']."'";
    $accounts_result = pg_exec($pg_connection, $accounts_sql);

    if(!$accounts_result || (pg_num_rows($accounts_result) < 1))
    {
    header('Location: index.php');
    }
    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <link rel="STYLESHEET" type="text/css" href="2connect_stylesheet.css">
    <title>my2connect2.com</title>
    </head>

    <body dir="ltr" lang="en-us" topmargin="0" leftmargin="0" bottommargin="0" rightmargin="0">

    <table dir="ltr" lang="en-us" align="left" width="960" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td align="left"><img src="images/page_header.jpg" alt="" width="950" height="122" border="0"><br><br></td>
    </tr>
    <tr>
    <td align="left">
    <table dir="ltr" lang="en-us" align="center" width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td align="left" valign="top" style="padding-top: 10px; padding-bottom: 10px; padding-right: 10px; padding-left: 10px">
    <? echo $_SESSION['login_test']; ?><br>
    <? echo $_GET['account']; ?><br>
    <img src="images/my2connect_title.jpg" alt="" border="0"><br>
    <img src="images/my2connect_banner.jpg" alt="" border="0">
    <br><br>
    <table width="500" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td align="center" valign="top"><img src="images/personal_profile.jpg" alt="" width="48" height="48" border="0"><br><br><font size="-1">Personal Profile</font></td>
    <td align="center" valign="top"><img src="images/refill_account.jpg" alt="" width="48" height="48" border="0"><br><br><font size="-1">Refill your Account</font></td>
    </tr>
    <tr>
    <td align="center" valign="top"><br></td>
    <td align="center" valign="top"><br></td>
    </tr>
    <tr>
    <td align="center" valign="top"><img src="images/technical_support.jpg" alt="" width="48" height="48" border="0"><br><br><font size="-1">Technical Support</font></td>
    <td align="center" valign="top"><img src="images/change_password.jpg" alt="" width="48" height="48" border="0"><br><br><font size="-1">Change your Password</font></td>
    </tr>
    </table>
    </td>
    <td align="left" valign="top">
    <img src="images/my_account_details_title.jpg" alt="" width="320" border="0">
    <table dir="ltr" lang="en-us" width="320" cellspacing="0" cellpadding="0" border="0">
    <tr style="padding-top: 5px; padding-bottom: 5px; padding-right: 5px; padding-left: 5px">
    <td valign="top" width="100%">
    <table dir="ltr" lang="en-us" width="100%" cellspacing="0" cellpadding="0" border="1" bordercolorlight="#C0C0C0">
    <tr>
    <td align="center" bgcolor="#C0C0C0" colspan="2"><font size="-1">2Call Accounts</font></td>
    <td align="center" bgcolor="#C0C0C0"><font size="-1">Credit (BD)</font></td>
    </tr>
    <?
    // process results
    for ($i = 0; $i < pg_num_rows($accounts_result); $i++)
    {
    $account_id = pg_result($accounts_result, $i, 0);
    $account_number = pg_result($accounts_result, $i, 1);
    $sequence_number = pg_result($accounts_result, $i, 6);
    $account_balance = pg_result($accounts_result, $i, 15);
    ?>
    <tr>
    <td align="center"><img src="images/details_icon_only.jpg" alt="" border="0"></td>
    <td align="center"><font size="-1"><? print("$account_number"); ?></font></td>
    <td align="center"><font size="-1"><? print(number_format("$account_balance", 3)); ?></font></td>
    </tr>
    <?
    }
    ?>
    </table>
    </td>
    </tr>
    <tr style="padding-top: 5px; padding-bottom: 5px; padding-right: 5px; padding-left: 5px">
    <td valign="top" width="100%">
    <table dir="ltr" lang="en-us" width="100%" cellspacing="0" cellpadding="0" border="1" bordercolorlight="#C0C0C0">
    <tr>
    <td align="center" bgcolor="#C0C0C0"><font size="-1">Recent Calls</font></td>
    <td align="center" bgcolor="#C0C0C0"><font size="-1">Date</font></td>
    <td align="center" bgcolor="#C0C0C0"><font size="-1">Amount (BD)</font></td>
    </tr>
    <?
    // if ($HTTP_GET_VARS['account'])
    // {
    $billing_sql = "SELECT billing.* FROM billing WHERE account_id = ".$_GET['account']." AND amount >= 0 ORDER BY start_date_time desc LIMIT 12";
    // {
    // else
    // {
    // $billing_sql = "SELECT billing.* FROM billing WHERE account_id = 105 AND amount >= 0 ORDER BY start_date_time desc LIMIT 12";
    // }

    // $illing_sql = "SELECT billing.billing_id, billing.detail, billing.start_date_time, billing.amount FROM customers INNER JOIN (accounts INNER JOIN billing ON accounts.account_id = billing.account_id) ON customers.customer_id = accounts.customer_id WHERE customers.customer_id = 84";
    $billing_result = pg_exec($pg_connection, $billing_sql);

    if(!$billing_result || (pg_num_rows($billing_result) < 1))
    {
    header('Location: index.php');
    }

    for ($i = 0; $i < pg_num_rows($billing_result); $i++)
    {
    $billing_id = pg_result($billing_result, $i, 0);
    $billing_detail = pg_result($billing_result, $i, 21);
    $billing_date_time = pg_result($billing_result, $i, 7);
    $billing_amount = pg_result($billing_result, $i, 28);
    ?>
    <tr>
    <td align="center"><font size="-1"><a href="mycalls.php?id=<?= $billing_id ?>"><? print("$billing_detail"); ?></a></font></td>
    <td align="center"><font size="-1"><? print(substr($billing_date_time, 8, 2)."/".substr($billing_date_time, 5, 2)."/".substr($billing_date_time, 0, 4)." ".substr($billing_date_time, 11, 5)); ?></font></td>
    <td align="center"><font size="-1"><? print(number_format("$billing_amount", 3)); ?></font></td>
    </tr>
    <?
    }
    ?>
    </table>
    </td>
    </tr>
    <tr style="padding-top: 5px; padding-bottom: 5px; padding-right: 5px; padding-left: 5px">
    <td valign="top" width="100%">
    <table dir="ltr" lang="en-us" width="100%" cellspacing="0" cellpadding="0" border="1" bordercolorlight="#C0C0C0">
    <tr>
    <td align="center" bgcolor="#C0C0C0"><font size="-1">Recent Payments</font></td>
    <td align="center" bgcolor="#C0C0C0"><font size="-1">Amount (BD)</font></td>
    </tr>
    <?
    $billing_sql = "SELECT * FROM billing WHERE account_id = 105 AND amount < 0 ORDER BY start_date_time desc LIMIT 12";
    $billing_result = pg_exec($pg_connection, $billing_sql);

    if(!$billing_result || (pg_num_rows($billing_result) < 1))
    {
    header('Location: index.php');
    }

    for ($i = 0; $i < pg_num_rows($billing_result); $i++)
    {
    $billing_id = pg_result($billing_result, $i, 0);
    $billing_detail = pg_result($billing_result, $i, 21);
    $billing_date_time = pg_result($billing_result, $i, 7);
    $billing_amount = pg_result($billing_result, $i, 28) / 1000;
    ?>
    <tr>
    <td align="center"><font size="-1"><? print(substr($billing_date_time, 8, 2)."/".substr($billing_date_time, 5, 2)."/".substr($billing_date_time, 0, 4)); ?></font></td>
    <td align="center"><font size="-1"><? print(number_format("$billing_amount", 3)); ?></font></td>
    </tr>
    <?
    }
    ?>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td align="center"><br><img src="images/footer.jpg" alt="" border="0"></td>
    </tr>
    </table>

    </body>
    </html>

  4. #4
    Join Date
    Apr 2006
    Location
    Denver, Co. USA
    Posts
    242
    You need to reconsider the logic of this page. You are outputting HTML content to the browser then performing database queries and redirecting to another page if there are no results from the query.

    ANY output to the browser will prevent the header(...) statement from working and cause the error message you are getting. You have a header() statement in two places after the start of the output to the browser.

    The following is the start of the HTML, you cannot use header() statements anywhere after this point in the file -
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Posting Permissions

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