SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    undefined index/variable

    what is wrong with the below code re. the rate? the invno works in the program I'm using this in.


    PHP Code:
    <?php  
    mysql_connect
    ("localhost","root","");   
    mysql_select_db('numbersdb') or die( "Unable to select database");   
    if(!empty(
    $_POST["submit"]))   
    {   
    $invno $_POST['invno'];   
    $rate $_POST['rate'];   
    }   
    mysql_query("UPDATE numbdata SET invno=invno+1");   
    $result=mysql_query("select invno from numbdata") or die ("Error - could not retrieve invoice# from database");  
    $data=mysql_fetch_assoc($result);  
    mysql_close();  
    ?>

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Show us your form.

    PS: Might want to not broadcast the fact that you're using that particular username and password combination for your database.

  3. #3
    SitePoint Zealot
    Join Date
    Jun 2010
    Posts
    108
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the posted code, an include , "getinvno.php" is used in a subsequent program using the invno and the rate. I am posting the code that uses it, here.

    PHP Code:
    <?php
    include("getinvno.php");
    mysql_connect("localhost","root","");
    mysql_select_db('posdb') or die( "Unable to select database");
    $query=" SELECT * FROM postable WHERE sellqty > 0";
    $result=mysql_query($query);
    $num=mysql_num_rows($result);
    echo 
    date("m/d/Y") . "<br />";
    echo 
    "<center><font size=+2><b> Kirk Pawn, Gun & Archery</font><br />";
    echo 
    "9921 Old Bearskin Rd<br />";
    echo 
    "Hunters Den, Alabama  32145<br /></center>";
    echo 
    "customer# ".$data['invno'];
    echo 
    " </b><br />";
    echo 
    "<table cellspacing=5 cellpadding=0 border=0>
    <tr>
    <th align=left>sell</th>
    <th colspan=2></th>
    <th>unit</th>
    <th></th>
    <th></th>
    <tr>
    <th align=left>qty</th>
    <th>item#</th>
    <th>item</th>
    <th>price</th>
    <th>charge</th>
     </tr>"
    ;
    while(
    $row mysql_fetch_array($result))
    {
    $amtdue $row['unitprice'] * $row['sellqty'];
    $tax $amtdue $data['rate'];  
    $tottax $tottax $tax
    $totdue $totdue $amtdue
    $totdue $totdue $tottax;
    echo 
    "<tr>";
    echo 
    "<td>" $row['sellqty'] . "</td>";
    echo 
    "<td>" $row['itemno'] . "</td>";
    echo 
    "<td>" $row['itemdescr'] . "</td>";
    echo 
    "<td align=right>" $row['unitprice'] . "</td>";
    echo 
    "<td align=right>" sprintf("%.2f",$amtdue) .
    "</td>"
    }
    echo 
    "<tr>";
    echo 
    "<td>Tax</td>";
    echo 
    "<td></td>";
    echo 
    "<td></td>";
    echo 
    "<td></td>";
    echo 
    "<td align=right>" sprintf("%.2f",$tottax) .
    "</td>";   
    echo 
    "<tr>";
    echo 
    "<td>Total</td>";
    echo 
    "<td></td>";
    echo 
    "<td></td>";
    echo 
    "<td></td>";
    echo 
    "<td align=right>" sprintf("%.2f",$totdue) .
    "</td>";
    echo 
    "</tr>";
    echo 
    "</table>";
    echo 
    "<tr>";
    echo 
    "<font size=+1><b>We thank you for your business</b>";
    mysql_close();
    ?>

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    You still havent shown me your form. I need to see what's supposed to be filling $_POST['rate'], not what you do with it afterwards..


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
  •