having problem with the code at the last if else (string and array) part

i am trying to run the code on server end but an error is occurring at the end of the code. can please help me to correct the code???

$adminid = $_REQUEST[‘adminid’];

	$selectemployee = mysql_query("select * from employee where adminid = '".$adminid."'");
 	$posts = array();
       if(mysql_num_rows($selectemployee)) 
	      {
		       while($post = mysql_fetch_assoc($selectemployee)) 
                 {
		            $posts[] = $post;
                 }
	                 
	           header('Content-type: application/json');
	           echo stripslashes(json_encode(array('[b]employee'=>$posts[/b])));
			     	          }
	   else 
	      {
	            header('Content-type: application/json');
                echo stripslashes(json_encode(array('[b]employee'=>'No record'[/b])));
	      }

I think this is what your trying to accomplish?

[php]header(‘Content-type: application/json’);
$array = array(‘employee’=>$posts);
echo stripslashes(json_encode($array));[/php]

You should use mysqli or PDO.

Sponsor our Newsletter | Privacy Policy | Terms of Service