Search code examples
phpjsonrestget

Using parameters in a GET request


I know this sound simple but this has been troubling me for a while, i have a simple get request and it just doesnt work when i try to use parameters, if i just use a full query it works, but if i try to use parameters it just wont

this is my code

<?php
include('function.php');
$dni=$_GET["DNI"];


if($resultset=getSQLResultSet("SELECT * FROM `table` WHERE DNI='$dni'")){
    while ($row = $resultset->fetch_array(MYSQLI_NUM)){
        echo json_encode(var_dump( $row));
    }
}

?>

now, no matter what value dni has it just doesnt work i just get an empty json

array(5) { [0]=> string(0) "" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(0) "" [4]=> string(0) "" } null

like so

but if i just change that query to

SELECT * FROM table WHERE DNI= 1111

it returns what it has to return for that dni

the parameter is the problem, but i dont know whats wrong about it


Solution

  • Solved, i was asking for "dni" when i should've been asking for "DNI"