ecabrera Posted February 8, 2013 Share Posted February 8, 2013 (edited) i keep getting PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given i am new to mysqli $get = $_GET['game']; if(!empty($get)){ require "scripts/db.ini.php"; $select = "SELECT * FROM games WHERE game=`$get`"; $return = mysqli_query($db,$select); $row = mysqli_fetch_assoc($return); echo $row['game']; } Edited February 8, 2013 by ecabrera Quote Link to comment https://forums.phpfreaks.com/topic/274229-mysqli-query/ Share on other sites More sharing options...
awjudd Posted February 8, 2013 Share Posted February 8, 2013 (edited) You have ticks in your query when I'm guessing they should be quotes. // Current $select = "SELECT * FROM games WHERE game=`$get`"; // Should be (if $get is a string) $select = "SELECT * FROM games WHERE game='$get'"; // Should be (if $get is a int) $select = "SELECT * FROM games WHERE game=$get"; Please note: you should either be validating the value in $_GET['game'], using an escape-string type function or database parameters. Otherwise there will be SQL injection. ~awjudd Edited February 8, 2013 by awjudd Quote Link to comment https://forums.phpfreaks.com/topic/274229-mysqli-query/#findComment-1411121 Share on other sites More sharing options...
Barand Posted February 8, 2013 Share Posted February 8, 2013 If you check for errors you will probably find that that the query fails. Put single quotes, not backticks (`) , around $get Quote Link to comment https://forums.phpfreaks.com/topic/274229-mysqli-query/#findComment-1411124 Share on other sites More sharing options...
ecabrera Posted February 8, 2013 Author Share Posted February 8, 2013 Thanks so much works i didn't know i was using ` Quote Link to comment https://forums.phpfreaks.com/topic/274229-mysqli-query/#findComment-1411129 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.