RE: implode()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



implode accepts an *array* as input, not a string.

you would need to change your $sqlUpdate to be an array, and each statement
look something like;
if($textfield12 != '') { $sqlUpdate[] = "textfield12='$textfield12'"; }

of course it would probably be easier to just do something like this;
if($image11_name != '') $sqlUpdate .= "image11='$image11_name', ";
if($image12_name != '') $sqlUpdate .= "image12='$image12_name', ";
...
if($textlink11 != '') $sqlUpdate .= "textlink11='$textlink11', ";

$sqlUpdate = substr($sqlUpdate, 0, -2);

(note the commas at the end of each string being concatenated?)

(not tested or anything, but should give you the idea)

HTH

Beau

// -----Original Message-----
// From: Jef [mailto:dragonr@xmission.com]
// Sent: Tuesday, 26 November 2002 2:52 PM
// To: php-db@lists.php.net; php-general@lists.php.net
// Subject:  implode()
// 
// 
// I am having difficulty with the implode function. What I am doing is
// building a string for an UPDATE SQL command. At the end of 
// the building
// portion of the code, I want to insert a comma between the 
// various fields
// that will be updated. However, it is not working. Here is a 
// portion of my
// code...thanks, in advance for any assistance received....
// 
//   $sqlUpdate = "SET ";
//   if($image11_name != '') $sqlUpdate .= "image11='$image11_name'";
//   if($image12_name != '') $sqlUpdate .= "image12='$image12_name'";
//   if($textfield11 != '') $sqlUpdate .= "textfield11='$textfield11'";
//   if($textfield12 != '') $sqlUpdate .= "textfield12='$textfield12'";
//   if($textlink11 != '') $sqlUpdate .= "textlink11='$textlink11'";
//   if($textlink12 != '') $sqlUpdate .= "textlink12='$textlink12'";
// 
//   $update = implode(",", $sqlUpdate);
//   $sql = "UPDATE mp " .$sqlUpdate;
// 
// I get a bad parameter message on the line with the call to 
// the Implode
// function.
// 
// 
// 
// Questions? Comments? Suggestions?
// 
// 
// 
// Jef
// 
// 
// 
// -- 
// PHP Database Mailing List (http://www.php.net/)
// To unsubscribe, visit: http://www.php.net/unsub.php
// 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux