So, this is the only issue I am having left to fix on my site. When it fetches a post from the database and is then called to parse/replace the URL as a it has a problem. The problem is only with duplicates or image names containing a space in them.
$result = mysql_query("SELECT * FROM posts ORDER BY postid DESC");
while($row = mysql_fetch_array($result))
{
$str = $row['post_content'];
$str = preg_replace_callback('#(?:https?://\S+)|(?:www.\S+)|(?:\S+\.\S+)#', function($arr)
{
if(strpos($arr[0], 'http://') !== 0)
{
$arr[0] = 'http://' . $arr[0];
}
$url = parse_url($arr[0]);
// images
if(preg_match('#\.(png|jpg|gif)$#', $url['path']))
{
return '<img src="'. $arr[0] . '" /><br /><br />';
}
Here is what it does for the first uploaded image:
http://domain.com/server/php/files/filename.jpg
Here is what it does for the second uploaded image:
http://domain.com/server/php/files/filename http://(1).jpg
I need to either control the naming convention for how names the file or control how it reads the spaces in the URL.