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 3 of 3

Thread: weird php/mysql

  1. #1
    New Coder
    Join Date
    Jun 2006
    Location
    Birmingham, UK
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question weird php/mysql

    PHP Code:
    <?
    $mysqluser 
    "root";
    $mysqlpass "pass";
    $mysqlhost "localhost";
    $mysqldb "db";
    $rootpath "/somewhere/";



    mysql_connect($mysqlhost,$mysqluser,$mysqlpass);
    mysql_select_db($mysqlpass);

    $ip $_SERVER['REMOTE_ADDR'];
    $sql "SELECT * FROM portal_logintrys WHERE ip='$ip'";
    $query mysql_query($sql);
    $numrows mysql_num_rows($query);
    echo 
    $numrows;
    ?>

    the error is..
    PHP Code:
    Warningmysql_num_rows(): supplied argument is not a valid MySQL result resource in
    Warning
    mysql_fetch_object(): supplied argument is not a valid MySQL result resource in 
    For some reason this wont work, neither would it work for mysql_fetch_array();

    Any thoughts on why it doesnt work?

    any ideas will be greatly appreciated. thanks
    Last edited by Birdie312; 06-11-2006 at 10:27 PM.

  • #2
    New Coder
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    49
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Take a close look in this line mysql_select_db($mysqlpass);
    maybe you´d want to connect to $mysqldb instead

  • #3
    New Coder
    Join Date
    Jun 2006
    Location
    Birmingham, UK
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wow never noticed that!! thanks, i'll have to change it.


  •  

    Posting Permissions

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