Here is my code, it works like it is right now:
$con = @mysql_connect($server_name, $mysql_username, $mysql_password) or die("cannot connect");
mysql_select_db($db_name) or die("cannot select DB");
$sql="SELECT `idComp`,`nombre`,`foto` from RECURSOHUMANO;";
$result = mysql_query($sql);
$json= array();
if(mysql_num_rows($result)>0){
while($row=mysql_fetch_assoc($result)){
$json['Data'][]=$row;
}
}
mysql_close($con);
echo json_encode($json);
?>
The table that i'm working on has other columns and would like to add some of them to the SELECT query, but when I add another one, say apPat, it stops working.
Just to be clear Ill write how I would normally do it:
$sql="SELECT `idComp`,`nombre`,`apPat`,`foto` from RECURSOHUMANO;";
apPat is exactly like 'nombre', so I dont see why it doesn't work.
Also when I add other columns it works, it just breaks with a couple of them, but I need them.
UPDATE: Just to clarify. The MySQL query is correct, if I run it by itself it gives me what I want, even when I add the other columns. The problem, I think is in the php.