I am writing a very simple REST service using a single get method in PHP. I am very new to PHP but am finding it a great framework whilst trying to understand all of the functions.
My API was working well & returning data as a JSON array very quickly but before I push it live, I was worried about SQL injections taking place & from reading online found a fairly quick method of preventing these could be to add a SQL prepare for the DB to parse the query & variables seperatly. My Variable within the get request is an SHA512 hashed string & the API is running within a HTTPS environment also.
The piece I am struggling with is as per below:
$stmt = mysqli_prepare ($link, "select blah,blah from people WHERE hashed = ? and blah <>''" );
        //binding SQL parameters
        mysqli_stmt_bind_param($stmt, 's', $e);
        // excecute SQL statement
        mysqli_stmt_execute($stmt);
        //get results
        $result = mysqli_stmt_get_result($stmt);
}
        //Set 405 status if wrong method is used.
        else {
             $result = http_response_code(405); 
        }
//debug variable check & SQL results row count
echo $e;        
echo mysqli_num_rows($result); 
I know that my variables for $link are working as expected as they were working previously to pull in a connection string from an included seperate file.
At present the debug echo of $e is returning the variable as expected but the rowcount is 0.
If I run the query in SQL server, the query returns results as expected. I'm using MAMP (not pro) so am unsure of a SQL profiler too as well. I think my issue is with parameter binding somewhere.
Thanks in advance
