Originally posted by TheDefender
Can you post some applicable code for this? (including several lines before and after the parse error)
Also, you mention the line number changes... is the content developed dynamically?
No problem, the code is below. Error lines vary. It can say line 56 and next time you catch the bug, it becomes 81, 73, etc. Sometimes it referes to a line with only } in it. Too weird.
<?
include("common/connect.php");
include("common/config.php");
include("common/mod_states.php");
include("common/mod_select.php");
include("common/upload.php");
session_start();
session_register("eh_sire","eh_sire1","eh_sire11","eh_sire12","eh_sire2","eh_sire21","eh_sire22","eh_dam","eh_dam1","eh_dam11","eh_dam12","eh_dam2","eh_dam21","eh_dam22");
session_register("filename_1");
session_register("filename_2");
session_register("filename_3");
session_register("filename_4");
session_register("m"); // month-folder
if (!$userLogged) {
if ($userLogin) header("Location: login.php\n"); else header("Location: register.php");
}
if ($GET[id]) $id = $GET[id]; else $id = $_POST[id];
if (!is_numeric($id)) header("Location: my_horses.php"); // if no id, close access and redirect to my horses
if ($_GET[id]) { // if redirected from the horses page, select by id
$sql = "SELECT keyword,name,breedid,genderid,age,dob,height,colorid,registered,description,city,state,photo,price,currency,userid,DATE_FORMAT(expires,'%m'),isfor,pedigreeid,skill1id,skill2id,skill3id,skill4id,skill5id,temperament,snapshot FROM horses WHERE id=$id AND userid=$userID";
$sql = mysql_query($sql);
echo(mysql_error());
list($keyword,$name,$breed,$gender,$age,$dob,$height,$color,$registered,$description,$city,$state,$photo,$price,$currency,$userid,$m,$isfor,$pedigreeid,$skill1id,$skill2id,$skill3id,$skill4id,$skill5id,$temperament,$snapshot)=mysql_fetch_row($sql);
// If pedigree found fill up session variabes with values
if ((is_numeric($pedigreeid))) {
$sql = "SELECT sire,sire1,sire2,sire11,sire12,sire21,sire22,dam,dam1,dam2,dam11,dam12,dam21,dam22 FROM pedigree WHERE id=$pedigreeid";
$sql = mysql_query($sql);
list($eh_sire,$eh_sire1,$eh_sire2,$eh_sire11,$eh_sire12,$eh_sire21,$eh_sire22,$eh_dam,$eh_dam1,$eh_dam2,$eh_dam11,$eh_dam12,$eh_dam21,$eh_dam22) = mysql_fetch_array($sql);
}
// if skills found
$skills = ""; $skill1id.$skill2id.$skill3id.$skill4id.$skill5id;
if ($skill1id) $skills .= $skill1id.";";
if ($skill2id) $skills .= $skill2id.";";
if ($skill3id) $skills .= $skill3id.";";
if ($skill4id) $skills .= $skill4id.";";
if ($skill5id) $skills .= $skill5id.";";
setcookie("ehSkills",$skills,$expires);
// if any images found, copy to upload folder and associate with session vars
$source_1 = "photos/" . $m . "/horses/" . $id . "x1";
$source_2 = "photos/" . $m . "/horses/" . $id . "x2";
$source_3 = "photos/" . $m . "/horses/" . $id . "x3";
$source_4 = "photos/" . $m . "/horses/" . $id . "x4";
$sources = array($source_1,$source_2,$source_3,$source_4);
$dest_1 = "upload/horses/". $id . "x1";
$dest_2 = "upload/horses/". $id . "x2";
$dest_3 = "upload/horses/". $id . "x3";
$dest_4 = "upload/horses/". $id . "x4";
$dests = array($dest_1,$dest_2,$dest_3,$dest_4);
foreach($sources as $index=>$value) { // preset cookies for photos (in case if updating photos)
if (file_exists($value.".jpg")) {
copy($value.".jpg",$dests[$index].".jpg");
if (file_exists($value.".jpg")) copy($value.".jpg",$dests[$index].".jpg"); else resizeImage($value.".jpg",$dests[$index].".jpg",150,100);
if (file_exists($value.".jpg")) copy($value.".jpg",$dests[$index].".jpg"); else resizeImage($value.".jpg",$dests[$index].".jpg",55,55);
if ($index==0) { $filename_1=$id; setcookie("ehPhotoHorse_1",$id); }
if ($index==1) { $filename_2=$id; setcookie("ehPhotoHorse_2",$id); }
if ($index==2) { $filename_3=$id; setcookie("ehPhotoHorse_3",$id); }
if ($index==3) { $filename_4=$id; setcookie("ehPhotoHorse_4",$id); }
}
}
}
function move_photos($id,$filename,$number,$m) {
$source_1 = "upload/horses/". $filename . "x" . $number . ".jpg"; // create all sources
$source_2 = "upload/horses/". $filename . "x" . $number . ".jpg";
$source_3 = "upload/horses/". $filename . "x" . $number . ".jpg";
$dest_1 = "photos/" . $m . "/horses/" . $id . "x" . $number . ".jpg"; // create all destinations
$dest_2 = "photos/" . $m . "/horses/" . $id . "x" . $number . ".jpg";
$dest_3 = "photos/" . $m . "/horses/" . $id . "x" . $number . ".jpg";
if (file_exists($source_1)) rename($source_1,$dest_1); // move if possible
if (file_exists($source_2)) rename($source_2,$dest_2);
if (file_exists($source_3)) rename($source_3,$dest_3);
}
function remove_photo($id,$number,$m) {
$source_1 = "photos/" . $m . "/horses/" . $id . "x" . $number . ".jpg"; // create all sources
$source_2 = "photos/" . $m . "/horses/" . $id . "x" . $number . "_.jpg";
$source_3 = "photos/" . $m . "/horses/" . $id . "x" . $number . "__.jpg";
if (file_exists($source_1)) unlink($source_1); // unlink if possible
if (file_exists($source_2)) unlink($source_2);
if (file_exists($source_3)) unlink($source_3);
}
// If user posts ad, put in DB
if ($post == "update") {
$name = stripall($name);
$isfor = stripall($isfor);
$breed = stripall($breed);
$gender = stripall($gender);
$age = stripall($age);
$height = stripall($height);
$color = stripall($color);
$registered = stripall($registered);
$description = stripall($description);
$city = stripall($city);
$state = stripall($state);
$price = stripall($price);
if ((!ereg("[[:digit:]]+$", $price))) $message = "Price must be a number (no commas, periods or spaces).";
if (!$state) $message = "Horse State is required.";
if (!$city) $message = "Horse City is required.";
if (!$temperament) $message = "Temperament is required.";
if (!$description) $message = "Description is required.";
if (!$registered) $message = "Specify if your horse is registered or not.";
if (!$color) $message = "Base Color is required.";
if (!$height) $message = "Height is required.";
if (!$dob) $message = "Year of Birth is required.";
if ($age=="") $message = "Age is required.";
if (!$gender) $message = "Gender is required.";
if (!$breed) $message = "Breed is required.";
if ($isfor=="") $message = "Specify if horse is for sale, stud or lease.";
if (!$name) $message = "Horse Name is required.";
if ($keyword) {
if (ctype_alnum($keyword)) {
$sql = "SELECT id FROM horses WHERE keyword LIKE '$keyword'";
$sql = mysql_query($sql);
if (mysql_num_rows($sql)) {
$message = "Sorry, this keyword is already taken. Please try again.";
}
} else {
$message = "Sorry, the keyword can contain only alphabetical characters and/or numbers.";
}
}
if (!$message) {
$photo = $HTTP_COOKIE_VARS["ehPhoto"];
$filename_1 = ""; // destroy session vars used in photo upload
$filename_2 = "";
$filename_3 = "";
$filename_4 = "";
$photo_1 = $HTTP_COOKIE_VARS["ehPhotoHorse_1"];
$photo_2 = $HTTP_COOKIE_VARS["ehPhotoHorse_2"];
$photo_3 = $HTTP_COOKIE_VARS["ehPhotoHorse_3"];
$photo_4 = $HTTP_COOKIE_VARS["ehPhotoHorse_4"];
$photoboolean = 0;
if (($photo_1) || ($photo_2) || ($photo_3) || ($photo_4)) $photoboolean = 1;
$submit_sire = $eh_sire.$eh_sire1.$eh_sire11.$eh_sire12.$eh_sire2.$eh_sire21.$eh_sire22;
$submit_dam = $eh_dam.$eh_dam1.$eh_dam11.$eh_dam12.$eh_dam2.$eh_dam21.$eh_dam22;
$submit_pedigree = $submit_sire . $submit_dam;
// If something was entered for pedigree, submit it
$pedigreeid = "";
if ($submit_pedigree) {
if (is_numeric($pedigreeid)) {
$sql = "UPDATE pedigree SET sire='$eh_sire',sire1='$eh_sire1',sire11='$eh_sire11',sire12='$eh_sire12',sire2='$eh_sire2',sire21='$eh_sire21',sire22='$eh_sire22',dam='$eh_dam',dam1='$eh_dam1',dam11='$eh_dam11',dam12='$eh_dam12',dam2='$eh_dam2',dam21='$eh_dam21',dam22='$eh_dam22' WHERE id=$pedigreeid";
} else {
$sql = "INSERT INTO pedigree SET sire='$eh_sire',sire1='$eh_sire1',sire11='$eh_sire11',sire12='$eh_sire12',sire2='$eh_sire2',sire21='$eh_sire21',sire22='$eh_sire22',dam='$eh_dam',dam1='$eh_dam1',dam11='$eh_dam11',dam12='$eh_dam12',dam2='$eh_dam2',dam21='$eh_dam21',dam22='$eh_dam22'";
}
mysql_query($sql);
echo(mysql_error());
if (!is_numeric($pedigreeid)) $pedigreeid = mysql_insert_id();
unset($eh_sire,$eh_sire1,$eh_sire2,$eh_sire11,$eh_sire12,$eh_sire21,$eh_sire22,$eh_dam,$eh_dam1,$eh_dam2,$eh_dam11,$eh_dam12,$eh_dam21,$eh_dam22);
session_unregister("eh_sire");
session_unregister("eh_sire1");
session_unregister("eh_sire2");
session_unregister("eh_sire11");
session_unregister("eh_sire12");
session_unregister("eh_sire21");
session_unregister("eh_sire22");
session_unregister("eh_dam");
session_unregister("eh_dam1");
session_unregister("eh_dam2");
session_unregister("eh_dam11");
session_unregister("eh_dam12");
session_unregister("eh_dam21");
session_unregister("eh_dam22");
}
list($skill1id,$skill2id,$skill3id,$skill4id,$skill5id) = explode(";",$ehSkills);
setcookie("ehSkills","");
}
// If photo ad posted and no snapshot found, offer bonus package
if (($photoboolean) && (!$snapshot)) header("Location:bonus.php?hid=$id");
// Else go directly to thank you page
else header("Location: horses.php");
}
}
?>