There are several questions with similar titles, but all of them seem to have more complicated queries than what I am working with.
I'm trying to use a variable as part of a select query. The variable $theindex indicates the value for the field theindex which I am selecting for.
This is the code I am trying to use, which generates HTTP ERROR 500...
$sql_stmt = "SELECT * FROM products WHERE theindex='$theindex'";
$result = mysqli_query($conn,$sql_stmt);
This works...
$sql_stmt = "SELECT * FROM products WHERE theindex='1'";
$result = mysqli_query($conn,$sql_stmt);
Clearly the apostrophes around $theindex may be causing the problem, but all the approaches that I've tried thus far don't help and just generate HTTP ERROR 500. How can I use a variable in this select query?
Thank you for taking a look at this.