-3
 <?php
$sitename = "csgodrugs.net";
$link = mysql_connect(" mysql.hostinger.ro", "u550413281_cosmi", "***********");          //DB!!     //IP,NICK,PW!!!
$db_selected = mysql_select_db('csgon', $link);      //NAME OF DATABASE
mysql_query("SET NAMES utf8");

function fetchinfo($rowname,$tablename,$finder,$findervalue) {
    if($finder == "1") $result = mysql_query("SELECT $rowname FROM $tablename");
    else $result = mysql_query("SELECT $rowname FROM $tablename WHERE `$finder`='$findervalue'");
    $row = mysql_fetch_assoc($result);
    return $row[$rowname];
}
?>
Saty
  • 22,213
  • 7
  • 30
  • 49
  • Change `$rowname` to your exact table name and stop using `mysql` – Chay22 Apr 05 '16 at 07:54
  • `mysql_*` has been deprecated since PHP version 5.5 and has been removed in version 7, if you want to ever consider upgrading your PHP version to 7 then you should switch to `mysqli_*` or `PDO`. Also don't execute a raw query `SET NAMES` as it makes `mysql(i)` unable to properly detect the character encoding. – apokryfos Apr 05 '16 at 08:03

1 Answers1

0

Try this:

function fetchinfo($rowname,$tablename,$finder,$findervalue) {
if($finder == "1") $result = mysql_query("SELECT '$rowname' FROM '$tablename'");
else $result = mysql_query("SELECT '$rowname' FROM '$tablename' WHERE '$finder'='$findervalue'");
$row = mysql_fetch_assoc($result);
return $row[$rowname];
}

Just tidied up where you should of used '', when targeting variables in a select statement.

You should also use MySQLi functions instead of MySQL functions, as MySQL functions were depreciated in PHP 5.5, and removed in PHP 7.0.

http://www.w3schools.com/php/php_ref_mysqli.asp

Tommy
  • 377
  • 1
  • 9