SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query was empty error

    When I test the code that is below it is displays this message: Could not update the entry because: Query was empty. The query was . Can someone please help me solve the error? Thanks in advance.

    PHP Code:
    $insert "INSERT INTO `clearingsales` (`selectDay`, `selectDate`, `selectMonth`, `selectYear`, `propertyname`, `time`, `ampm`, `accountname`, `comments`, `select1`, `txt1`, `select2`, `txt2`, `select3`, `txt3`, `select4`, `txt4`, `select5`, `txt5`, `select6`, `txt6`, `select7`, `txt7`, `select8`, `txt8`, `select9`, `txt9`, `select10`, `txt10`, `select11`, `txt11`) VALUES ('$selectDay', '$selectDate', '$selectMonth', '$selectYear', '$propertyname', '$time', '$ampm', '$accountname', '$comments', '$select1', '$txt1', '$select2', '$txt2', '$select3', '$txt3', '$select4', '$txt4', '$select5', '$txt5', '$select6', '$txt6', '$select7', '$txt7', '$select8', '$txt8', '$select9', '$txt9', '$select10', '$txt10', '$select11', '$txt11')";
        if (
    mysql_query ($insert)) {
            if ((
    $select1 == 'other') && (!empty($other1))) {
                
    $update "UPDATE clearingsales SET select1 = '$other1' WHERE propertyname = '$propertyname'";            
            }
            if (
    mysql_query ($update)) {
                
    header ("Location: clearing_sale_added.php");
            } else {
                print 
    "<p>Could not update the entry because: <b>" mysql_error() . "</b>. The query was $update.</p>";
            }
        } else {
            print 
    "<p>Could not add the entry because: <b>" mysql_error() . "</b>. The query was $insert.</p>";
        } 

  2. #2
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Kansas City, MO
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You only set the $update query condtionally
    PHP Code:
    if (($select1 == 'other') && (!empty($other1))) {
                
    $update "UPDATE clearingsales SET select1 = '$other1' WHERE propertyname = '$propertyname'";            
            } 
    If that statement evals to false, $update is never set to anything and you have an empty query.

  3. #3
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay how do I update a row when someone has entered data into the other text box that appears after that someone has selected an option in a combo box within having the query was empty error?


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
  •