php - Call to a member function saveSibling() on a non-object? -


i added code add row dynamically form , when user submit form call function(savesibling) of application object save data database(sibling table)but doesnt work. when data has been submitted user redirected updateappplication.php

$userid = $_session['username'];  	$a = new application();  	$namesib = $jobsib = $relationshipsib  = $jabatan = $age = $statussib = "";  	  	$check = true;  	  	if ($_server["request_method"] == "post")  	{   		//save n cont next form  	   if(isset($_post['savecontinue']))  	   {  			$namesib = $_post['namesib'];  			$jobsib = $_post['jobsib'];  			$relationshipsib = $_post['relationshipsib'];  			$jabatan = $_post['jabatan'];  			$age = $_post['age'];  			$statussib = $_post['statussib'];  			   			foreach($namesib $a => $b)  			{  				if(isset($_post['namesib']) && isset($_post['relationshipsib']) && isset($_post['age']) && isset($_post['statussib']) || isset($_post['jobsib']) || isset($_post['jabatan']))  					$a -> savesibling($userid, $namesib[$a], $relationshipsib[$a], $age[$a], $statussib[$a], $jobsib[$a], $jabatan[$a]);  			}  			header('location: displayapplication.php');  			  		}  		  	}

public function savesibling($studid, $namesib,  $relationshipsib, $age, $statussib, $jobsib, $jabatan)  	{  		$this -> studid = $studid;  		$this -> namesib = $namesib;  		$this -> jobsib = $jobsib;  		$this -> relationshipsib = $relationshipsib;  		$this -> age = $age;  		$this -> statussib = $statussib;   		$this -> jabatan = $jabatan;  		  		$query = mysql_query("select appid application (studid = '" . mysql_real_escape_string($studid) . "')");  		while($row = mysql_fetch_array($query))   		{  			$appid = $row['appid'];  			$sql = "insert `sibling`(`namesib`, `jobsib`, `relationshipsib`, `age`, `statussib`, `jabatan`, `appid`)   					values ('$namesib', '$jobsib', '$relationshipsib', '$age', '$statussib', '$jabatan', '$appid')";  			$query2 = mysql_query($sql);  			if(!$query2)  				echo mysql_error();  		}  		  		  	}

you overwriting variable:

$a = new application();  ...          foreach($namesib $a => $b)                             ^^ here         { 

you need use different variable name loop:

        foreach($namesib $key => $value)         { 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -