[SOLVED] Working with {url_prefix}

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pepper28
Forum Newbie
Posts: 2
Joined: Fri Feb 04, 2005 12:00 pm

[SOLVED] Working with {url_prefix}

Post by pepper28 »

I currently have a database with a table that contains images with are stored as follows:
{url_prefix}/image.php?filename=ps_468x60_1.gif&contenttype=gif

I would like to access this field and replace the {url_prefix} with my domain address http://www.mydomain.com. I only want this change to happen upon a Select request and not through a conversion of the table to include my domain information. The resulting path should look as follows:
http://www.mydomain.com/image.phpfilena ... nttype=gif

Thanks in advance for your help,
Pepper28
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Instead of going through the db and renaming all the strings, you could use PHP to rename the photo on every access of the field. Something like:

Code: Select all

// $string = url string

$new_string=explode("/", $string);

// rebuild the string with your new domain

$new_domain_url="http://www.mydomain.com/".$new_stringї3];
I haven't tested this, but I've done similar.
pepper28
Forum Newbie
Posts: 2
Joined: Fri Feb 04, 2005 12:00 pm

{url_prefix}

Post by pepper28 »

Thanks Voltrader,

Your recommendation works great! I was racking my brain for a few days trying to figure out how to do what you suggested.

Thanks agaian very much!

Pepper28
Post Reply