<?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];
}
?>
Asked
Active
Viewed 62 times
-3
-
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 Answers
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.
Tommy
- 377
- 1
- 9