Can't find the problem in this code
Posted: Sat Sep 22, 2012 5:05 am
Hi,
Here is my code, it seems there is some problem with it:
userAreaOfWorkArray is an array that I am posting via ajax from javascript code.
Please HELP ME!!
Here is my code, it seems there is some problem with it:
Code: Select all
<?php
require_once 'connection.php';
$link = conenct('localhost', 'root', '', 'w_db');
mysql_query( "SET NAMES utf8" );
mysql_query( "SET CHARACTER SET utf8" );
mysql_set_charset('utf8', $link);
Class AreaInfo{
public $areaNmae;
public $areaId;
public $areaTableName;
}
$areaOfWorkArray = json_decode($_POST['userAreaOfWorkArray']); // userAreaOfWorkArray is an array
$areaInfoArray = Array();
foreach ($areaOfWorkArray as $key){
$key = mysql_real_escape_string($key);
$tmpObj = new AreaInfo();
$tmpObj->areaId = $key;
$query = mysql_query("SELECT areaOfWork, tableName FROM area_of_work WHERE id = '$key'");
$query = mysql_fetch_assoc($query);
$tmpObj->areaNmae = $query['areaOfWork'];
$tmpObj->areaTableName = $query['tableName'];
array_push($areaInfoArray, $tmpObj);
}
echo json_encode($areaInfoArray);
?>
Please HELP ME!!