Jump to content

Mysqli query


ecabrera
 Share

Recommended Posts

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 by ecabrera
Link to comment
Share on other sites

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 by awjudd
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.