0

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>");?>

largeimage.php:

<?php

$groupid=$_GET['groupid'];


print("             <img src='showimagelarge.php?groupid=".$groupid."'>");

?>

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"]);

?>

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"]);

?>
James Anderson
  • 815
  • 1
  • 13
  • 23
  • Where is your fancybox initialization code? – Samsquanch Dec 12 '12 at 23:16
  • 1
    If you're still in develop process you should try to avoid the use of mysql_* since it will be deprecated soon. search google for "php prepared statments" – Pluda Dec 12 '12 at 23:25
  • I have a header with the CSS and a footer with the JS being called through an include. Got'cha, Pluda. Just trying to get it to work then I can optimize it to be much better. – James Anderson Dec 12 '12 at 23:25
  • Your browser only show this message "The requested content cannot be loaded. Please try again later." ? I guess that you have a syntax error in somewhere. – daniloisr Dec 12 '12 at 23:33
  • Is this a JS or PHP error? Which file are you calling, when retrieving this error? Have you checked your server error log's? You should provide more explanation's to your question and reduce the code to the file that is affected. – feeela Dec 12 '12 at 23:35
  • Here's what is displaying, @Daniloisr: http://i.imgur.com/Utdgj.png – James Anderson Dec 12 '12 at 23:37
  • The thing is, before I put the Fancybox in place, it was pulling and displaying images just fine via the ahref, but once I added all of the fancybox classes and such to the links, it blew up. Trying to figure out why. :( – James Anderson Dec 12 '12 at 23:40
  • Yeah, they're returning the images just fine. You can see here: http://i.imgur.com/1sD8J.png The images are being returned, but when it comes to clicking them to display the enlarged versions, after I've added fancybox it just doesn't work. – James Anderson Dec 12 '12 at 23:54
  • So your problem is in `showimagelarge.php`, you know how to see server logs to find the problem? – daniloisr Dec 13 '12 at 00:00
  • @daniloisr , I'm not sure. Where would those be located? – James Anderson Dec 13 '12 at 00:04
  • It depend of what OS you are using, search on google for `where php error_log OS_NAME`, [example](http://www.cyberciti.biz/faq/error_log-defines-file-where-script-errors-logged/) – daniloisr Dec 13 '12 at 00:08
  • Oh, I'm not sure if I can do that. I'm using a host called Bounceweb that has a control panel called the cPanel. Is there a way I can do it in there? – James Anderson Dec 13 '12 at 00:09
  • I found a error_logs file on the FTP. But nothing in it references showimagelarge.php at all. – James Anderson Dec 13 '12 at 00:18

1 Answers1

3

You are rendering the link to your images this way :

<div class='picture'><a rel='image' href='largeimage.php?groupid=".$row['groupid']."'>....

... so your link href will not have any image extension (jpg, png, gif). Because that fancybox doesn't know what type of content to handle, hence the message

The requested content cannot be loaded. Please try again later.

You need to force the type of content to image within your fancybox custom script. That is documented here http://fancyapps.com/fancybox/#support, FAQ tab No. 5

You can do either:

<script type="text/javascript">
  $(document).ready(function(){
    $(".picture a").fancybox({
      "type": "image"
    });
  });
</script>

... or

<script type="text/javascript">
  $(document).ready(function(){
    $('a[rel="image"]').fancybox({
      "type": "image"
    });
  });
</script>
JFK
  • 40,963
  • 31
  • 133
  • 306
  • Oh interesting. Where do I actually place those two lines? In one of the PHP files, or my fancybox.js file, or the fancybox.css file? Not completely sure where it needs to be stuck at is my problem :( – James Anderson Dec 13 '12 at 00:22
  • @JamesAnderson : in the same file that you are loading jQuery and fancybox js and css files, I bet is ShowAll.PHP – JFK Dec 13 '12 at 00:25
  • @JamesAnderson : I edited my answer. The complete piece of code that should be in your `` section AFTER you loaded jQuery and fancybox js and css files – JFK Dec 13 '12 at 00:28
  • Ah, gotcha. I'll try it out! – James Anderson Dec 13 '12 at 00:29
  • @JamesAnderson ... see my previous comment and edited answer ;) – JFK Dec 13 '12 at 00:30
  • Hmm, that didn't seem to do much of anything. :( – James Anderson Dec 13 '12 at 00:37
  • can you share a link? ... at the end of the road what it matters to fancybox is the rendered html and the correct initialization of the script. – JFK Dec 13 '12 at 00:38
  • Sure! http://ravingtechguy.com/weddingpics/login.php Since everything is test, you can just login with my 2nd dummy account: ID: Silvashadows@msn.com pw: amleo241 After logging in, you'll want to go to "My Gallery" under "My Account". – James Anderson Dec 13 '12 at 00:41
  • don't you think this `base64_decode` is creating the issue? why not just echo the image as simple ``? ... check http://stackoverflow.com/a/3260011/1055987 for reference. – JFK Dec 13 '12 at 01:02
  • Not sure honestly. I'm still able to do an inspect element on the page in Chrome, and see all of the images just fine - large and small versions, so the PHP is definitely calling the images. It's just, how do I populate them into the fancybox? – James Anderson Dec 13 '12 at 01:06
  • Actually, I think that's what we're doing like this: In showimagelarge.php, we're doing the base64_decode, then in largeimage.php, it's being placed into an So basically, the same thing, right? – James Anderson Dec 13 '12 at 01:13
  • Anyone have any other ideas? – James Anderson Dec 13 '12 at 14:55