nzorb Posted June 3, 2011 Share Posted June 3, 2011 I've got this and it gives me that warning. Row is null before and after the command. What am I doing wrong? $row=mysql_fetch_array(mysql_query("SELECT I.ITEM_ID AS ID,I.DESCR AS DESCR,W.QUANTITY AS QUANT,W.PRICE AS PRICE FROM ITEM I JOIN WANTS_TO_BUY W ON I.ITEM_ID=W.ITEM_ID JOIN USER U ON U.USERNAME=W.USERNAME WHERE U.USERNAME='%id'")); (I also posted this in php help cause I'm not sure where it belongs, please tell me so I can delete the wrong post) Quote Link to comment https://forums.phpfreaks.com/topic/238273-mysql_fetch_array-needs-refference-and-not-boolean-warning/ Share on other sites More sharing options...
trq Posted June 3, 2011 Share Posted June 3, 2011 Passing the data returned from mysql_query() directly to mysql_fetch_array() is ridiculous, you need to check this result before using it. Quote Link to comment https://forums.phpfreaks.com/topic/238273-mysql_fetch_array-needs-refference-and-not-boolean-warning/#findComment-1224475 Share on other sites More sharing options...
nzorb Posted June 3, 2011 Author Share Posted June 3, 2011 the result should be fine, if by checking you mean something simple like this: if ($result=mysql_query("SELECT I.ITEM_ID AS ID,I.DESCR AS DESCR,W.QUANTITY AS QUANT,W.PRICE AS PRICE FROM ITEM I JOIN WANTS_TO_BUY W ON I.ITEM_ID=W.ITEM_ID JOIN USER U ON U.USERNAME=W.USERNAME WHERE U.USERNAME='%id'")) $row=mysql_fetch_array($result); else echo 'error'; I've done that and get the same error. PS: tnx for moving it, I wasn't sure where it belonged, it has a bit of both. Quote Link to comment https://forums.phpfreaks.com/topic/238273-mysql_fetch_array-needs-refference-and-not-boolean-warning/#findComment-1224487 Share on other sites More sharing options...
kenrbnsn Posted June 3, 2011 Share Posted June 3, 2011 A better way is (IMHO) <?php $q = "SELECT I.ITEM_ID AS ID,I.DESCR AS DESCR,W.QUANTITY AS QUANT,W.PRICE AS PRICE FROM ITEM I JOIN WANTS_TO_BUY W ON I.ITEM_ID=W.ITEM_ID JOIN USER U ON U.USERNAME=W.USERNAME WHERE U.USERNAME='%id'"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); $row = mysql_fetch_assoc($rs); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/238273-mysql_fetch_array-needs-refference-and-not-boolean-warning/#findComment-1224496 Share on other sites More sharing options...
nzorb Posted June 3, 2011 Author Share Posted June 3, 2011 tnx ken that seems to fix the error but $row is still null the sql query should be correct cause I'm running it over in mysql admin and returns the one line it should. Quote Link to comment https://forums.phpfreaks.com/topic/238273-mysql_fetch_array-needs-refference-and-not-boolean-warning/#findComment-1224501 Share on other sites More sharing options...
Pikachu2000 Posted June 3, 2011 Share Posted June 3, 2011 If it's running without errors, it must be returning an empty results set. Is %id supposed to be $id, perhaps? Quote Link to comment https://forums.phpfreaks.com/topic/238273-mysql_fetch_array-needs-refference-and-not-boolean-warning/#findComment-1224502 Share on other sites More sharing options...
nzorb Posted June 3, 2011 Author Share Posted June 3, 2011 *goes in the corner and shoots his face off* yup it should :S tnx Quote Link to comment https://forums.phpfreaks.com/topic/238273-mysql_fetch_array-needs-refference-and-not-boolean-warning/#findComment-1224504 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.