Results 1 to 26 of 26

Thread: mysql database problem

  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

    mysql database problem

    I recently changed servers, and now when I try to access my guestbook, I keep getting this error:


    Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/mendhak/public_html/guestbook/index.php on line 51


    For some reason, mysql_numrows, is not... valid/recognized???
    Here's the code:

    PHP Code:
    <?php
    global $offset// the string will be in the URL, say index.php?offset=9
    if($offset==OR $offset==""){
    $offset=0;
    }


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

    $displayperpage 5//set this variable to the number of records you want per page.

    $sqloffset=$offset*$displayperpage;




    $query="SELECT * FROM guestbook ORDER BY id DESC LIMIT $sqloffset,$displayperpage";
    $countquery="SELECT COUNT(*) FROM guestbook";

    $result=mysql_query($query);

    $pagecount=mysql_query($countquery);
    $rowsonthispage=mysql_numrows($result);
    //[b][color=black]THIS IS LINE 51[/color][/b]



    $tempcount mysql_fetch_row($pagecount);

    $num $tempcount[0];   //now we have total records
    Last edited by mendhak; Apr 14th, 2003 at 11:40 AM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    First thing I would do is findout what version of MySQL is running on the server, and then find out if the command in question is supported in that version.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Ok, it turned out to be a missing column in the table, which is why the argument being received was invalid.

    Thanks anyways.

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: mysql database problem

    Originally posted by mendhak

    For some reason, mysql_numrows, is not... valid/recognized???
    Here's the code:
    I know you fixed this already, but just a little FYI: that error is telling you that the supplied resource is not valid, not that the function itself is invalid.

    So when you were missing your column, your mysql_query() was not returning a valid result.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

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

    Re: Re: mysql database problem

    Originally posted by The Hobo
    I know you fixed this already, but just a little FYI: that error is telling you that the supplied resource is not valid, not that the function itself is invalid.

    So when you were missing your column, your mysql_query() was not returning a valid result.
    Thanks for the info.
    I had another question. On both servers, I had phpMyadmin (the web based mySQL admin thing).

    Now, I was wondering if it's possible for me to take a backup of the database, along with the tables and values stored in it? I know how to do this in SQL Server, which is what I used previously. But I don't know how to do this in mySQL.

    Any ideas?

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    first, mysql_numrows is deprecated and shouldn't be used.

    second, in phpmyadmin there is a export link. just select what you want "structure and data" and save it as a zip or sql file. either way will be sql file when done. then just upload the sql file in the new phpmyadmin adn it will install everything.

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by phpman
    second, in phpmyadmin there is a export link. just select what you want "structure and data" and save it as a zip or sql file. either way will be sql file when done. then just upload the sql file in the new phpmyadmin adn it will install everything.
    I've done that before.... it' pretty handy for creating "backups".... depending on the size if the DB, you may want to do it inbatch of a few tables at a time. I had a problem once, where the host had a veryshort timeout period, and so tables that took a while to script (because of the #of rows), I got TO errors when I scripted them w/ other tables.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    very true, if a very big database than you would want to do it one table at a time.

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    first, mysql_numrows is deprecated and shouldn't be used.
    I'm going to invent a language so I can randomly deprecate functions and create new ones with extra underscores in them.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    that's what is seems like huh? but in fact you can't even find it in the manual anymore so, deprecated, heck it is gone

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    that's what is seems like huh? but in fact you can't even find it in the manual anymore so, deprecated, heck it is gone
    Indeed, although there is a reference to it under mysql_num_rows(), but that just says that it's deprecated.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

  13. #13
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  14. #14

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Alright,
    if mysql_numrows() is depreciated, then what do I use instead?

    It's important that I get the number of rows, after all, it's for the guestbook, and I do ned the 'sorting' scheme I'm implementing.

    Second, I have winmysqladmin, which is a pain in the ass to say the least. Where can I get phpmyadmin from?

  15. #15
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    use mysql_num_rows()

    and

    www.phpmyadmin.net

  16. #16
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by CornedBee
    Here
    http://www.php.net/manual/en/functio...l-num-rows.php
    Also in the downloadable .chm documentation.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  17. #17
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    that is funny, because I ooked at mysql.com and you would think they would now what is in there program and what is not. they dont' even list it.

  18. #18

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Jeez, mysql_numrows() and mysql_num_rows() differ by one friggin' under_score. I really don't see what difference it makes, other than causing the inconvenience of having to change that single line in several pages of my site. (Thank you PHP.NET)


    Thanks guys, I'll try out phpmyadmin.

  19. #19
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    that is funny, because I ooked at mysql.com and you would think they would now what is in there program and what is not. they dont' even list it.
    phpman...mysql_num_rows() is a PHP function, not a native MySQL function.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  20. #20
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In the old PHP API for mysql it was mysql_numrows(). Then the name was changed to mysql_num_rows() so that it is the same as the native mysql function that phpman found.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  21. #21
    Member
    Join Date
    Nov 1999
    Posts
    61
    may be error at server, my script is ok on this server but error at
    other. report your problem to server admin

  22. #22
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by lejohn
    may be error at server, my script is ok on this server but error at
    other. report your problem to server admin
    He already fixed his problem. Read the third post.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  23. #23
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648

    Undefined function mysql_connect

    HI All

    Since this thread is over a year aol and you guys know more php than I do, I wish to ask you this:

    I have recently installed RH Linux 8 using the server installation option of the RH installer. PHP works fine and MySQL works fine. I have a problem when using MySQL connect in that an undefined function error is returned when i try to use:

    VB Code:
    1. $conn = mysql_connect("localhost");

    I am logged in as a root user and there are no database permissions present yet. I think apache is not finding a module of sorts. Any help here would be really appreciated.

    Thanks
    Mike

  24. #24
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    what version of php are you using? and you really should start another thread.

  25. #25
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    what version of php are you using? and you really should start another thread.

  26. #26
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648

    new thread

    Sorry about the posting , but you can find the new thread here

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