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
https://forums.phpfreaks.com/topic/71793-search-a-database/#findComment-361554
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
https://forums.phpfreaks.com/topic/71793-search-a-database/#findComment-361620
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.