FancyBox error when using PHP. Any ideas?

Discussion in 'PHP' started by jamesdanderson.1337, Dec 14, 2012.

  1. #1
    just going to share my code and see if anyone can spot what's causing this.


    The error reads:
    "The requested content cannot be loaded.
    Please try again later."


    ShowAll.PHP:
    
    
    <?include_once "db.php";    
    
    session_start();    
    
    $gid=$_SESSION['gid'];    
    
    $result = mysql_query("SELECT id,groupid FROM images where gid='".$gid."' and imagetype='1' ORDER BY id");
        
    print("<div id='wrapper'>   
                 
    <!--start: Container -->  
              
    <div class='container'>");  
              
    $j=0;
    
    print("<div class='row'><div class='span6'>
    
    <h1>My Gallery</h1>
    
    <br></div>
    
    <div class='span6'></div></div>
    
    <!--start: Row -->
    
    <div class='row'>");           
    
    while($row = mysql_fetch_array($result)){ if ($j==6){$j=0;print("</div>");                            
    
    print("<!--start: Row -->  
                      
    <div class='row'>");  
                      
    print("<div class='span2'>");    
                    
    print("<p><div class='picture'><a rel='image' href='largeimage.php?groupid=".$row['groupid']."'><img src='showimage.php?id=".$row['id']."'><div class='image-overlay-zoom'></div></a></div>");         
               
    print("</div>");$j++;}
    
    else{print("<div class='span2'>");   
                     
    print("<p><div class='picture'><a rel='image' href='largeimage.php?groupid=".$row['groupid']."'><img src='showimage.php?id=".$row['id']."'><div class='image-overlay-zoom'></div></a></div>");         
               
    print("</div>");$j++;}}print("</div>");?>
    PHP:


    largeimage.php:
    
        <?php       
    $groupid=$_GET['groupid'];            
    print("<img src='showimagelarge.php?groupid=".$groupid."'>");?>
    
    PHP:
    showimagelarge.php:
    
    include_once "db.php";        
    session_start();                
    $gid=$_SESSION['gid'];        
    header('Content-type: image/jpeg');        
    $query = "SELECT image from images where groupid=". intval($_GET["groupid"])." and gid='".$gid."' and imagetype='2'";        
    $rs = mysql_fetch_array(mysql_query($query));        
    echo base64_decode($rs["image"]);        ?>
    PHP:
    showimage.php:
    
    include_once "db.php";        
    session_start();                
    $gid=$_SESSION['gid'];        
    header('Content-type: image/jpeg');        
    $query = "SELECT image from images where id=". intval($_GET["id"])." and gid='".$gid."'";        
    $rs = mysql_fetch_array(mysql_query($query));        
    echo base64_decode($rs["image"]);        ?>
    PHP:

    Also, my initialization of the fancybox is:
    [COLOR=#333333][FONT=Whitney SSm A]$(document).ready(function(){ $(".picture a").fancybox({ "type": "image" }); });[/FONT][/COLOR]
    Code (markup):

     
    Last edited: Dec 14, 2012
    jamesdanderson.1337, Dec 14, 2012 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    You see the images? as in a gallery? please give more info! what if you remove the fancy box script? no error?
     
    EricBruggema, Dec 14, 2012 IP
  3. jamesdanderson.1337

    jamesdanderson.1337 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I see the images, for instance:
    largeimage.php?groupid=1

    Is the large version of the image, then:

    showimage.php?id=41

    Is the rezzed down version of the image.

    Can't see it from an outside point of view, since the way the PHP works, images are associated to specific user accounts.

    Without the fancybox, the a href just opens the image up in a new browser tab and that's it. Wanted to add fancybox to make it look better, but it's throwing all kinds of errors and giving me all sorts of headaches.
     
    jamesdanderson.1337, Dec 15, 2012 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    The endless pointless use of multiple print statements doesn't exactly make this mess easy to follow. Nor does the meaningless markup like "span6" and what I suspect are DIV for nothing, block level elements inside inline-level, paragraph around non-paragraph content (likely doing margin's job)... and of course the pointless comments like "Start Container" right before <div class="container"> -- lemme guess, that steaming pile known as Dreamweaver?

    The logic flow doesn't even make sense, since you're closing a bunch of DIV without opening any... or... gah, no, it's just poorly written poorly formatted gibberish it's a miracle anyone can follow. That the logic flow is wasting time forcing them into rows instead of letting the layout CSS do that FOR YOU isn't helping matters either.

    Just what are you even trying to accomplish with that mess?
     
    deathshadow, Dec 15, 2012 IP
    DomainerHelper likes this.
  5. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #5
    The php bbcode would not retain format so I quoted it. This is your code cleaned up. the issue is your html. This isn't flawless btw. I did not fix your isue.... because you did not include all code needed to do that.... and I typically charge for that much work.

    
    
    <?php
    session_start();
    require_once('db.php');
    if (!function_exists('clean')) {
        function clean($data) {
            if (filter_var($data, FILTER_VALIDATE_INT) !== FALSE) {
                return $data;
            } else {
                return filter_var($data, FILTER_SANITIZE_STRING);
            }
        }
    }
    if (!empty($_SESSION['gid'])) {
        $gid = clean($_SESSION['gid']);
    } else {
         die('NO GID SENT! I QUIT!');
    }   
    $result = mysql_query('SELECT `id`,`groupi` FROM `images` WHERE `gid`="'.mysql_real_escape_string($gid).'" && `imagetype` = "1" ORDER BY `id`');
    if (mysql_num_rows($result) == 0) { die('NO RESULTS'); }
    $j = 0;
    echo '
        <div id="wrapper">
            <!--start: Container -->
                <div class="container">
                    <div class="row">
                        <div class="span6">
                            <h1>My Gallery</h1><br />
                        </div>
                        <div class="span6"></div>
                    </div>
                    <!--start: Row -->
                    <div class="row">
    ';         
    while($row = mysql_fetch_assoc($result)) {
        $j++;
        if ($j == 6) {
            echo '
                </div>
                <!--start: Row -->
                <div class="row">
                    <div class="span2">
                        <div class="picture">
                            <a rel="image" href="largeimage.php?groupid='.$row['groupid'].'"><img src="showimage.php?id='.$row['id'].'"><div class="image-overlay-zoom"></div></a>
                        </div>
                    </div>
            ';     
        } else {
            echo '
                    <div class="span2">
                    <div class="picture">
                        <a rel="image" href="largeimage.php?groupid='.$row['groupid'].'"><img src="showimage.php?id='.$row['id'].'"><div class="image-overlay-zoom"></div></a>
                    </div>
                </div>
            ';
        }
    }
    echo '</div>';
    ?>
    
    
    Code (markup):
     
    Last edited: Dec 15, 2012
    DomainerHelper, Dec 15, 2012 IP
  6. zied.ho

    zied.ho Well-Known Member

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    106
    #6
    place session_start(); on the top of your script
     
    zied.ho, Dec 16, 2012 IP
  7. DomainerHelper

    DomainerHelper Well-Known Member

    Messages:
    445
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    100
    #7
    Wow, you wasted database space to say that? No, that WILL NOT fix the issue. Don't post stupid crap just to build your post count.
     
    DomainerHelper, Dec 16, 2012 IP