ryan king Posted July 13, 2010 Share Posted July 13, 2010 hi, I have recently migrated one mysql database to another. the last thing I need now is images. I have already migrated the image names, ect to the new table from the old. but the old db just had cd/imagename.jpg in the field.. my new database requires that all images be placed in the user id's subdirectory and renamed.. basicly, I just need to move all the images from a directory they are now stored in and put them into the correct user_id subdirectory and rename them.. heres what I have so far.. it echo's the correct results but nothing gets copied, I have all directories permissioned correctly $result = mysql_query("SELECT zoo_products.products_id, jamroom_store.band_id, jamroom_store.item_id, jamroom_store.item_image_name FROM jamroom_store LEFT JOIN zoo_products ON zoo_products.products_id = jamroom_store.item_id ORDER BY jamroom_store.item_id ASC"); while($row = mysql_fetch_array($result)) { rename("../selecto/CD/{$row['item_image_name']}", "../selecto/members/{$row['band_id']}/item_{$row['item_id']}"); echo "<table>"; echo "<tr><td>{$row['item_id']}"; echo "</td>"; echo "<td>{$row['item_image_name']}"; echo "</td>"; echo "<td>{$row['band_id']}"; echo "</td>"; echo "</td></tr>"; } echo "</table>"; ?> it need to go from selecto/cd/imagename.jpg to selecto/members/$BAND_ID/item_$ITEM_ID.jpg Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 13, 2010 Share Posted July 13, 2010 Have you created all of the selecto/members/$BAND_ID directories? If not, rename will not create the directories. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 13, 2010 Share Posted July 13, 2010 Also, add this so you get errors: error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment Share on other sites More sharing options...
ryan king Posted July 13, 2010 Author Share Posted July 13, 2010 Yes, the directories all exists.. I get this error The file ../selecto/CD/090431620229.jpg does not exist Warning: rename(/selecto/CD/090431620229.jpg,/selecto/members/5359/item_5067.jpg) the file 090431620229.jpg is available in the selecto/CD directory and members/5359 directory is also there.. Quote Link to comment Share on other sites More sharing options...
ryan king Posted July 13, 2010 Author Share Posted July 13, 2010 accualy, I take that back..the images are not available.. I had all 5700 of them in there..now it says there are only 307.. so..somewhere along the line..some images got moved..I cant see them in any of the members directories so i dont know where they went..re uploading them now. Quote Link to comment Share on other sites More sharing options...
ryan king Posted July 13, 2010 Author Share Posted July 13, 2010 i figured it out.. at one point the files got moved to the wrong place..then the files where no longer in the folder to move them from..so..re uploaded the files and tried again and voila! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.