#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    17
    Rep Power
    0

    Updating MySQL not working, but Sessions works fine


    I am trying to update one of my tables to collect a number.
    The Sessions portion works as expected, but nothing is being updated in the database.

    PHP Code:
    function shwAddTaxCertForm(){
                

            
    $retBuffer "";

            
    $con mysql_connect("xxxxxxxxx","xxxx","xxxxxxxx");
                if (!
    $con)
              {
                die(
    'Could not connect: ' mysql_error());
               }

                
    mysql_select_db("xxxx"$con);
        
            if(isset(
    $_POST['Submit'])){
                
    $location mysql_real_escape_string($_POST['inpTaxCertNo']);
                
    $tbl_name="ord_accounts";
                
    $sql="UPDATE $tbl_name SET tax_exempt='$location' WHERE id='$accId'";
                
    $result=mysql_query($sql);
                }

            
    $retCertCode simpleQueryString(gine("inpTaxCertNo"), "");

            if(!empty(
    $retCertCode)){

                if(
    $retCertCode == "remove"){

                    
    $_SESSION['taxcert'] = "";

                    unset(
    $_SESSION['taxcert']);

                    
    header("Location: ?action=ordconf");

                    die(
    "Please continue to: <a href=\"?action=ordconf\">checkout</a>");

                }

                
    $retBuffer .= "

                    <p class=\"genPError\">

                        Tax cert received, please continue with your <a href=\"?action=ordconf\">checkout</a>.

                    </p>"
    ;

                
    $_SESSION['taxcert'] = $retCertCode;

                
    header("Location: ?action=ordconf");

            }
            





            

            
    $retBuffer .= "

                <div class=\"checkoutPageWrapper\">

                    <h2>Florida Tax Exemption Certificate</h2>

                    <form action=\"?action=addtaxcert\" method=\"post\">

                        <div class=\"locListAnnot\" style=\"text-align: center;font-size: 1.15em;\">

                            To place an order with a Florida address without having sales<br />

                            tax added to your order's total, your company must provide an<br />

                            active Florida Resale or Exemption Certificate.<br />

                            <br />

                            Entries will be verified through the <a href=\"http://dor.myflorida.com/dor/gta.html\">Florida Department of Revenue</a><br />

                            website. Customers who's certificates can not be verified will be<br />

                            contacted to verify details before an order may ship.<br />

                            <br />

                            <span style=\"font-size: 0.8em;font-weight: bold;color: #2158A9;\">

                                <label for=\"inpTaxCertNo\">Florida Certificate Number:</label><br />

                            </span>

                            <input type=\"text\" value=\"\" name=\"inpTaxCertNo\" id=\"inpTaxCertNo\" />

                            <br />

                        </div>

                        <div class=\"locListAnnot\" style=\"text-align: center;font-size: 1.15em;\">

                            <br />

                            

                            <input type=\"submit\" id=\"Submit\" name=\"Submit\" style=\"font-size: 1.15em\" value=\"Continue\" /><br />

                            <a href=\"?action=ordconf\">[Cancel]</a><br />

                            <br />

                        </div>

                    </form>

                </div>"
    ;

            

            return 
    $retBuffer;

        } 
    Any suggestions?
    Thanks
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Did you debug this on your own? Did you echo the query to see what could be wrong with it? I'm betting you didn't, since $accID isn't set.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    the variable $accId isn't defined anywhere.

    By the way, the first thing you should do when you have a problem with a query is output the query and see what it actually looks like.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    17
    Rep Power
    0
    Perfect, Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo