Can anyone please help me, i'm going crazy and can't see what i'm doing wrong! I have this basic SELECT query:
$locationQuery = mysqli_query($conn, "SELECT * FROM uk_towns where county = 'Dyfed'");
This returns 1,000 results... Perfect!
Now, if I do this:
$county = "Dyfed";
$locationQuery = mysqli_query($conn, "SELECT * FROM uk_towns where county = '$county'");
I get nothing?
@Dharman It still doesn't like it. f I use the variable, I don't get a result. If I manually type it in, it returns what I expect but I know the variable holds the correct data. This is what I have now:
$county = $userDetails['county'];
// $county = "Dyfed";
$town = $userDetails['town'];
$sql = "SELECT * FROM uk_towns WHERE county=? AND name=?";
$stmt = mysqli_stmt_init($conn);
mysqli_stmt_bind_param($stmt, "ss", $county, $town);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result)) {
echo $row['id'];
}