try str_replace and replace the commas and dollars signs with nothing ""


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
>
> -- 
> Thank you,
> Grant
>
> [Non-text portions of this message have been removed]
>
> 


[Non-text portions of this message have been removed]

Reply via email to