arrays - SQL PHP Syntax ERROR Optimisation -


i error in code. see i'm doing wrong. error get:

died have error in sql syntax; check manual corresponds mysql server version right syntax use near ')' @ line 1

this code:

   $depsql = mysql_query("select department_array busdetails bus_id='".$bus_id."' limit 1");     while($row=mysql_fetch_array($depsql))     {       $deparray = $row["department_array"];     }     $stsql = mysql_query("select department_id, staff_array institute_departments department_id in ($deparray)") or die ("died ".mysql_error());    while($get=mysql_fetch_array($stsql)) {     $starray = $get["staff_array"];      $id =  $get["department_id"];    $explodedst = explode(",", $starray);   foreach ($explodedst $key2 => $value2) {         if ($value2 == $bus_id) {             unset($explodedst[$key2]);         } } $newst = implode(",", $explodedst); echo $id . " " . $newst . "<br/>" ; $sql = mysql_query("update institute_departments set staff_array ='$newst'     department_id='$id'");  } 

$strarray = explode(',' , trim($deparray));  $count = count($strarray); if(empty($strarray[$count-1]))     unset($strarray[$count-1]);  $deparray = implode(',' , $strarray); 

you must take care of extra comma , while inserting values.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -