Will someone PLEASE explain to me why I get an error saying that $new_cid is unidentified? It only happens when I use .= to append a value to the existing variable.
$dereg_course_student= mysql_query("SELECT * FROM course_student");
$new_cid;
while($row=mysql_fetch_assoc($dereg_course_student)){
$cid=explode(".",$row['cid']);
foreach($cid as $cids){
if($cids==$_GET['cid']){
unset($cids);}
if(isset($cids)){
$new_cid=$new_cid.".{$cids}";}
} mysql_query("UPDATE course_student SET cid={$new_cid} WHERE sno={row['sno']}");
}
Because you are using
$new_cid;at the beginning and you aren’t specifying what type of variable it should be. In php you don’t have to declare variables you can just use$new_cidin the loop whit no pre-defined value.
Try it like this.