Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    mysql_result error: invalid resource

    What am I doing wrong?

    PHP Code:
    <?php
    //header ("Context-Type: text/xml");
    $usr $_GET["usr"];


    $psw $_GET["psw"];

    echo 
    "Username is: $usr, and psw is: $psw";

    $conn mysql_connect ("localhost","jay","") or die ("No connection available");
    $db mysql_select_db ("rlaPool") or die ("Could not find database");

    $query "SELECT * FROM usrs WHERE usrs.usr=$usr";

    $result mysql_result ($result,$conn) or die ("<b>That didn't work!!!!</b>") ;

    ?>
    I get error
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/jail/labtec/login.php on line 14

    If I try
    Code:
    $result = mysql_result ($result) or die ("<b>That didn't work!!!!</b>") ;
    I get wrong param count


    Someone plz just quickly call me stupid and tell me what I did wrong... coz I can't belive I'm stuck at this point.
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #2
    New Coder
    Join Date
    Mar 2006
    Location
    London, UK
    Posts
    58
    Thanks
    3
    Thanked 0 Times in 0 Posts
    PHP Code:
    <?
    $conn 
    mysql_connect ("localhost","jay","") or die ("No connection available");/* remember that it will be for example if your hosting account name was domain the sql username would be domain_jay not just jay*/


    $db mysql_select_db ("rlaPool") or die ("Could not find database"); /* same goes here so it would be domain_rlaPool */
    ?>
    Last edited by bhav; 12-24-2006 at 08:55 PM.

  • #3
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    But I have die statements for all of them, if I comment out the mysql_query line then it gives NO error. And I don't recall ever using the doman_ thing
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #4
    New Coder
    Join Date
    Dec 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am not sure I agree with bhav either. I have used hosting where it did not force me to use domain_username.

    jaywhy13, i think the solution to your problem is:
    PHP Code:
    $query "SELECT * FROM usrs WHERE usrs.usr=$usr"// not sending a query

    $result mysql_query($query); // now my query is sent 
    edit:
    Also, why are you sticking $conn in the mysql_result function?

    See this: http://us2.php.net/mysql_result
    Last edited by Crimsonjade; 12-24-2006 at 09:17 PM. Reason: Another question

  • #5
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Crimsonjade View Post
    I am not sure I agree with bhav either. I have used hosting where it did not force me to use domain_username.

    jaywhy13, i think the solution to your problem is:
    PHP Code:
    $query "SELECT * FROM usrs WHERE usrs.usr=$usr"// not sending a query

    $result mysql_query($query); // now my query is sent 
    edit:
    Also, why are you sticking $conn in the mysql_result function?

    See this: http://us2.php.net/mysql_result

    $result = mysql_result ($result,$conn) or die ("<b>That didn't work!!!!</b>") ;

    I'm using php 5 and when I try just using result alone if gives me a wrong param count error....


    Edit:
    I just finished exams @ school, I can tell I am stressed. I really should have been using mysql_query instead of result... That fixed it.

    Thanks man... it's working now
    Last edited by jaywhy13; 12-24-2006 at 09:42 PM. Reason: A moment of stupidity finally ended
    I'm gonna find a way to download the internet if its the last thing I do...
    Prepare to bow down to me (or my grave) and call me almighty when the algorithm is finished

  • #6
    New Coder
    Join Date
    Dec 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $result = mysql_result ($result,$conn) or die ("<b>That didn't work!!!!</b>") ;

    I'm using php 5 and when I try just using result alone if gives me a wrong param count error....
    I think the second parameter is
    The row number from the result that's being retrieved. Row numbers start at 0.
    Glad it worked.


  •  

    Posting Permissions

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