Reputation: 437
I have a database with all the data in a base64 string. What I need to do is pull every row from the database, decode it and then update it in the database.
I've written a little script but it only converts one row. How can I get it to run through all rows and convert them?
Here is what I have at the moment:
$result = mysql_query("SELECT * FROM mod_manage_testimonials") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$client_id = $row['client_id'];
$title = base64_decode($row['title']);
$content = base64_decode($row['content']);
$link = base64_decode($row['link']);
$result = mysql_query("UPDATE mod_manage_testimonials SET title='$title',content='$content',link='$link' WHERE client_id='$client_id'")
or die(mysql_error());
}
Upvotes: 1
Views: 258
Reputation: 131871
Don't overwrite the result $result
from the SELECT
-query with the return value of the the UPDATE
-query
$result = mysql_query("UPDATE mod_manage_testimonials SET title='$title',content='$content',link='$link' WHERE client_id='$client_id'") or die(mysql_error());
As far as I can see $result
from the UPDATE
-query has no deeper meaning, so you can just omit it.
mysql_query("UPDATE mod_manage_testimonials SET title='$title',content='$content',link='$link' WHERE client_id='$client_id'") or die(mysql_error());
Upvotes: 1