SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Please Help Me

  1. #1
    SitePoint Member moneybyus's Avatar
    Join Date
    Mar 2001
    Location
    MN
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please Help Me

    Can someone please tell me why i get this error when I run this script?

    Warning: Supplied argument is not a valid MySQL result resource in /home/smh_2/moneybyus-www/chkrefer.php on line 6

    Warning: Supplied argument is not a valid MySQL result resource in /home/smh_2/moneybyus-www/chkrefer.php on line 9

    The code still records the referrer even with the errors, but always makes a new entry instead of just adding another count to the one that already exists.

    Here is the code I am using...

    <?
    if(!eregi("moneybyus\.com", $HTTP_REFERER)) {
    dbconnect('moneybyus_com');
    $sql = "Select * from referrer where url = '$HTTP_REFERER'";
    $result = mysql_query($sql);
    if(mysql_result($result,0,0)>0) {
    mysql_query("UPDATE referrer SET num=num+1 where site = '$HTTP_REFERER'");
    }
    if(mysql_result($result,0,0)<1) {
    $add = "INSERT INTO referrer SET
    site = '$HTTP_REFERER'";
    if (!mysql_query($add))
    error("A database error occurred in processing your ".
    "submission.\\nIf this error persists, please ".
    "contact support@moneybyus.com.");
    }
    }
    ?>

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Those two errors are saying that the value of $result (which is the arguement in your call to mysql_result() in line 6 and 9) is not a valid mysql result resource. In other words, the query you executed in line 5 failed.

    Line 5 is:
    $result = mysql_query($sql);

    This could be because the sql statement in $sql is baddly formed - but it looks ok to me.

    Also, have you made a successfull connection to the mysql server daemon using mysql_connect() and then selected a database to use using mysql_select_db()? I am assuming that that is what you have going on inside the function dbconnect. But if either of these are not in place (a connection to the mysql server and selection of a database) then your queries will fail.

    If you could show us what code is inside function dbconnect woud be good to.

  3. #3
    SitePoint Enthusiast kcabobert's Avatar
    Join Date
    Aug 2001
    Location
    Topeka, KS
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure but try replacing the:
    mysql_result($result,0,0)>0
    with:
    mysql_num_rows($result)>=1
    and the other with:
    mysql_num_rows($result)<=0

    That may help. Good luck on finding the problem. Oh the other thing is if you want to find out if the queries are working right try adding an "or die("Sorry I died doing query X");" bfore the ;. like:

    $result = mysql_query($sql) or die("Sorry I died doing query X");

    Hope that will be of some help to you.
    Microsoft's Motto: Resistance is futile, you will be assimilated.

    My dog's name is Jade; she is a Miniature pinscher.
    Click here to see some of her pictures

  4. #4
    SitePoint Member moneybyus's Avatar
    Join Date
    Mar 2001
    Location
    MN
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The dbconnect function is the same as db.php at http://www.webmasterbase.com/article/319/20 with my login details added. I use this script many other times throughout my site and it works fine.

  5. #5
    SitePoint Member moneybyus's Avatar
    Join Date
    Mar 2001
    Location
    MN
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out, I was telling it to Select * from referrer where url = '$HTTP_REFERER' but there is no field url so I changed it to site like it should have been. Thanks for the help.


Bookmarks

Posting Permissions

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