Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange SELECT query issue

Status
Not open for further replies.

pjwhitfield

Programmer
Sep 14, 2013
1
GB
I have the following (Ive changed field names and table for ease of posting) very simple code:

$sql = "SELECT a,b,c,d FROM `tableA` WHERE a='Y' ORDER BY RAND()";
$result = mysqli_query(login(),$sql);

all works fine....however Ive decided to add a further bit of functionality so have added field 'e' to TableA and changed $sql to
$sql = "SELECT a,b,c,d,e FROM `tableA` WHERE a='Y' ORDER BY RAND()";

thats all Ive changed, simply asked it to return an additional field.

yet, on running I get the following error.

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in......

If, however I replace the d with an e to "SELECT a,b,c,e..." or any of the other fields then all is fine, its only if I add field e, Ive tried adding it elsewhere in the statement eg "SELECT a,b,e,c,d..." but still the same. Its as if its set to only return 4 fields???

Strange one that no doubt has a simple answer but its losing me!
 
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in......

That simply means your query is not returning any results but rather an error of some kind.

You can explicitly ask for the error being returned by doing:

Code:
$result = mysqli_query(...) [b][red]or die(mysqli_error());[/red][/b]






----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top