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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • matheussousuke
    New Member
    • Sep 2009
    • 249

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

    My cron job is sending this error on the email

    Code:
    <br />
    <b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result
    resource in <b>/home/xhost/public_html/portal/remindtrial.php</b> on line
    <b>19</b><br />
    Trial reminders sent!

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


    Code:
    $sql_gettrial = "select orderid,userid from tblhosting where DATEDIFF(now(),regdate)=$remind_trial_days and (packageid=23)";
    $rs_gettrial = mysql_query($sql_gettrial);
    
    while($row = mysql_fetch_array($rs_gettrial, MYSQL_ASSOC))
    {
    $orderid = $row['orderid'];
    $userid = $row['userid'];
    $rs_getemail = mysql_query("SELECT email FROM tblclients WHERE id = ".$userid."");
    $ada_email = mysql_numrows($rs_getemail);
    
    while($rowemail = mysql_fetch_array($rs_getemail, MYSQL_ASSOC))
    	{
    $mailme = $rowemail['email'];


    I'm getting this error, what's wrong with the command?
  • Mayur2007
    New Member
    • Aug 2007
    • 67

    #2
    Hello,

    I think problem is in this line
    Code:
    $sql_gettrial = "select orderid,userid from tblhosting where DATEDIFF(now(),regdate)=$remind_trial_days and (packageid=23)";
    Change the above line with this below line

    Code:
    $sql_gettrial = "select orderid,userid from tblhosting where DATEDIFF(now(),regdate)= '".$remind_trial_days."' and (packageid = '23')";
    Revert back if any problem.

    Regards,
    Mayur Bhayani

    Comment

    • johny10151981
      Top Contributor
      • Jan 2010
      • 1059

      #3
      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_arr ay? as far i have understood it takes double memory.

      Use mysql_fetch_ass oc, you will get string indexing.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Line 8. You're using a single double quote when you should be using a single single quote.

        Comment

        • matheussousuke
          New Member
          • Sep 2009
          • 249

          #5
          It should be like this?

          Code:
          $rs_getemail = mysql_query('SELECT email FROM tblclients WHERE id = ".$userid."');

          Comment

          • JKing
            Recognized Expert Top Contributor
            • Jun 2007
            • 1206

            #6
            If userid is a string then this:
            Code:
            $rs_getemail = mysql_query("SELECT email FROM tblclients WHERE id = '".$userid."'");
            if it is an integer then this:
            Code:
            $rs_getemail = mysql_query("SELECT email FROM tblclients WHERE id = ".$userid);
            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.

            Comment

            Working...