Are you actually getting any rows returned? That error message suggests 
a problem with accessing the results set - there are much simpler ways 
of doing it than what you have here, such as mysql_fetch_array.

In any event, you need give to the update query a 'where' clause such as 
the primary key of the record you are trying to update.

PT


Grant wrote:
> Anyone know how to remove commas or other characters in a string? I've
> imported data from a CSV and it has commas in the price field. For example,
> I want $1,200 to become simply "1200".  I keep getting that generic error
> message which says" mysql_result(): supplied argument is not a valid MySQL
> result resource". I've spent about 3 hours trying to figure this out. I've
> never used the str_replace() function. I realize my code doesn't remove the
> "$" yet. I'm just trying to get one thing working for now.
> 
> $query = "SELECT * FROM tblData";
> $result = mysql_query($query);
> $totalrows = mysql_num_rows($result);
> echo "there are $totalrows records<br></br>";
> 
> $rowID = 0;
> while ($rowID < $totalrows) {
>  $listPrice = mysql_result($result, $rowID, "listPrice");
> 
> $strippedOfCommas = str_replace(",","", $listPrice);
> $newFormattedListPrice = $strippedOfCommas;
> 
> $query = "UPDATE tblData SET listPrice='$newFormattedListPrice'";
> $result = mysql_query($query);
> $rowID++;
>      } //end of while condition
> 

Reply via email to