-5
<?php

$sitename = "Site Name";

$link = mysql_connect("localhost", "username", "password");

$db_selected = mysql_select_db('databasename', $link);

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

?>

Having a unknown problem i dont know why but its saying that

Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u759655205/public_html/set.php on line 9

Line 9 : else $result = mysql_query("SELECT $rowname FROM $tablename WHERE$finder='$findervalue'");

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Deivids
  • 45
  • 1
  • 5
  • 3
    It is saying it's deprecated because [it's deprecated](http://php.net/manual/en/function.mysql-query.php). – al'ein Aug 28 '15 at 13:38
  • 1
    The error is literally telling you what the issue is. `mysql_query` is [deprecated](http://php.net/manual/en/function.mysql-query.php)... – Ankh Aug 28 '15 at 13:38
  • Deprecated means that it is going to be removed from PHP in the future, specifically in November of this year with the release of PHP7 – Mark Baker Aug 28 '15 at 13:38
  • [Here is an example of what happens when you continue to use `mysql_*` functions.](http://stackoverflow.com/questions/26299564/php-version-upgraded-cannot-use-few-functions) Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Aug 28 '15 at 13:39
  • In short, prepared statements are much nicer in terms of constructing a query, and they help protect against SQL injection attacks. – Shotgun Ninja Aug 28 '15 at 14:01

1 Answers1

1

the MySQL module is depreciated in PHP5, instead use

MySQLi is very similar to MySql in PHP with some major changes.

If you must use MySQL you have the option of surpressing errors

from another post: php mysql_connect Warning disable

$dblink = @mysql_connect(DBHOST_LOCAL, DBUSER, DBPASS);

if (!$dblink) 
{
    $dblink = @mysql_connect(DBHOST_REMOTE, DBUSER, DBPASS);                  
}

if (!$dblink)
{
    $message = sprintf(
        "Could not connect to local or remote database: %s",
        mysql_error()
    );
    trigger_error($message);
    return;
}

I advise you to use this form of error suppressing since your error is specific.

Community
  • 1
  • 1
THE AMAZING
  • 1,496
  • 2
  • 16
  • 38