PT,

I discovered that Mysql has a way of doing the same thing. I used the
replace() function in MySQL

$query = "UPDATE tblRentalsImport set listPrice =
replace(listPrice,',','')";

I really want to understand the PHP function for str_replace(), but I'm
going to go back to that when I have more time. This is primarily for a
business solution for myself, and after several hours, I had to move on to
the next task since I found a suitable solution. However, I believe that you
answered the question because I did NOT have the WHERE clause in my update
query. That likely explains my dilemma.

Thanks,
Grant

On Sun, Apr 4, 2010 at 4:51 AM, PapaTango <papa_tango_1...@yahoo.co.uk>wrote:

>
>
> 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
> >
>
> 
>



-- 
Grant S. Pollet, REALTOR
Austin TX


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



------------------------------------

The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning. Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/php_mysql/join
    (Yahoo! ID required)

<*> To change settings via email:
    php_mysql-dig...@yahoogroups.com 
    php_mysql-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    php_mysql-unsubscr...@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to