Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What am I doing Wrong? - MySQL Call

Status
Not open for further replies.

zinja

MIS
Nov 14, 2002
149
US
I am trying to update four fields of a record. The fields and the data types in the table are as follows:

sold (tinyint 1)
solddate (varchar 10)
soldprice (float 10,2)
soldagency (varchar 25)

Here is the sql I am using:
Code:
      // Create a mysql query
        $sql = 'UPDATE '. PROPERTIES_TABLE .
        ' SET sold = 1, solddate = "' . $form['solddate'] . '",
		 soldprice = "' . $form['soldprice'] . '", 
		 soldagency = "' . $form['soldagency'] . '" 
		 WHERE id = "' . intval($_GET['id']) . '"';

        $db->query($sql) or error ('Critical Error', mysql_error ());

Here is the section of the form:

Code:
   echo userform ('Sold Date (YYYY-MM-DD)', '<input type="text" size="45" name="solddate" value="' . $form['solddate'] . '" maxlength="255">');
    echo userform ('Sold Price', '<input type="text" size="45" name="soldprice" value="' . $form['soldprice'] . '" maxlength="255">');
    echo userform ('Sold Agency', '<input type="text" size="45" name="soldagency" value="' . $form['soldagency'] . '" maxlength="255">');


The form is not posting errors, but the record doesn't get updated. Nothing happens to the record at all.

Any advice?


LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
The first thing you are doing wrong is using floats for money. floats are inexact representations of their values, so MySQL provides the decimal type, which is greatly recommended over float.


Next, what's $form? Typically, form-submitted variables in PHP will be found in $_POST or $_GET for POST- or GET-method forms, respectively.


Want the best answers? Ask the best questions! TANSTAAFL!
 
And as I have pointed out in my FAQ in this forum, titled "Debugging PHP" (faq434-2999), you should try printing out your query top verify what it looks like. Then try copy-and-pasting the query into some MySQL management tool to see how well it works.


Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top