-2

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a3332804/public_html/lib/configuration.php on line 22 .

I got error while uploading php in my database

<?


  session_start ();

  if (!$stop_eval)
  {

    global $c;
    if(is_dir('install/'))
    {
    header("Location: install/");
    }



    if(defined('DB_DETAILS') && $c && !$error_log) {

    if(!$_SESSION['setting'])
    {
    $setq = mysql_query("SELECT * FROM settings");
    while ($r=mysql_fetch_array ($setq))    - this is the line 22 in my database 
    {
    $set[$r[set_name]] = $r['set_value'];
    $_SESSION['setting'][$r[set_name]] = $r['set_value'];
gen_Eric
  • 214,658
  • 40
  • 293
  • 332
mac singh
  • 9
  • 2
  • Really? None of the 900,000 duplicates shown to you in the _Related_ sidepane as you wrote your question were relevant to you? – Lightness Races in Orbit Dec 08 '14 at 18:24
  • **WARNING**: `mysql_query` is an obsolete interface and should not be used in new applications as it's being removed in future versions of PHP. A modern replacement like [PDO is not hard to learn](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/). If you're new to PHP, a guide like [PHP The Right Way](http://www.phptherightway.com/) can help explain best practices. If this is new code, don't even bother fixing these errors, instead switch to using a modern interface to execute your queries. – tadman Dec 08 '14 at 18:34

2 Answers2

1

This error means your query failed.

Your query could be failing due to a missing/wrong table or field. To see the detailed error, print out the result of mysql_error().

The mysql_* library is deprecated. It is recommended to upgrade to MySQLi or PDO.

mickmackusa
  • 37,596
  • 11
  • 75
  • 105
ashkufaraz
  • 5,064
  • 6
  • 49
  • 79
1

Are you connecting to the db properly before this snippet of code?

You should have something like

mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("") or die(mysql_error());
gen_Eric
  • 214,658
  • 40
  • 293
  • 332
Isma
  • 41
  • 2
  • 9