SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Member
    Join Date
    Sep 2003
    Location
    FL, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help with php error

    I need help as for some reason this code worked on old hosting account but on new hosting account I get the following errors for this code:

    value of sqlonl is: ( I put in to see value of sqloni )

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/cowpoke/a-dream-lover.com/members/inc_online.php on line 9

    5. $sqlonl = mysql_query("select * from online where MID = '{$_REQUEST['MID']}'", $conn);
    6. {
    7. echo("value of sqlonl is: $sqlonl"); (for testing purposes)
    8. }
    9. $numm = mysql_num_rows($sqlonl);


    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/cowpoke/a-dream-lover.com/members/inc_online.php on line 51

    50. $sqlallonl = mysql_query("select * from online", $conn);
    51. $num = mysql_num_rows($sqlallonl);

    If anyone can help me out and let me know what I did wrong I would be very grateful

    Hoot

  2. #2
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Melbourne
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.sitepoint.com/forums/showthread.php?t=196272

    From the looks of it your query is failing for some reason and not setting $sqlonl (most likely because when you changed to the new account the connection details have changed?).

  3. #3
    SitePoint Member
    Join Date
    Sep 2003
    Location
    FL, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    paths were changed

    details did change of course, but they are global and are contained in conn.php and were changed to the new hosting accounts paths, and names. The whole site was then checked to make sure no other instance of paths and server names were found and not changed. This is what has me stumped, as they worked in the old hosting account. I thought maybe it might be due to a version change of php or maybe php was installed with some switches different?

  4. #4
    SitePoint Enthusiast SlayMan's Avatar
    Join Date
    Oct 2004
    Location
    Germany/ Hamburg
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe try instead of:
    PHP Code:
    $sqlonl mysql_query("select * from online where MID = '{$_REQUEST['MID']}'"$conn); 
    this:
    PHP Code:
    $sqlonl mysql_query("select * from online where MID = '".$_REQUEST['MID']."'"$conn); 
    just a suggestion, it's not guaranteed to be working though.

    edit:
    I just saw it happens anywhere you try to SELECT something
    excuse me for not seeing this, then i really do not have a clue, but try:
    PHP Code:
    $sqlonl mysql_query("select * from online where MID = '".$_REQUEST['MID']."'"); 
    U recognize try a connect without your connection ID.
    SlayMan,
    Your friendly neighbourhood trainee and webmaster
    go, see for yourself @ http://www.alpupp.de

  5. #5
    SitePoint Member
    Join Date
    Sep 2003
    Location
    FL, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    no go

    thanks for the help, but it didn't work either, same error in the same place

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    try registering the $_REQUEST as a simple variable to see if it changes anything.
    ie:
    PHP Code:
    $mid $_REQUEST['mid'];
    $sqlonl mysql_query("select * from online where MID = '$mid'); 
    If that doesn't work, change from $_REQUEST to either $_GET or $_POST depending on which method you are using.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    SitePoint Member
    Join Date
    Sep 2003
    Location
    FL, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope didn't work either, get this error now:
    Parse error: parse error, unexpected T_STRING in /hsphere/local/home/cowpoke/a-dream-lover.com/members/inc_online.php on line 8

  8. #8
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    aahhh that will be because I missed the closing " of the query!!!!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  9. #9
    SitePoint Member
    Join Date
    Sep 2003
    Location
    FL, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nada tha didn't do it either

  10. #10
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Nevada
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know the php version of you old and new hosting company?

    To get a more specific mysql error message use code like this:
    PHP Code:
     $result mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query"); 
    Renaun
    PHP Reusable Web Framework - http://www.rwfphp.org

  11. #11
    SitePoint Member
    Join Date
    Sep 2003
    Location
    FL, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    old php3 new php4

  12. #12
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Nevada
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So php versions should not be an issue, might be the php_mysql configuration.

    But before looking into that did you try?
    PHP Code:
    // assummed that you did a mysql connect before this
     
    $result mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query"); 
    Renaun
    PHP Reusable Web Framework - http://www.rwfphp.org

  13. #13
    SitePoint Member
    Join Date
    Sep 2003
    Location
    FL, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe I'm missing something but somewhere along this thread something got lost
    sorry I am not sure how this :
    $result = mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query");

    relates to this:

    $sqlonl = mysql_query("select * from online where MID = '{$_REQUEST['MID']}'", $conn);

    maybe I'm missing something here as I'm lost now.

    here is the complete flow:
    starts in members/index.php

    <?
    session_start();
    if(session_is_registered('username')){

    include '../conn.php';
    $conn = my_conn(); *** JUST STANDARD MYSQL CONNECT
    VALUES WORKS FINE
    // username MID username
    $sqluserpass = mysql_query("select username, password, paid from members where MID = '{$_REQUEST['MID']}'", $conn) or die (mysql_error()); ;
    $userpass = mysql_fetch_array( $sqluserpass, MYSQL_ASSOC ) or die (mysql_error()); ;

    if ($userpass[username] != $username){
    header( "Location: loginf.php" );
    }

    ?>

    <html>
    <head>
    <title>A Dream Lover</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#CCCCCC">
    <?
    include 'menu.php'; ***GOES TO MEMBERS/MENU.PHP ***
    ?>

    Members/menu.php

    <?

    include 'inc_online.php'; ***GOES TO MEMBERS/INC_ONLINE.PHP IMMEDIATELY

    ?>

    MEMBERS/INC_ONLINE ***THIS IS WHERE THE PROBLEM IS ON LINE 9

    <?

    $sqldelmem = mysql_query("DELETE FROM online WHERE datetime < DATE_SUB(NOW(), INTERVAL 3 MINUTE)", $conn);

    $sqlonl = mysql_query("select * from online where MID = '{$_REQUEST['MID']}'", $conn);
    {
    echo("value of sqlonl is: $sqlonl"); (for testing purposes)
    }
    $numm = mysql_num_rows($sqlonl); ***THIS IS LINE 9

    $datetime = (date ("Y-m-d H:i:s"));


    if($numm > '0'){
    // update datetime

    and lines 50-51
    $sqlallonl = mysql_query("select * from online", $conn);
    $num = mysql_num_rows($sqlallonl); ***THIS IS LINE 51

    AGAIN THE WARNINGS ARE:

    value of sqlonl is:
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/cowpoke/a-dream-lover.com/members/inc_online.php on line 9

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/cowpoke/a-dream-lover.com/members/inc_online.php on line 51

    I also get the same warning one other place where I use mysql_num_rows():

    hope this full scene helps as this has me pulling my hair out, I cannot figure it out no matter what I do, and I'm about half bald as of now. All help has been and will be appreciated greatly.

    Hoot

  14. #14
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Nevada
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hsphere/local/home/cowpoke/a-dream-lover.com/members/inc_online.php on line 9
    Means that the parameter its is getting is not valid. Thats why i was suggesting putting the mysql_error() after it. So change line 5 to look like
    PHP Code:
    $sqlonl mysql_query("select * from online where MID = '{$_REQUEST['MID']}'"$conn) or die( mysql_error() ); 
    If there is a mysql error it will be shown, which is mostly likely the problem.

    If the code you posted is your exact code maybe change it to this and see what you get:
    PHP Code:
    <?php
    if($conn === null || $conn === false || !isset($conn))
        echo 
    "Connection has not been made!";
    $sqldelmem mysql_query("DELETE FROM online WHERE datetime < DATE_SUB(NOW(), INTERVAL 3 MINUTE)"$conn);

    $sqlonl mysql_query("select * from online where MID = '{$_REQUEST['MID']}'"$conn);
    if(
    $sqlonl === false) {
        echo(
    "value of sqlonl is: $sqlonl"); (for testing purposes)
    }
    $numm mysql_num_rows($sqlonl); ***THIS IS LINE 9

    $datetime 
    = (date ("Y-m-d H:i:s"));
    //.....
    The above code is just to double check all the basics nothing big but its always good to narrow down the problem.

    My Guess is that $conn is not valid?
    Renaun
    PHP Reusable Web Framework - http://www.rwfphp.org

  15. #15
    SitePoint Member
    Join Date
    Sep 2003
    Location
    FL, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all your help, I just found the problem. The table online in the database was somehow lost when transferring the site it works ok now that I created the table online
    One other question to you all before I post it as you may know the answer

    I want to read this table and then print out the member name contained in each row of the table.
    I want to format the results as otherwise it would be one long row of names so I would like to split it into three columns. If you have an answer then I will not start a new thread
    thanks again for all the great help!!

    Hoot


Bookmarks

Posting Permissions

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