MySQL functions are deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.
Since you have nothing to notify you or your app that the query failed, you're getting a blank page.
You also call $id
versus $gelenid
, so you're passing a NULL to your query. $id
is not defined. Here is an example of your code with a Error catch:
<?php
header('Content-Type: text/html; charset=utf-8');
require_once("connect.php");
if(isset($_POST['id'])){
$gelenid = $_POST['id'];
} else {
$gelenid = $_GET['id'];
}
$sql_query = sprintf("select * from places where ADDED_BY='%d'", $gelenid);
if(!mysql_query($sql_query)){
$error = array("error" => mysql_errno($link) . ": " . mysql_error($link));
echo json_encode($error)
} else {
$sonucDizisi['basliklar'] = array();
while($oku=mysql_fetch_array(mysql_query($sql_query))){
$temp['ilan'] = $oku['TITLE'];
array_push($sonucDizisi['basliklar'], $temp);
}
echo json_encode($sonucDizisi);
}
?>
** EDIT**
From your comments, it sounds like you would like to see an example in MySQLi. Be aware that there are tons of examples at php.net and I will show you one here:
<?php
header('Content-Type: text/html; charset=utf-8');
if(isset($_POST['id']))
$gelenid = $_POST['id'];
else
$gelenid = $_GET['id'];
}
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
$error = array("Error" => "Connect failed: " . mysqli_connect_error();
echo json_encode($error);
exit();
}
/* create a prepared statement */
if ($stmt = $mysqli->prepare("SELECT * FROM places WHERE ADDED_BY=?")) {
/* bind parameters for markers */
$stmt->bind_param("i", $gelenid);
/* execute query */
if(!$stmt->execute()){
$error = array("error" => $stmt->errno . ": " . $stmt->error);
echo json_encode($error);
$stmt->close();
$mysqli->close();
exit();
}
$result = $stmt->get_result();
$sonucDizisi['basliklar'] = array();
while ($oku = $result->fetch_assoc()) {
$temp['ilan'] = $oku['TITLE'];
array_push($sonucDizisi['basliklar'], $temp);
}
echo json_encode($sonucDizisi);
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
?>