Warning: mysql_num_rows() expects parameter

Discussion in 'PHP' started by XXx_Death_xXX, Feb 28, 2014.

  1. #1
    1 ===== Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:webroot\app\app\customer.php on line 627

    2 ===== Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\webroot\app\app\customer.php on line 101

    3 ===== Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\webroot\app\app\customer.php on line 248
    4 ===== Undefined variable: currMin in C:\webroot\app\app\customer.php on line 670
    I Post file that is uploaded i
     

    Attached Files:

    Last edited: Feb 28, 2014
    XXx_Death_xXX, Feb 28, 2014 IP
  2. skible

    skible Member

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    41
    #2
    so basicly this is one piece that causes an error:

    function fetch($que, $type = null) {
                if (!$type) {
                    $assoc = mysql_fetch_assoc( $que );
                    return $assoc;
                }
    
    
                if ($type == 'array') {
                    $arr = mysql_fetch_assoc( $que );
                    return $arr;
                }
    
    
                if ($type == 'row') {
                    $row = mysql_fetch_row( $que );
                    return $row;
                }
    
                return false;
            }
    PHP:
    I don't know how much php you know. But what the PHP error is saying is that $que is a boolean. When you want to call this function somewhere you have to do fetch(parameter1, parameter2). It looks like that parameter1 is a boolean instead of resource.

    A resource could be something like this:
    $result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
    Code (markup):
    $result is a resource.

    So basically you should track what it puts in. We can't see much with this code...
     
    skible, Feb 28, 2014 IP
  3. XXx_Death_xXX

    XXx_Death_xXX Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    33
    #3
    Thanks for fast reply sir

    i see somewhere this error too in my php


                if ($type == 'row') {
                    $row = mysql_fetch_row( $que );
                    return $row;
                }
    PHP:

    let me check and i am not very expert in PHP
     
    XXx_Death_xXX, Feb 28, 2014 IP
  4. skible

    skible Member

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    41
    #4
    that's the same thing. The $que is not declared right.
     
    skible, Feb 28, 2014 IP
  5. XXx_Death_xXX

    XXx_Death_xXX Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    33
    #5
    how to fix this please
     
    XXx_Death_xXX, Feb 28, 2014 IP
  6. skible

    skible Member

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    41
    #6
    Post the pages on which you used the function.
     
    skible, Feb 28, 2014 IP
  7. HassanKhalid

    HassanKhalid Active Member

    Messages:
    158
    Likes Received:
    6
    Best Answers:
    4
    Trophy Points:
    90
    #7
    change variable name paste the code here.
     
    HassanKhalid, Feb 28, 2014 IP
  8. XXx_Death_xXX

    XXx_Death_xXX Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    33
    #8
    code i already pasted top
     
    XXx_Death_xXX, Feb 28, 2014 IP
  9. HassanKhalid

    HassanKhalid Active Member

    Messages:
    158
    Likes Received:
    6
    Best Answers:
    4
    Trophy Points:
    90
    #9
    customer.php code
     
    HassanKhalid, Feb 28, 2014 IP
  10. XXx_Death_xXX

    XXx_Death_xXX Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    33
    #10
     

    Attached Files:

    XXx_Death_xXX, Feb 28, 2014 IP
  11. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #11
    You need to show us how you're using the PHP-class/functions in the code you pasted (as a text-file) above. Ie, what is being given to the functions, what does the $que-variable hold, etc.
    If you're using it wrong, it will throw errors, and since you're not providing the proper information, it's hard to know what is wrong. But my guess is that your query/result isn't returning what the function expects. Reposting the code you've already posted doesn't really help...
     
    PoPSiCLe, Feb 28, 2014 IP
  12. XXx_Death_xXX

    XXx_Death_xXX Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    33
    #12
    what u mean what i must share here u mean i must share full software

    ?
     
    XXx_Death_xXX, Feb 28, 2014 IP
  13. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #13
    No. But somewhere, you're USING this class (the one you've shared with us) - HOW do you use this class? As far as I could see by a quick look, that's all one huge class, with a lot of functions tucked inside it - there might be nothing wrong with the class itself (probably isn't), but the way you're implementing it is not correct - as others have pointed out, the $que-parameter (for each of the errors you're getting), is a boolean (1:0 or true:false) instead of a proper query, or similar. This can, for instance, happen if you try to run a malformed query, or the query is doing some sort of comparison and returning either true or false depending on the output (bort of these won't work in the class you posted above).
    The point is, we've given you a lot of pointers - read up on the error-message you've gotten (paste it into google, just this bit: "mysql_num_rows() expects parameter 1 to be resource, boolean given") and read up on what the error means.
     
    PoPSiCLe, Feb 28, 2014 IP
  14. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #14
    There are a lot of issues with that code, which looks to be circa the end of PHP 4's life cycle; most of it will be throwing errors and warnings like CRAZY under PHP 5.4/later it's that badly out of date. The long deprecated 'var' property, lack of scopes on methods... and that's before talking the just plain badly written nonsense like variables for nothing, nested IF doing case's job, etc, etc...

    ... and as PoPSiCLe is saying, we STILL aren't seeing enough of this to say what's wrong since we can't see what's calling this class and/or how it's being called.

    ... but if I was handed this code, I'd figure out what it's trying to do, and pitch it in the trash to start over from scratch as it's so poorly written and so badly out of date, it would take less time to rewrite from scratch than it would to try and fix.
     
    deathshadow, Feb 28, 2014 IP
  15. XXx_Death_xXX

    XXx_Death_xXX Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    33
    #15
    i told u al that i am nto programmer i have downaod script from somewhere and i m getring this error if u guys want i can send u script full with back up if u really can fix this error then u can check what ever u ned there

    Thansk for helping
     
    XXx_Death_xXX, Mar 1, 2014 IP
  16. XXx_Death_xXX

    XXx_Death_xXX Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    33
    #16
    There is Some file which are related to This file which show up me error

    http://www.mediafire.com/download/85bmtukjn043knn/FILES.zip

    hope now maybe u guys get solution

    Regards ghulam
     
    XXx_Death_xXX, Mar 1, 2014 IP
  17. skible

    skible Member

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    41
    #17
    $stadtQue = $customer->query( 'SELECT html FROM static WHERE type=\'main\' LIMIT 1' );
    That is probably the problem. Do you have a "static" table and a html column in there?
     
    skible, Mar 1, 2014 IP
  18. XXx_Death_xXX

    XXx_Death_xXX Member

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    33
    #18
    Yes i have table static and Column html

    but i dont undestand where should i use this line

    $stadtQue = $customer->query( 'SELECT html FROM static WHERE type=\'main\' LIMIT 1' );
    PHP:
     
    XXx_Death_xXX, Mar 1, 2014 IP
  19. skible

    skible Member

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    41
    #19
    Could you please try that query into your database. Post what it trows out. I do think that that is causing the problem.
     
    skible, Mar 2, 2014 IP