Variable out of scope when entering a while loop in php

I have a problem when trying to populate an array in php. It seems that once I enter a while loop with a mysql_fetch_assoc method I cannot populate my array. I've included the code below.\[code\] $params = $_REQUEST['params'];\[code\]$arr["status"]="ok";$projects=array();$files=array();$titles=array();$query = 'SELECT p.id as pid, f.fname as name, f.title FROM proj p INNER JOIN pic f ON f.projid=p.id WHERE p.catid=\'' . $params['category'] . '\' ORDER BY p.ordr, f.ordr';require("../php/connect.php");//select all projects from chosen category and pics from selected projects$proj_result = mysql_query($query) or die ("Select failed");//populate from rowswhile($row = mysql_fetch_assoc($proj_result)){ $projects[]=$row["pid"]; $files[]=$row["name"]; $titles[]=$row["title"];}$arr["projects"]=$projects;$arr["files"]=$files;$arr["titles"]=$titles;echo json_encode($arr);\[/code\]\[/code\]The result: {"status":"ok","projects":[],"files":[],"titles":[]}Thank You.
 
Back
Top