Before I came on here for help I tried imputing 1 for $aid variable. That did work, although I did not try it with the new code I am now using. As son as I get arround a computer I wil try putting 1 in and see if the code parses and wil display some images.

The only other thing I can recommend is to copy your database connection script into it's own file like "db_connect.php" for example. You can then include that file as one of the first lines on the page. This will keep you from having to rewrite your connection script as well as bypass any potential problems you may encounter from connecting halfway down the page (this doesn't pose many problems but I've run into a few in the past). Of course this has nothing to do with your $_GET problem but nothing surprises me anymore :)

I knew there was a reason for not having an external file to connect to the Database.

I get an error saying it cannot connect to the database. I put the include file as the very first thing to get parsed on the page..

Oh yeah, the _GET is my problem. If I manually put aid = '1' I see photos :)

I just tried this code:

$aid = mysql_real_escape_string($_GET['aid'], $con);
var_dump($aid);

and I got this on the screen:
string(0) ""

Have any ideas on what that mean? Because I sure dont....'

Thanks for all the help you have been giving really appreciate it!!

LOL, if you don't know what it means ... string(0) ... why would you use var_dump? It's the type and value of the expression you passed to var_dump. This will tell you all you need to know about it. http://php.net/manual/en/function.var-dump.php.

It's a matter of personal preference whether or not to use an external file to make your connection (it's not important now) ... if it's something you would like to do there is really no reason not to ... it's as simple as using $_GET :) I personally keep my connection script in an external file because that file does a bit more for me than just connect to the db.

db_connect.php

$dbname = 'DATABASE_NAME';
$link = mysql_connect("localhost","USER","PASSWORD") or die("Couldn't make connection.");
$db = mysql_select_db($dbname, $link) or die("Couldn't connect to the database");

<?php include 'db_connect.php'; ?>

Nothing to it.

I'm not sure what to tell you about the problem with $_GET at this point ... it couldn't be any easier to use, $_GET works just fine we just need to figure out what you're doing wrong.

Think of it like parking your car ... if you keep hitting the curb or other cars is it the cars fault? Of course not, the car works just fine you just need to learn how to drive it :)

so I did a new db_connect file and used the code just like yours and put the include file at the top of the page and i still get the "could not cennect" error. But it does seem to work when I attach it to the top of all my other scripts..

I checked if Register Globals is on ( I did a lot of reading on Google and it said that's how the variable is passed), it is on. So Other than not being able to connect with an external script I still don't know what the problem is...

Could there possibly be a a way to rewrite this:

echo "<div class='photoThumb'>"
   ."<a href='".$row['filepath'].$row['filename']."'>"
   ."<img src='".$row['filepath'].$row['filename']."' rel='lightbox['".$aid."']' border='0' width='100px' />"
   ."</a><br/></div>";

The reason I ask is my source displays some crazy looking HTML:

<img border="0" width="100px" ]="" 1="" rel="lightbox[" src="/image01.jpg">

Here is my updated PHP that I am working with, this goes to show again that I am losing my $_GET variable because I manually typed in '1' and everything works great.

//$aid = mysql_real_escape_string($_GET['aid'], $con);
$aid = '1';
$select1 = ("SELECT * FROM photo_albums WHERE aid = '$aid' ");
$result1 = mysql_query($select1) or die(mysql_error());
while($row = mysql_fetch_array($result1)) {
	echo "<h3 align='left'>".$row['atitle']."</h3>"
         ."<p align='left'>".$row['description']."</p>";
}
$select = ("SELECT * FROM pictures WHERE aid = '$aid' ORDER BY pid ASC ");
$result = mysql_query($select) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
echo "<div class='photoThumb'>"
   ."<a href='".$row['filepath'].$row['filename']."'>"
   ."<img src='".$row['filepath'].$row['filename']."' rel='lightbox['".$aid."']' border='0' width='100px' />"
   ."</a><br/></div>";
}

wow.... so my problem the entire time was the include file. I put all my gallery code on the viewAlbum.php page and it works fine...
it gets the $_GET and drops every where I have $aid...

So conclusion... for me at least, dont use an include file for a photo gallery :) . I'm stoked! thanks everyone for your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.