I have about 230 photos in a database, all along I have been putting http://domain.com/path/to/image.jpg. I am trying to enable a thumbnail script and it will not work with the http://domain.com on the front of the url. Is there a way I can run a script to go through and delete all of these?

I have all my photos in a table named "photos" with the url in a cell named "path" Maybe there is a script that can call on all the photos and remove that part then overwrite the current path on all the images.

Thanks,
Brian

Recommended Answers

use update query to replace that string.
Assume photos is your table and imageurl is your field..
Take backup of your table before update all these..
try this:

update photos set imageurl = replace(imageurl,'
Jump to Post

All 3 Replies

You could use a simple PHP SELECT and UPDATE

For example:

<?
include("databasefile.php");

$query = mysql_query("SELECT * FROM `phototable` ORDER BY `id` ASC");
while($fetch = mysql_fetch_array($query)){
// We get all images in the table by the primary key in this case id

$id = $fetch;
//collect the id or if you are using the image name as the file name then change that

$newurl = "path/to/$id.jpg";
$update = mysql_query("UPDATE `imagetable`
SET `url`='$newurl' WHERE `id`='$id'");
}
echo"All done! you can now delete this file or script";
?>

I hope that helps and was easy to understand :)

use update query to replace that string.
Assume photos is your table and imageurl is your field..
Take backup of your table before update all these..
try this:

update photos set imageurl = replace(imageurl,'http://domain.com/','')

If you dont' want to update in your database..
then try some php string functions str_ireplace() to replace that string in image path..

wow, that worked great. thanks man!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.