Results 1 to 4 of 4
  1. #1
    pph Expert! Gordon's Avatar
    Join Date
    January 18th, 2005
    Edmonton Canada
    I'm trying to get a php script to work and I keep getting the error message can anybody help me out with it please?
    BTW This is the line in question $n = mysql_num_rows($q);

    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mysite/public_html/ulinks2/linkcode.php on line 25 <HR></BLOCKQUOTE>
    One day parasites and their ilk will be made illegal, I bet a few Lawyers will be pissed off when the day comes.
    Mr. Spitzer is fetching it nearer


  2. #2
    ABW Ambassador
    Join Date
    January 17th, 2005
    The problem is not that line.

    The problem is $q.
    somewhere above will be a $q=mysql_query("blah blah");

    The error will be in your query.

  3. #3
    Full Member jollygoodpirate's Avatar
    Join Date
    January 17th, 2005
    I'll assume...

    $q = your query
    you are trying to run mysql_num_rows against your query string this probably beign "select ...."

    Which will never work, for you must run your query string against a mysql_query like
    $result = mysql_query($q)

    and then run your $result against your mysql_num_rows like
    $numrows = mysql_num_rows($result)

    I am assuming all this because of the $q which looks more like a name for query string than a result....

    I could be 100% wrong here!

  4. #4
    Join Date
    January 17th, 2005
    Basically what you want to do is go back and look to see if you have more than one connection on your script. If you do then you need to pass the connection variable to the mysql_query function. If you do not, then you are not getting a result from $q.

    <pre class="ip-ubbcode-code-pre">
    $dbh = mysql_connect(SERVER,USER,PASS);
    $q = mysql_query("SELECT 1 FROM some_table",$dbh) or die(mysql_error($dbh));</pre>

    Then you have your mysql_num_rows function. In that function you would pass $q. If the query has an error, it will tell you. If the query does not have an error, $n will have the amount of rows returned whether it be 0 or 500.

  5. Newsletter Signup

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts