Results 1 to 4 of 4

Thread: More mySQL Problems [Resolved]

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Angry More mySQL Problems [Resolved]

    I have mySQL running on my computer here, and all works fine: using PHP I can enter data, and view it.

    However, on the server, it just won't work.

    I keep getting this error:


    Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/mendhak/public_html/slambook/view.php on line 23
    The code I'm using is

    PHP Code:

    $dbh
    =mysql_connect("localhost""mendhak_hello""zzz") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db("slambook");  




    $abcquery "SELECT * FROM slambook;";

    $result mysql_query($abcquery);

    echo 
    $result;






    $rowsonthispage mysql_numrows($result); //this is line 23, where the error is occuring



    echo "There are $rowsonthispage rows in total";
    mysql_close(); 
    I've also tried using mysql_num_rows, and I still get the same error. Now, it's obvious there's a problem with what $result is retrieving, but why is that? The query is perfectly fine. The database name is slambook, and the table name is also slambook... is that causing problems?

    What can I do to resolve this problem?
    Last edited by mendhak; May 17th, 2003 at 05:43 AM.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Code:
    '...
    
    mysql_select_db("slambook") or die(mysql_error());  
    
    $abcquery = "SELECT * FROM slambook;";
    
    $result = mysql_query($abcquery) or die(mysql_error());
    
    echo $result;
    
    '...
    Do that and see if it produces a different error.

    Also, a few things:

    [list=1][*]You don't need to put a ; at the end of your MySQL queries.[*]You don't need to use mysql_close(), as this is done automatically when the script finishes executing.[/list=1]
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    yes, that semi-colon is the problem

    $abcquery = "SELECT * FROM slambook;";

    also it is good practice to make your names different than you db name.

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Resolved! The die(mysql_error()) thing really helped: I saw that I had to select the db "mendhak_slambook" instead of just "slambook"


    Thanks a lot.

Posting Permissions

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



Click Here to Expand Forum to Full Width