Jump to content

Search a database


adam291086

Recommended Posts

Ok. I have a next button and it works. The way it works is by adding 1 to the photo Id that is posted from a pervious page. I have got the code to count the number of photos on display. This is stored in an array. I then have an If statement say If the photo on display = 0 then redirect. But the page doesn't redirect it displays all the links and no pictures. Can you help?

 

// get picture details 

$con;
$sql = "SELECT photo_title, photo_id, photo_location, album_id FROM photos WHERE photo_id = " . addslashes($_GET['photo_id']);
$result = @mysql_query($sql) or die("Error retrieving record: " . mysql_error()); 
while($row = @mysql_fetch_array($result))
{
$photo_title = $row['photo_title'];
$photo_loc = $row['photo_location'];
$album = $row['album_id'];
$photo = array($column['photo_id']);
}

// stop blank pictures 

$empty = count ($photo); 
echo $empty;

If ($empty ==0){
header('Location: http://www.example.com/');
}

 

Link to comment
Share on other sites

echo $empty;

 

If ($empty ==0){

header('Location: http://www.example.com/');

}

 

 

Your echoing before your calling a header set

 

At a guess, because I dont actually know, I'd say if you print anything before you set a header it will cause problems

 

Serves the same princeable as when using cookies, they must be set before anything is sent to the page

 

Just try taking away the echo and ammend your code so that if the photo is 0 then location can be set before anything else is on the page

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.