473,411 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

mysql_fetch_array(): supplied argument is not a valid MySQL result

matheussousuke
249 100+
My cron job is sending this error on the email

Expand|Select|Wrap|Line Numbers
  1. <br />
  2. <b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result
  3. resource in <b>/home/xhost/public_html/portal/remindtrial.php</b> on line
  4. <b>19</b><br />
  5. Trial reminders sent!
  6.  

From the php code (gonna post just a part of it)


Expand|Select|Wrap|Line Numbers
  1. $sql_gettrial = "select orderid,userid from tblhosting where DATEDIFF(now(),regdate)=$remind_trial_days and (packageid=23)";
  2. $rs_gettrial = mysql_query($sql_gettrial);
  3.  
  4. while($row = mysql_fetch_array($rs_gettrial, MYSQL_ASSOC))
  5. {
  6. $orderid = $row['orderid'];
  7. $userid = $row['userid'];
  8. $rs_getemail = mysql_query("SELECT email FROM tblclients WHERE id = ".$userid."");
  9. $ada_email = mysql_numrows($rs_getemail);
  10.  
  11. while($rowemail = mysql_fetch_array($rs_getemail, MYSQL_ASSOC))
  12.     {
  13. $mailme = $rowemail['email'];


I'm getting this error, what's wrong with the command?
Mar 10 '11 #1
5 2575
Hello,

I think problem is in this line
Expand|Select|Wrap|Line Numbers
  1. $sql_gettrial = "select orderid,userid from tblhosting where DATEDIFF(now(),regdate)=$remind_trial_days and (packageid=23)";
  2.  
Change the above line with this below line

Expand|Select|Wrap|Line Numbers
  1. $sql_gettrial = "select orderid,userid from tblhosting where DATEDIFF(now(),regdate)= '".$remind_trial_days."' and (packageid = '23')";
  2.  
Revert back if any problem.

Regards,
Mayur Bhayani
Mar 10 '11 #2
johny10151981
1,059 1GB
You should always varify after after executing a query

after calling mysql_query function please check the returned resourse whether it is valid resource or it returned false.

I agree with Mayur your query is not right,

By The way Why use mysql_fetch_array? as far i have understood it takes double memory.

Use mysql_fetch_assoc, you will get string indexing.
Mar 10 '11 #3
Rabbit
12,516 Expert Mod 8TB
Line 8. You're using a single double quote when you should be using a single single quote.
Mar 10 '11 #4
matheussousuke
249 100+
It should be like this?

Expand|Select|Wrap|Line Numbers
  1. $rs_getemail = mysql_query('SELECT email FROM tblclients WHERE id = ".$userid."');
Mar 10 '11 #5
JKing
1,206 Expert 1GB
If userid is a string then this:
Expand|Select|Wrap|Line Numbers
  1. $rs_getemail = mysql_query("SELECT email FROM tblclients WHERE id = '".$userid."'");
  2.  
if it is an integer then this:
Expand|Select|Wrap|Line Numbers
  1. $rs_getemail = mysql_query("SELECT email FROM tblclients WHERE id = ".$userid);
  2.  
If you are not already using an editor that has syntax highlighting and coloring for strings, integers etc. you may want to look into getting one as they make it easier to tell where the quotes for your strings are malformed.

Another tip when working on your SQL strings is to print them out and verify that they look the way they are supposed to.
Mar 10 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the...
1
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
11
by: Breana | last post by:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/category.php on line 88 ------------------------------------------- It does this...
5
by: Mubs | last post by:
Hi, I 'am trying to connect my sql database with my webpage for users log in. i have got this script so far but i keep getting the following error message which i cannot figure out.. could any1...
4
by: fisherd | last post by:
When i run this code, i keep getting this message; Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\checklogin.php on line 26 i use this code to...
4
by: kalyanip14 | last post by:
Hi I am new to Php.I am trying to read My sql database data from table to php. I am getting this warning Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ...
11
by: chemlight | last post by:
I'm having a problem. I'm sure I'm going to kick myself over the answer... I have a table that stores vendors and their languages. This table starts out blank. I am querying the table to see if a...
2
by: perhapscwk | last post by:
When I run my site from localhost, no error, but when I move it to webhosting, it show below error, why? Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in...
0
Atli
by: Atli | last post by:
What to discuss: What is a "MySQL resource". What causes the error. How to fix it. Common Newbie Pitfalls This article is the second installment in a series of (hopefully) many, following...
9
by: Cxsey | last post by:
I get the following error code using this code: "Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource" It's on line 55 in this php script: <?php /** *...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.