A Fight to Fetch!

Discussion in 'PHP' started by prabha_friend, Jun 30, 2009.

  1. #1
    mysql:
    showall() = select * from sometable;
    class.php:
    class EMP_LOGIN
    {
    function EMP_LOGIN()
    {
    }
    function showall()
    {
    $myrset = mysql_query("call showall()");
    return $myrset;
    }
    function getemp($somevar)
    {
    somecommands;
    }
    }
    page1.php:
    $myobj = new EMP_LOGIN();
    $myrset = $myobj->showall();
    $myrow = mysql_fetch_array($myrset);
    echo($myrow['EMP_ID']);
    page2.php:
    //First procedure to get details for a single employee
    $myobj = new EMP_LOGIN();
    $myrset = $myobj->getemp($_SESSION['EMP_ID']);
    $myrow = mysql_fetch_array($myrset);
    echo "Welcome! ".$myrow['FIRSTNAME'];
    echo " ".$myrow['LASTNAME'];
    //This procedure is to get dashboard with all employee details
    $myrset = $myobj->showall();
    $myrow = mysql_fetch_array($myrset);
    echo($myrow['EMP_ID']);

    Page1.php works well but page2.php returns Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
    What went wrong. Is it wrong to access two objects in a single page. Help needed.
     
    prabha_friend, Jun 30, 2009 IP
  2. nirajkum

    nirajkum Active Member

    Messages:
    815
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #2
    please print the sql statement before firing the sql query .. it will help to find the root cause
     
    nirajkum, Jun 30, 2009 IP