Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with PHP

    I am very new to PHP and am trying to get a php page that will use the logged_in session variable so they are only given the table data if the user is logged. I was wondering if someone could look at this and let me know what I messed up? I am sure it is something simple. I always seem to forgot a { or put too many {'s. This code was working until I tried to implement the session variable check.

    Thanks

    Here is the code:
    <html>
    <head>
    <title>Find ADSL Customers By Cabinet</title>
    <SCRIPT LANGUAGE="JavaScript" runat=server>
    function updatespeeds(up, down)
    {
    document.speed.up.value = document.speed.up.value + up;
    </head>t>ocument.speed.down.value = document.speed.down.value + down;
    <body>
    <center>
    <img src=images\logo.gif border=0><BR>
    <?
    session_start();

    # We do our own error reporting
    error_reporting(0);

    $cabinet = $_GET['cabinet'];
    $dbhost="localhost";
    $dbuser="xxxx";
    $dbpass="xxxxxx";
    $dbname="adsl";
    $db = mysql_connect("$dbhost", "$dbuser", "$dbpass") or die("<P><H1>Could not connect to mysql");

    $dbhost2="localhost";
    $dbuser2="xxxx";
    $dbpass2="xxxxxx";
    $dbname2="radius";
    $db2 = mysql_connect("$dbhost2", "$dbuser2", "$dbpass2") or die("<P><H1>Could not connect to mysql");
    mysql_selectdb("$dbname", $db);

    if($_SESSION['logged_on'] = '1')
    {
    print "<tr><td align=right valign=bottom bgcolor=#dddddd>Cabinet</td>";
    print "<td align=left valign=bottom bgcolor=#dddddd><form><select name=cabinet onChange=\"submit();\"><option value=\"None\">Select
    Cabinet</option>";
    //Now loop thru cabinets and show the one selected

    $sel_result = mysql_query("select cabinet, code, exchange from cabinet order by code",$db);
    while($sel_row=mysql_fetch_array($sel_result))
    { if ($cab$cabinet = $sel_row[1];
    if ($selprint " SELECTED";t)row[1]\"";
    print ">$sel_row[0]</option>";
    }
    print "</select></form><BR><BR><form name=speed><input type=text readonly name=up value=0 size=10>kb UP&nbsp;<input type=text readon
    ly name=down value=0 size=10>kb DOWN&nbsp;</form></td></tr>";
    print "</table></td></tr></table>";
    ?>
    <b>Note: Click on DSL Phone Number to open up DSL Information</b>
    <br>
    <b>Note: Click on Account Phone Number to open up Accounts Database Information</b><br>
    <br>
    <table border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="#003399">
    <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#DDDDDD">
    <table border=0 cellpadding=3 cellspacing=2><tr>
    <td align=left valign=center bgcolor=#FFFFFF width=175>
    <font size=2 face="Verdana, Arial, Helvetica">
    DSL Phone Number:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Account Phone Number:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Status:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Name:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    IP Address:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Account Type:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Account Plan:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Speed:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    CPE Equipment:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Addt'l Equip:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Equipment Number:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Pair Number:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Shelf:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Pack:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Port:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Feeder VPI:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Feeder VCI:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Sub VPI:</td>
    <td align=left valign=center bgcolor=#FFFFFF>
    <font size=2 face="Verdana, Arial, Helvetica">
    Sub VCI:</td>
    </tr>
    <?
    $sel_result2 = mysql_query("select areacode, prefix, suffix, status, customername, ipaddress, downspeed, modem, equip, pairnum, shel
    f, pack, port, fvpi, fvci, svpi, svci, cabinet, upspeed, customerid, add_equipment from customerdata where cabinet = $cabinet order
    by shelf, pack, port, fvci, status",$db);
    //$sel_row=mysql_fetch_array($sel_result);

    $totdn = 0;
    //Now loop thru account types and show the one selected
    while($sel_row2=mysql_fetch_array($sel_result2))
    {
    $phonenumber="$sel_row2[0]" . "-" . "$sel_row2[1]" . "-" . "$sel_row2[2]";
    //$areacode="$sel_row2[0]";
    //$prefix="$sel_row2[1]";
    //$suffix="$sel_row2[2]";
    $status="$sel_row2[3]";
    $customername="$sel_row2[4]";
    $ipaddress="$sel_row2[5]";
    $downspeed=$sel_row2[6]+=0;
    $modem="$sel_row2[7]";
    $equip="$sel_row2[8]";
    $pairnum="$sel_row2[9]";
    $shelf="$sel_row2[10]";
    $pack="$sel_row2[11]";
    $port="$sel_row2[12]";
    $fvpi="$sel_row2[13]";
    $fvci="$sel_row2[14]";
    $svpi="$sel_row2[15]";
    $svci="$sel_row2[16]";
    $cabinet="$sel_row2[17]";
    //$totup=($totup+=0)+($upspeed+=0);
    //document.speed.up.value = $totup;
    //document.speed.down.value = $totdn;
    $customerid="$sel_row2[19]";
    $add_equipment="$sel_row2[20]";

    mysql_selectdb("$dbname2", $db2);
    $sel_result3 = mysql_query("select customerid, account_plan_id, account_biz_res, areacode, prefix, suffix from customerdata where cu
    stomerid = $customerid",$db2);
    $sel_row3=mysql_fetch_array($sel_result3);
    $customerid="$sel_row3[0]";
    $account_plan_id="$sel_row3[1]";
    $account_biz_res="$sel_row3[2]";
    $radiusphonenumber="$sel_row3[3]" . "-" . "$sel_row3[4]" . "-" . "$sel_row3[5]";
    //$radius_areacode="$sel_row3[3]";
    //$radius_prefix="$sel_row3[4]";
    //$radius_suffix="$sel_row3[5]";

    $sel_result4 = mysql_query("select account_plan from account_plans where account_plan_id = $account_plan_id",$db2);
    $sel_row4=mysql_fetch_array($sel_result4);
    $account_plan="$sel_row4[0]";

    $sel_result5 = mysql_query("select Info from account_biz_res where id = $account_biz_res",$db2);
    $sel_row5=mysql_fetch_array($sel_result5);
    $acctbizres="$sel_row5[0]";

    mysql_selectdb("$dbname", $db);
    $sel_result6 = mysql_query("select status, bgcolor from status where id = $status",$db);
    $sel_row6=mysql_fetch_array($sel_result6);
    $statusnew="$sel_row6[0]";
    $bg_color="$sel_row6[1]";

    print "<tr><td align=left valign=bottom bgcolor=$bg_color><A HREF=http://accounts.etc1.net/dsl/maint_acct.php?customer=$customerid t
    arget=_new>$phonenumber</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color><A HREF=http://accounts.etc1.net/displaycustdetails.php?customer_id=$customeri
    d target=_new>$radiusphonenumber</a></td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$statusnew</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$customername</a></td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$ipaddress</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$acctbizres</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$account_plan</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$upspeed&nbsp;up/$downspeed&nbsp;down</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$modem</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$add_equipment</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$equip</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$pairnum</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$shelf</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$pack</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$port</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$fvpi</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$fvci</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$svpi</td>";
    print "<td align=left valign=bottom bgcolor=$bg_color>$svci</td></tr>";
    print "</table></td></tr></table></td></tr></table><br>";
    print "";
    }
    else {
    print "not logged in";
    }
    mysql_close($db);
    <b>Note: Click on DSL Phone Number to open up DSL Information</b>
    <br>
    <b>Note: Click on Account Phone Number to open up Accounts Database Information</b>
    </body>
    </html>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    First problem is right here:
    <?
    session_start();

    You do not have output buffering enabled, and you cannot send a header with the session after output. Simply move this to the very top of your page.
    If it still doesn't work, can you change your error_reporting to E_ALL and tell us what comes up?

    As well, you should wrap your code in [php] tags, this will kill the problems with smilies

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the quick reply! I moved my session_start to the top and also changed my error reporting to 2047. Here is the error message that I am getting when I try going to the page.

    Parse error: parse error, unexpected T_ELSE in /var/www/dsl2/findcustomer.php on line 200

    The line i have there is as follows:
    </body>


  •  

    Posting Permissions

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