Results 1 to 9 of 9
  1. #1
    Join Date
    May 2004
    Location
    Colorado
    Posts
    948

    Question mysql_result error, help plz :)

    hi everyone..
    lately i have been working on a site for my school, really more of a fun learning porject.. as such i have taken the chance to mess around with some things.. ie. i have kinda created my own authentification system and so on..

    however i am having a small problem (big one really, cuz the login doesnt work if i cant figure out why this is happening) but i keep getting:
    "Warning: mysql_result(): supplied argument is not a valid MySQL result resource in C:\Web\root\CM\restricted\authen.php on line 15"

    here is the code that i am using for it
    PHP Code:

    $ip 
    $_SERVER["REMOTE_ADDR"];

        
    //Database query
        
    $query mysql_query("SELECT a_authenticate FROM authen WHERE a_ip = $ip"$connect);
        
    $return_auth mysql_result($query0'a_authenticate'); 
    that file is included with another file:

    PHP Code:
    <?php
    session_start
    ();
    require(
    'restricted/connect.php');
    include(
    'restricted/authen.php');
    thats pretty much the only php there is in that file except where i check the hash against one in the database, but that doesnt have anything to do with my error because i dont even get sofar as checking for anything

    THanks again, if you need any more info about it just ask me
    currently i am using PHP5 and apache 2.05something and mySQL ~2

    thx


    Absolute Power, its the only way to roll!

  2. #2
    Join Date
    Dec 2002
    Location
    United Kingdom
    Posts
    635
    PHP5 does not have MYSQL support enabled by default you must edit your PHP.ini and uncomment the mysql line relevant to you Opertaing system of your sever

    .dll for windows
    .so for linux

    I'm dling php5 now and will post back with the exact lines to edit
    Saiweb ~ Ramblings of a sysadmin

    My Current Recomended WebHost: Nativespace



    "Acies Latin: a sharp edge or point; mental acuity, sharpness of vision"

    NOTE: Acies is currently beta, the "down" page will be displayed untill I have finished a release candidate

    3DBuzz has a reputation system please rate posts using the icon

  3. #3
    Join Date
    Dec 2002
    Location
    United Kingdom
    Posts
    635
    ;extension=php_mysql.dll
    chage to

    extension=php_mysql.dll
    Saiweb ~ Ramblings of a sysadmin

    My Current Recomended WebHost: Nativespace



    "Acies Latin: a sharp edge or point; mental acuity, sharpness of vision"

    NOTE: Acies is currently beta, the "down" page will be displayed untill I have finished a release candidate

    3DBuzz has a reputation system please rate posts using the icon

  4. #4
    Join Date
    May 2003
    Location
    Germany
    Posts
    845
    Can you interact between PHP and MySQL succesfully???
    If you can't work with MySQL then do what Sion said.
    I had the same problem before....

  5. #5
    Join Date
    May 2004
    Location
    Colorado
    Posts
    948
    that is not the problem...
    yes i can interact with php
    my php file has already been edited.. i fixed it when i installed it and i have several test scripts that prove that it will work with mySQL.. not to mention the rest of my site relies on mySQL...

    i will have o look over my code again later and check everything but im certain that it is not a problem with the way mySQL apache or PHP are set up


    Absolute Power, its the only way to roll!

  6. #6
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    455
    PHP Code:
    $ip $_SERVER["REMOTE_ADDR"];    
     
    //Database query
    $query mysql_query("SELECT a_authenticate FROM authen WHERE a_ip = $ip"$connect);
    $return_auth mysql_result($query0'a_authenticate'); 
    try taking your sql statement and execute it using a query window.

    Because it looks like you are missing quotes around your $ip variable.

    So you sql should look like something like this:

    SELECT a_authenticate FROM authen WHERE a_ip = \"$ip\"

    Hope that helps.
    Jazzgame

  7. #7
    Join Date
    Sep 2004
    Posts
    5
    Don’t know if this matters but I always use “” around my data fields in a mysql_result query.

    PHP Code:
    $return_auth mysql_result($query0"a_authenticate"); 
    If not tell the mysql_query to return an error.

    PHP Code:
    $query mysql_query("SELECT a_authenticate FROM authen WHERE a_ip = $ip"$connect) or die("ERROR in SQL: " mysql_error()); 

  8. #8
    Join Date
    Jul 2004
    Location
    N29° 22.725' X W95° 6.452'
    Posts
    343
    Jazzgame is correct, you should have quotes around $ip. I would change your sql to "SELECT a_authenticate FROM authen WHERE a_ip =' $ip' ". This should correct the problem.

  9. #9
    Join Date
    May 2004
    Location
    Colorado
    Posts
    948
    alright thanks alot guys, i will try to fix it up when i have a spare moment, thats probably what the problem is though

    thx


    Absolute Power, its the only way to roll!

Posting Permissions

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