-3

In my template.php file i am getting the above error in the following lines :

$config=mysql_fetch_array(mysql_query("select * from sbjbs_config "));
$icons=mysql_fetch_array(mysql_query("select * from sbjbs_icons where sb_id=".$config["sb_icon_list"]));
Shankar Narayana Damodaran
  • 66,874
  • 43
  • 94
  • 124

3 Answers3

0

Check your query once more before passing it to mysql_fetch_array. You'll find that it's false because the query failed. Before asking question please browse.

  • i m not getting u....can u just suggest me wot editing i need to do xactly...means do i need to add sumthing to it???...somewhere i also read that mysql_query is deprecated that's y it is showing error – user3510004 Apr 08 '14 at 10:28
0

Check your DB connection and Database Table name is as same as

sbjbs_config

and also check you got accessibility to Database (check it manually using PHP myadmin..

Check this Link

Then you should have some other problems , will you please post program codings , then only it is possible to check whats happening wrong

Community
  • 1
  • 1
yoostink
  • 50
  • 5
0

You are doing it completely wrong. First, MySQL extension is deprecated, use MySQLi or PDO_MySQL instead.

Next, mysql_fetch_array requires first parameter to be a resource. But mysql_query sometimes returns a boolean value, for example on error. So it's not a good idea to pass return value of mysql_query directly to mysql_fetch_array function. See examples on mysql_query manual page.

You can also use the function mysql_error to print error message, when mysql_query returns false.

Generally you should test what mysql_query returns before you call function, which works with the query results.

As I mentioned above, it's better to not use this deprecated extension. But you should work the same way as I have described with another extensions too.

David Ferenczy Rogožan
  • 21,531
  • 8
  • 75
  • 67
  • i replaced mysql with mysqli...nd after that i have replaced it with:$result=mysqli_query("select * from sbjbs_config "); $config=mysqli_fetch_array($result); – user3510004 Apr 08 '14 at 12:01
  • Well, and what about `mysql_error`? What error message did you get? Do you test, if `$result` contains resource before passing it to the function `mysqli_fetch_array`? – David Ferenczy Rogožan Apr 08 '14 at 13:42