PHP MySQLi获取数组自动递增int失败[重复]

I currently have a table which has an int(11) called lindex.

In another table "landtb" it has an auto_increment index int(11) called index.

I've checked to see that both have the correct variable, which is 4.

the query and code involved is:

$lindex = $addressRow['lindex'];
$landQuery = \mysqli_query($connection, "SELECT * FROM landtb WHERE index='$lindex'");
$landRow = \mysqli_fetch_array($landQuery);

I've echo'd the content of $lindex and it shows the correct value also of "4", but when I run the code I get the following:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\Documents and Settings\Garry\My Documents\Dropbox\htdocs\Websites\The_Archive\propertySQL.php on line 43

If I change lindex to a string, and then also change landQuery's WHERE to looks at a name it works fine and pulls the row. So for some reason its just having issues searching with index.

I've been at it for an hour now, and I get the feeling I'm going to have done something really stupid like leaving of semi-colon in c. I don't thing it'll have any effect on the question, but I'm using netbeans.

Any help would be appreciated.

</div>

index is a reserved keyword in MySQL, you have to quote it with backticks if you want to use it as a column name:

$landQuery = \mysqli_query($connection, "SELECT * FROM landtb WHERE `index`='$lindex'");

You should always check for failure of your queries:

if (!landQuery) {
    die (mysqli_error($connection));
}

This will show the MySQL error message. It probably says that you have a syntax error near index.