SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help me in this code plz

    hi there i have an error in this php code it indecates everything abt the images in the directory img like the no. of images and the images names but in the view the images not appear help me plz urgent

    PHP Code:
    <?php 

    //which dir 
    $d dir("img"); 

    //read thru and  
    while (false !== ($entry $d->read())) { 
      
    //allow extensions here 
      //|| preg_match("/(\.bmp$)/i", $entry) 
      //|| preg_match("/(\.jpeg$)/i", $entry); 

      
    if (preg_match("/(\.gif$)/i"$entry) || preg_match("/(\.jpg$)/i"$entry)){ 
        
    $pics[] = $entry
      } 


    $d->close(); 


    //================ 
    //total images count 
    $numPics count($pics); 



    //================ 
    //picture in array to show on this page 
    $thispic 0
    if (
    is_numeric($_GET['id'])){ 
        
    $thispic $_GET['id']; 

    $thispicDisplay $thispic 1



    //================ 
    //img tag for current image 
    $thisImage '<img src="' $pics[$thispic] . '" alt="' $pics[$thispic] . '" />'



    //====================== 
    // START set thumbnails on or off  

    //comment this section out if you don't want thumbs to show at all 

    $showThumbs 5;//number of thums to show 
    $thumbsList ''
    $thumburl ''
    if (
    $_GET['thumb'] == 'yes'){ 
        
    //read thumb param to url if exists 
        
    $thumburl '&amp;thumb=yes'

        for (
    $i=0;$i<$showThumbs;$i++){ 
            if (
    $thispic $i $numPics){ 
                
    $currThumb $thispic $i 1
                
    $thumbsList .= '<a href="' $_SERVER['PHP_SELF'] . '?id=' $currThumb 

    $thumburl '" title="' $pics[$currThumb] . '"><img src="' $pics[$currThumb] . '" alt="' 

    $pics[$currThumb] . '" height="100" width="100" border="0" /></a>&nbsp;&nbsp;&nbsp;'
            } 
        } 
        
    $onOff ='<a class="thumbs" href="' $_SERVER['PHP_SELF'] . '?id=' $thispic '">Turn 

    Thumbnails Off</a>'

    } else { 
        
    $onOff ='<a class="thumbs" href="' $_SERVER['PHP_SELF'] . '?id=' $thispic 

    '&amp;thumb=yes">Turn Thumbnails On</a>'


    // END set thumbnails on or off  





    //prev button 

    $prevurl ' <span class="highlighted">First Picture</span>'
    if (
    $thispic 0){ 
        
    $prev $thispic 1
        
    $prevurl '<a href="' $_SERVER['PHP_SELF'] . '?id=' $prev $thumburl '" title="' 

    $pics[$prev] . '">Previous picture</a>'
    }  




    //next button 

    $nexturl ' <span class="highlighted">Last Picture</span>'
    if (
    $thispic < ($numPics 1)){ 
        
    $next $thispic 1
        
    $nexturl '<a href="' $_SERVER['PHP_SELF'] . '?id=' $next $thumburl '" title="' 

    $pics[$next] .'">Next picture</a>'




    //======================= 
    // string of all pics url's 
    $urlarray ''
    for (
    $i=0;$i<count($pics);$i++){ 
        
    //highlign pic you are on 
        
    $j $i 1

        if (
    $i != $thispic){ 
             
            
    $urlarray .= '<a href="' $_SERVER['PHP_SELF'] . '?id=' $i $thumburl .'" title="' 

    $pics[$i] . '">' $j .'</a>  '
        } else { 
            
    $urlarray .= ' <span class="highlighted">' $j '</span> '
        } 










    ?> 
    <?php echo '<?xml version="1.0" encoding="iso-8859-1"?>' "\n"?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <title><?=$pics[$thispic]?></title> 
    <meta name="Author" content="Trent Williams" /> 
    <style type="text/css"> 
    *{margin:0px;} 
    html, body{color:#000; background-color:#fff;} 
    .borders {background:#FFFFFF; border:2px solid #DF1C11; padding:10px; width:100%; 

    float:left; font-family:arial, helvetica, sans-serif; font-size:85%;} 
    .content {padding:10;} 
    a{color:#000;text-decoration:none; font-weight:bold;} 
    a:hover{text-decoration:underline;} 
    .highlighted {color:#DF1C11; font-weight:bold;} 

    a.thumbs {color:#000000;text-decoration:none; font-weight:bold;} 

    </style> 
    </head> 

    <body> 


    <table cellpadding="0" cellspacing="10" border="0"> 
    <tr> 
        <td> 

    <div class="borders"><?=$prevurl?>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<?

    =$nexturl?>&nbsp;&nbsp;&nbsp;Picture number: <strong><?=$thispicDisplay?></strong> 

    &nbsp;&nbsp;Picture name: <strong><?=$pics[$thispic]?></strong></div> 




    <div class="content"><center><?=$thisImage?></center></div> 

    <div class="content"><?=$onOff?><center><?=$thumbsList?></center></div> 

    <div class="borders"><?=$urlarray?></div> 


    </td> 
    </tr> 
    </table> 


    </body> 
    </html>

  2. #2
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    right click on image chk the properties and chk the image path is it proper or not....

  3. #3
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by simplecode View Post
    right click on image chk the properties and chk the image path is it proper or not....
    i have checked the images the properties r right the name of the img. , its path and its size everything is right but no images appears the X sign in the place of the images

  4. #4
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can u post the complete image path here

  5. #5
    SitePoint Enthusiast dakine's Avatar
    Join Date
    Dec 2006
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had this same problem, not sure if the same solution will apply but, download the image and open it in a program like photoshop, and look at the colour system if it is CMKY, then change it to RGB.....and problem solved (im my case it was).

  6. #6
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the images r already RGB and secondly the image path in the drirectory called "img" this is the image path

  7. #7
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its working now thanks to u all but its works when in put the php file in the same directory of the images

  8. #8
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that means ur missing the correct path

  9. #9
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its the path man thanks so much and i'm so sorry for this entruption


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •