-4

I'm trying to make a page where you search an IGN then it returns stats relevant to that player stored in the database.

This is my search.php page

<?php
mysql_connect ("185.14.187.33", "lightpvp","Notsayingpassword")  or die (mysql_error());
mysql_select_db ("lightpvp_test");

$term = $_POST['term'];

$sql = mysql_query("select * from Stats where IGN='%$term%'");

while ($row = mysql_fetch_array($sql)){
    echo 'Player Username: '.$row['IGN'];
    echo '<br/> Number of Kills: '.$row['Kills'];
    echo '<br/> Number of Deaths: '.$row['Deaths'];
    echo '<br/><br/>';
    }

?>

However it returns the error:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/51/11301251/html/mockup/search.php on line 9

Help? Thanks In Advance.

Hell_Yeah96
  • 23
  • 1
  • 5

1 Answers1

1

You may use LIKE instead of =. Try this:

    $sql = mysql_query("SELECT * FROM Stats WHERE IGN LIKE '%$term%'") or die (mysql_error());
echo_Me
  • 36,552
  • 5
  • 55
  • 77