admin2gd1
09-01-2008, 06:58 AM
OK i have 2 functions, one checks to see if the property has been sold, two updates the visitors counter on the property and the date of that last visit.
The first one does not work as I have a session file that already starts the header so I get this error.
Warning: Cannot modify header information - headers already sent by (output started at /home/account/public_html/listing.php:50) in /home/account/public_html/listing.php on line 50
The second one does not update the values that I have put. The code I have written is for when the visitor is on the property page so it should be collecting the information fine as the error appears for when trying to redirect to the new page. So the page is viewed like this in the address bar: - www.sitename.com/listing.php?id=1 (This is for when the property is still up for sale and if it's not for sale redirect to www.sitename.com/delisting.php?id=1).
This is what I have so far!
<?php
///// Collect information about the property /////
$sql = "SELECT * FROM ".TBL_PROPERTIES." WHERE property_id='$id' AND sale_type='1' AND status='1' AND active='1'";
$query = mysql_query($sql);
while ($result = @mysql_fetch_array($query)){
$id = $result['$property_id'];
$sale_type = $result['sale_type'];
$visits = $result['visits'];
$lastvisit = $result['$last_visit'];
}
///// Checks if property has been sold or removed. /////
if ($sale_type == 0){
header("Location: delisted.php?id=$id");
}
///// If property has not been sold or removed, continue to display property details. /////
///// Update Property Views Counter /////
if($visits = mysql_query("SELECT COUNT (visits) FROM ".TBL_PROPERTIES." WHERE property_id='$id' AND visits='$visits'")){
while($row = mysql_fetch_assoc($visits)){
$counter = $visits; //count the number of times the property has been viewed
if ($counter != "" || !empty($counter)){
$visits_counter = $counter +1; //add 1 to the counter when property is viewed
$lastvisit = date("Y:m:d H:i:s"); // update the date when property was last looked at
$sqlvisits = mysql_query("UPDATE ".TBL_PROPERTIES." SET visits='$visits_counter', last_visit='$lastvisit' WHERE property_id='$id'");
$query = mysql_query($sqlvisits);
}
}
}
?>
So if someone can help on this, it would be most appreciated.
Thank you.
The first one does not work as I have a session file that already starts the header so I get this error.
Warning: Cannot modify header information - headers already sent by (output started at /home/account/public_html/listing.php:50) in /home/account/public_html/listing.php on line 50
The second one does not update the values that I have put. The code I have written is for when the visitor is on the property page so it should be collecting the information fine as the error appears for when trying to redirect to the new page. So the page is viewed like this in the address bar: - www.sitename.com/listing.php?id=1 (This is for when the property is still up for sale and if it's not for sale redirect to www.sitename.com/delisting.php?id=1).
This is what I have so far!
<?php
///// Collect information about the property /////
$sql = "SELECT * FROM ".TBL_PROPERTIES." WHERE property_id='$id' AND sale_type='1' AND status='1' AND active='1'";
$query = mysql_query($sql);
while ($result = @mysql_fetch_array($query)){
$id = $result['$property_id'];
$sale_type = $result['sale_type'];
$visits = $result['visits'];
$lastvisit = $result['$last_visit'];
}
///// Checks if property has been sold or removed. /////
if ($sale_type == 0){
header("Location: delisted.php?id=$id");
}
///// If property has not been sold or removed, continue to display property details. /////
///// Update Property Views Counter /////
if($visits = mysql_query("SELECT COUNT (visits) FROM ".TBL_PROPERTIES." WHERE property_id='$id' AND visits='$visits'")){
while($row = mysql_fetch_assoc($visits)){
$counter = $visits; //count the number of times the property has been viewed
if ($counter != "" || !empty($counter)){
$visits_counter = $counter +1; //add 1 to the counter when property is viewed
$lastvisit = date("Y:m:d H:i:s"); // update the date when property was last looked at
$sqlvisits = mysql_query("UPDATE ".TBL_PROPERTIES." SET visits='$visits_counter', last_visit='$lastvisit' WHERE property_id='$id'");
$query = mysql_query($sqlvisits);
}
}
}
?>
So if someone can help on this, it would be most appreciated.
Thank you.