Page 1 of 1

Question about saving images

Posted: Mon Aug 11, 2008 6:22 am
by katerina
Hi,
I would like to insert the code of a website into a database.
However, I don't know how I can insert it.
So I thougth that is better to save into a table all the images, in another table all lists etc.

My code for saving images is :

Code: Select all

 
  $url="http://www.e-gov.gr";
  $file = file_get_contents($url);
 
preg_match_all ( '#(?:<img )([^>]*?)(?:/?>)#is', $file, $imgtags, PREG_PATTERN_ORDER );
 
$imgcontents = array();
 
foreach ( (array) $imgtags[1] as $img )
{
   
   preg_match_all ( '#([a-zA-Z]*?)=[\'"]([^"\']*)["\']#i', $img, $attributes, PREG_PATTERN_ORDER );
    $attrs = array();
    foreach ( (array) $attributes[1] as $key => $attr )
    {
        $attrs[$attributes[1][$key]] = $attributes[2][$key];
    }
    $imgcontents[] = $attrs;
}
 
 
foreach($imgcontents as $img => $key1) {
 
    $id = $img;
   
   
    $query = "INSERT INTO eikones (id) VALUES ('" .$id. "')";
    mysql_query($query);
 
    foreach($key1 as $imgs => $key2) {
   
        if ($imgs == 'src') {
       
            $img = array_reverse(split('/', $key2));
           
            $key2 = $img[0];
        }
      
       
        $query = "UPDATE eikones SET " .$imgs. " = '" .$key2. "' WHERE id = '" .$id. "'";
        mysql_query($query);
   
    }
}
QUESTION 1 :
Trying the site http://www.e-gov.gr I take the error

Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\php examples\example.php on line 56

What is happened ?

QUESTION 2 :
I tried the site of microsoft and because the src of img is in the end , I cannot find any images.

And Last QUESTION
I want to save also in database the line of code that I found the image so as in every row of table 'images' to see the line.

Thanks a lot

Re: Question about saving images

Posted: Tue Aug 12, 2008 9:22 am
by katerina
Some assistance ???