tags:

views:

37

answers:

1

Hello all,

I have just uploaded an image to imageshack using their API and I am trying to save that image path that I get back from imageshack.

$mgr->setUploadUrl('http://www.imageshack.us/index.php');

$fileImagePath = $row['cr_path'];

echo $fileImagePath.'<br><br>';

$res =  $mgr->upload($row['cr_path'], 'image/jpeg', 'avaojo');

$newImagePath = explode(' ', $res);

$shackPath = trim($newImagePath[6]);

echo '>>>'.$shackPath.'<<<';
//Outputs >>>http://img194.imageshack.us/img194/5038/9444679.jpg&lt;&lt;&lt;

$sql = "UPDATE avatar SET image_path = '$shackPath' WHERE avatar_id =".$row['cr_id'];

However, when I view my MySQL database it wraps around the URL string with <image_link></image_link> tags?

What the hell is going on? I looked everywhere and in my script nothing resets the $shackPath variable. In fact, the insertion and the trimming of $newImagePath are only 3 lines away and nothing happens in between that!

Thanks all

+4  A: 

That's because $shackPath contains the <image_link> tags also. The only reason you aren't seeing it when you echo it is because your browser thinks it's an invalid HTML tag, so it just ignores it. If you view source, you should see the <image_link> tags in there.

To fix this, do:

$shackPath = strip_tags(trim($newImagePath[6]));
jimyi
Wow! That's the second thing I learnt today. ;) Thank you.!
Abs