UBB.Dev
Posted By: HunterGSXR help with UPDATE query. - 03/15/2003 9:36 PM
i having trouble figuring this one out.

i want to be able to update the location of users pictures.

so in w3t_Users i already have a bunch or records that have values like this.

U_Picture = 'http://www.gixxer.com/uploads/582.gif'

how can i update every occurance of "http://www.gixxer.com/uploads/" with "http://www.gixxer.com/avatars/" while leaving the image names alone.

thanks for any help.
Posted By: dimopoulos Re: help with UPDATE query. - 03/16/2003 1:12 AM
You can certainly do it with a php script

Without having compiled and tested it:
Code
 <br />$strQuery = ""; <br />$strUpdate = ""; <br />$strQuery = "SELECT U_Number, U_Picture FROM w3t_Users"; <br />$sth = $dbh -> do_query($strQuery); <br />while ( list ( $lngNumber, $strPicture ) = $dbh -> fetch_array ( $sth ) ) <br />{ <br />if ( !empty( $strPicture ) ) <br />{ <br />$strNewPicture = str_replace( "/uploads/", "/avatars/", $strPicture ); <br />$strUpdate = "UPDATE w3t_Users SET U_Picture = '$strNewPicture' WHERE U_Number = '$lngNumber'"; <br />$dbh -> do_query ( $strUpdate ); <br />} <br />} <br />$dbh -> finish_sth( $sth ); <br />


Make sure you include the main.inc.php library at the top.
Posted By: HunterGSXR Re: help with UPDATE query. - 03/16/2003 3:32 AM
thanks. worked well.
Posted By: dimopoulos Re: help with UPDATE query. - 03/16/2003 4:59 AM
Did it? Damn! Now I know that the compiler in my brain still works LOL
© UBB.Developers