do u know php??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
User avatar
sakaveli
Forum Commoner
Posts: 60
Joined: Tue Apr 06, 2004 9:42 am

do u know php??

Post by sakaveli »

hi,

this problem is driving me insane!

i am behind proxie server and wish to download images from the internet so i can store them into a mysql database...im using Curl and have it setup fine, the function below is about to initialise the get LoadImage function:

Code: Select all

<?php 

function storeImageURL($url,$id,$table = "item") { 
   $type = getImageType($url); 
   if ($type === FALSE) return FALSE; 
   $data = loadImage($url); 
   if ($data === FALSE) return FALSE; 
   $rtn = saveImage($id,$data,$type,$table); 
} 
?>

after the type is verified the loadimage function is called with the valid url being passed to it:

Code: Select all

<?php 
function loadImage($url) 
{ 

//useful function  
//@param  resource  $cx     connection 
//@param  array       $opts  array of options: array(option_name => option_value) 
//@return  void 


   $cx = curl_init($url); // create the connection 
   curl_set_options($cx, array('returntransfer' => true, 'followlocation' => true)); // set connection options 
   $data = curl_exec($cx); // execute the request 
   curl_close($cx);    
   return $data; 
    

// now $result holding the response of the remote server: image, html error-page, nothing - whatever. 
// check the PHP manual, cURL chapter for more options, such as proxies, authentication etc. 
} 

?>

can ANYONE please help me? whats going wrong above?? i placed an echo just before the "return $data" and that echo comes up. but no image is saved?

just incase, the save function is below...

Code: Select all

<?php 

function saveImage($id,$data,$type,$table = "item") { 
   //clean up the data so SQL can understand it. 
   $data = str_replace("","\",$data); 
     $data = str_replace("'","\''",$data); 
     $result = query("UPDATE $table set imagetype = '$type', image = '$data' where item_id = '$id'"); 
} 

?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

no need to start a new topic

heres the original - http://www.devnetwork.net/forums/viewtopic.php?t=20553

Mark
Locked