Hello there!
I need some help on a script. I have a form with that edits a row in the database, a form that have a browse button for images. What i need is to run a code if the field LajmeImg is not blank and anothe code if is blank.
I have used this 2 ways:
1.
[code=php]if(empty($_FILES[‘LajmeImg’]) && ($error == ”)) {
$sql = “UPDATE lajme SET KatLajmeID = ‘$KatLajmeID’, LajmeEmri = ‘$LajmeEmri’, LajmeLink = ‘$LajmeLink’, LajmeIntro = ‘$LajmeIntro’, LajmeTxt = ‘$LajmeTxt’, LajmeVideo = ‘$LajmeVideo’, LajmeTag = ‘$LajmeTag’, LajmeAktiv = ‘$LajmeAktiv’ WHERE LajmeID = ‘$LajmeID'”;
$query = mysql_query($sql) or die(“Fatal error: “.mysql_error());
}
else if (!empty($_FILES[‘LajmeImg’]) && ($error == ”)) {
$sql = “UPDATE lajme SET KatLajmeID = ‘$KatLajmeID’, LajmeEmri = ‘$LajmeEmri’, LajmeLink = ‘$LajmeLink’, LajmeIntro = ‘$LajmeIntro’, LajmeTxt = ‘$LajmeTxt’, LajmeVideo = ‘$LajmeVideo’, LajmeTag = ‘$LajmeTag’, LajmeImg = ‘$LajmeImg’, LajmeAktiv = ‘$LajmeAktiv’ WHERE LajmeID = ‘$LajmeID'”;
$query = mysql_query($sql) or die(“Fatal error: “.mysql_error());
2.
[code=php]if(($LajmeImg == ”) && ($error == ”)) {
$sql = “UPDATE lajme SET KatLajmeID = ‘$KatLajmeID’, LajmeEmri = ‘$LajmeEmri’, LajmeLink = ‘$LajmeLink’, LajmeIntro = ‘$LajmeIntro’, LajmeTxt = ‘$LajmeTxt’, LajmeVideo = ‘$LajmeVideo’, LajmeTag = ‘$LajmeTag’, LajmeAktiv = ‘$LajmeAktiv’ WHERE LajmeID = ‘$LajmeID'”;
$query = mysql_query($sql) or die(“Fatal error: “.mysql_error());
}
else if (($LajmeImg !== ”) && ($error == ”)) {
$sql = “UPDATE lajme SET KatLajmeID = ‘$KatLajmeID’, LajmeEmri = ‘$LajmeEmri’, LajmeLink = ‘$LajmeLink’, LajmeIntro = ‘$LajmeIntro’, LajmeTxt = ‘$LajmeTxt’, LajmeVideo = ‘$LajmeVideo’, LajmeTag = ‘$LajmeTag’, LajmeImg = ‘$LajmeImg’, LajmeAktiv = ‘$LajmeAktiv’ WHERE LajmeID = ‘$LajmeID'”;
$query = mysql_query($sql) or die(“Fatal error: “.mysql_error());
but, in both of them, when the field is empty didn’t let the “LajmeImg” DB field out of the query but updates the database with a value that i don;t know where it gets that and have only the name of the image existent on the DB without extension (ex: if the existent image name is [B]imagename.jpg[B]imagename.
Hope that someone will help me on this. Thank you!