I have looked here (and many many many other places) before i asked my question.
I have tried the following formats '".$user_id." ''$user_id'
and even ?
to use as my variables holders, but im still getting the same error. I also tried to change from $_GET
to $_POST
.
Here's my code.
<?php
$connection = mysqli_connect("db_name", "user", "pass", "db") or die(mysqli_error($con);
$user_id = $_GET["user_id"];
$event_id = $_GET["event_id"];
$query = "SELECT * FROM user where user_id BETWEEN('".$user_id."'+1) and ('".$user_id."'+4);";
$query .= "SELECT * FROM user_in_event WHERE user_id = '".$user_id."' AND event_id = '".$event_id."' ";
if (mysqli_multi_query($connection, $query) or die(mysqli_error($connection).$query) ){
do {
/* store first result set */
if ($result = mysqli_store_result($connection) or die(mysqli_error($con))) {
while ($row = mysqli_fetch_assoc($result) or die(mysqli_error($con)))
$array[] = $row;
mysqli_free_result($result) or die(mysqli_error($con));
}
} while (mysqli_next_result($connection) or die(mysqli_error($con)));
}
header('Content-Type:Application/json');
echo json_encode($array);
?>
and this is the error
mysqli_error() expects parameter 1 to be mysqli null given
and i have checked on the DB itself and the querys works fine
*edit fixed "con" to "connection" but now instead of getting the result required im getting balnk