Jef wrote:
implode() expects an array as the second argument. You're passing a
string. In
fact with the code you have above I don't see why you don't just tack the
comma on the end in the first place:
if($image11_name != '') $sqlUpdate .= "image11='$image11_name', ";
The reason being the comma at the end of the SQL command will prevent the
command from working because SQL will expect another entry. However, your
comment about implode expecting an array helps out. Thanks.
This is how I would do it:
<?php
$separator = "";
if($image11_name != '') {
$sqlUpdate .= $separator . "image11='$image11_name'";
$separator = ", ";
}
if($image12_name != '') {
$sqlUpdate .= $separator . "image12='$image12_name'";
$separator = ", ";
}
if($textfield11 != '') {
$sqlUpdate .= $separator . "textfield11='$textfield11'";
$separator = ", ";
}
if($textfield12 != '') {
$sqlUpdate .= $separator . "textfield12='$textfield12'";
$separator = ", ";
}
if($textlink11 != '') {
$sqlUpdate .= $separator . "textlink11='$textlink11'";
$separator = ", ";
}
if($textlink12 != '') {
$sqlUpdate .= $separator . "textlink12='$textlink12'";
$separator = ", ";
}
if($sqlUpdate != "") {
$query = "UPDATE my_table SET " . $sqlUpdate;
// Execute query
} else {
// Nothing to update...
}
?>
Regards
Joakim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php