4 Replies - 8339 Views - Last Post: 30 May 2011 - 04:59 AM Rate Topic: *---- 3 Votes

#1 clarkeash  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 56
  • Joined: 04-February 11

mysql_fetch_array supplied argument is not a valid mysql result resour

Posted 30 May 2011 - 04:19 AM

I know that this issue has probably been posted 100 times already but I am getting the following error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/qrsharec/public_html/dev/minda/user.php on line 25

Here is my code

<?php
$uid = $_GET['id'];
$page['title'] = 'User Management';
include('header.php');
include('nav.php');
include('sidebar.php');
include('config.inc');
?>
<?php 
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}
$result = mysql_query("SELECT tbl_user.id_user, tbl_user.f_name, tbl_user.s_name, tbl_user.u_name, tbl_user.log_ip, tbl_type.name, tbl_user.activate, tbl_user.d_join, tbl_user.last_login, tbl_type.fileqty, tbl_type.memoqty, tbl_user.files, tbl_user.memo, tbl_user.comment
FROM tbl_user, tbl_type
WHERE tbl_user.type = tbl_type.id_type
AND tbl_user.id_user = '$uid'");
while($row = mysql_fetch_array($result)){
$message = $row['comment'];
$status = $row['activate'];
$fname = $row['f_name'];
$sname = $row['s_name'];
$uname = $row['u_name'];
$file_max = $row['fileqty'];
$memo_max = $row['memoqty'];
$file_used = $row['files'];
$memo_used = $row['memo'];
$file_percent = ($file_used/$file_max)*100;
$file_pc = round($file_percent,0);
$memo_percent = ($memo_used/$memo_max)*100;
$memo_pc = round($memo_percent,0);
$plan = $row['name'];
if($row['log_ip'] ==''){
$ip = 'N/A';
}else{
$ip = $row['log_ip'];
}
$d_join = $row['d_join'];
list($yr,$month,$day)    =    split('-',$d_join);
$djoin = date("l j F Y", mktime(0, 0, 0, $month, $day, $yr));
$last_login = $row['last_login'];
list($lyr,$lmonth,$lday)    =    split('-',$last_login);
$ll_date = date("l j F Y", mktime(0, 0, 0, $lmonth, $lday, $lyr));
}
mysql_close()
?>



Works fine locally, but I get the error when the file is live, I have checked my error logs in cpanel and nothing has showed up!

Thanks in advanced

Is This A Good Question/Topic? 0
  • +

Replies To: mysql_fetch_array supplied argument is not a valid mysql result resour

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6109
  • View blog
  • Posts: 23,666
  • Joined: 23-August 08

Re: mysql_fetch_array supplied argument is not a valid mysql result resour

Posted 30 May 2011 - 04:39 AM

Yes, yes it has been posted 100 (million) times before. So did you even bother to search or look in the FAQ, Guides and Resources topic, where it's listed in The Giant PHP List of Common Problems?
Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: mysql_fetch_array supplied argument is not a valid mysql result resour

Posted 30 May 2011 - 04:40 AM

your query fails, that may be due to differences in the local and live database, add or die(mysql_error()); to line #24. additionally you have a syntax error on line #52.

This post has been edited by Dormilich: 30 May 2011 - 04:40 AM

Was This Post Helpful? 1
  • +
  • -

#4 clarkeash  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 56
  • Joined: 04-February 11

Re: mysql_fetch_array supplied argument is not a valid mysql result resour

Posted 30 May 2011 - 04:57 AM

View PostJackOfAllTrades, on 30 May 2011 - 04:39 AM, said:

Yes, yes it has been posted 100 (million) times before. So did you even bother to search or look in the FAQ, Guides and Resources topic, where it's listed in The Giant PHP List of Common Problems?

Yes I did and all over google, I came here for advise not rudeness

View PostDormilich, on 30 May 2011 - 04:40 AM, said:

your query fails, that may be due to differences in the local and live database, add or die(mysql_error()); to line #24. additionally you have a syntax error on line #52.

Thanks I think i know what i have done (will check shortly)
what is wrong with the use of
mysql_close()
???

Thanks

Clarkeash

This post has been edited by clarkeash: 30 May 2011 - 04:58 AM

Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: mysql_fetch_array supplied argument is not a valid mysql result resour

Posted 30 May 2011 - 04:59 AM

it could be ok since it is the last command before ?>, but any additional line will throw you off (isnít there missing something?)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1