Jump to content

Mysqli query


ecabrera

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'];

}

Link to comment
https://forums.phpfreaks.com/topic/274229-mysqli-query/
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

Link to comment
https://forums.phpfreaks.com/topic/274229-mysqli-query/#findComment-1411121
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.