Result Set Problem - Really Weird.....

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • coder

    Result Set Problem - Really Weird.....

    I am new to programming in PHP however, this should be a pretty
    straight forward answer. I have three queries that I am pulling for a
    content form page.

    1) The Author List
    2) The Content Page (pulls the PK, Title and the Description of the
    content.
    3) The Category List

    When I attempt to pull the data the only result set I get back is from
    the Item #1 query above. Now, I made sure that there is data in the
    tables, but I still get no data back for the other two queries(????)

    Is there something that I missing when connecting to PHP/MYSQL? Do I
    need to take some additional steps??

    Any help would be greatly appreciated. I've been struggling with this
    problem for several hours now scratching my head why this is.

    :-)

    // here is the PHP Code I am using

    <?php
    $db = mysql_connect(" $DB_SERVER", "$DB_SERVER_USE RNAME",
    "$DB_SERVER_PAS SWORD");
    mysql_select_db ("$DB_DATABASE" ,$db);
    //result set 1 - get members
    $result_M=mysql _query("SELECT * FROM tblMembers",$db );
    $myrow_M=mysql_ fetch_assoc($re sult_M);
    //result set 2 - get content ID
    $result_C=mysql _query("SELECT * FROM tblContent WHERE
    contentID=1",$d b);
    $myrow_C=mysql_ query($result_C );
    //result set 3 - get categories
    $result_Cat=mys ql_query("SELEC T * FROM tblCat",$db);
    $myrow_Cat=mysq l_query($result _Cat);


    //result set 1 - output
    $memID =$myrow_M['memberID'];
    $fname =$myrow_M['fname'];
    $lname =$myrow_M['lname'];
    //result set 2 - output
    $contentID =$myrow_C['contentID'];
    $Title =$myrow_C['Title'];
    $e1m1 =$myrow_C['Descr'];
    //result set 3 - output
    $CatID = $myrow_Cat['CatID'];
    $CatName = $myrow_Cat['CatName'];


    echo ($memID);
    echo ($fname);
    echo ($lname);
    echo ($contentID);
    echo ($Title);
    echo ($e1m1);
    echo ($CatID);
    echo ($CatName);

    return false;

    ?>

  • Dikkie Dik

    #2
    Re: Result Set Problem - Really Weird.....

    > When I attempt to pull the data the only result set I get back is from[color=blue]
    > the Item #1 query above. Now, I made sure that there is data in the
    > tables, but I still get no data back for the other two queries(????)
    >[/color]
    <snip>[color=blue]
    > // here is the PHP Code I am using
    >[/color]
    <snip: lots of PHP code without error checking>

    I suggest you ask the mysql_errno() mysql_error() functions first.

    Best regards

    Comment

    • Jerry Stuckle

      #3
      Re: Result Set Problem - Really Weird.....

      coder wrote:[color=blue]
      > I am new to programming in PHP however, this should be a pretty
      > straight forward answer. I have three queries that I am pulling for a
      > content form page.
      >
      > 1) The Author List
      > 2) The Content Page (pulls the PK, Title and the Description of the
      > content.
      > 3) The Category List
      >
      > When I attempt to pull the data the only result set I get back is from
      > the Item #1 query above. Now, I made sure that there is data in the
      > tables, but I still get no data back for the other two queries(????)
      >
      > Is there something that I missing when connecting to PHP/MYSQL? Do I
      > need to take some additional steps??
      >
      > Any help would be greatly appreciated. I've been struggling with this
      > problem for several hours now scratching my head why this is.
      >
      > :-)
      >
      > // here is the PHP Code I am using
      >
      > <?php
      > $db = mysql_connect(" $DB_SERVER", "$DB_SERVER_USE RNAME",
      > "$DB_SERVER_PAS SWORD");
      > mysql_select_db ("$DB_DATABASE" ,$db);
      > //result set 1 - get members
      > $result_M=mysql _query("SELECT * FROM tblMembers",$db );
      > $myrow_M=mysql_ fetch_assoc($re sult_M);
      > //result set 2 - get content ID
      > $result_C=mysql _query("SELECT * FROM tblContent WHERE
      > contentID=1",$d b);
      > $myrow_C=mysql_ query($result_C );
      > //result set 3 - get categories
      > $result_Cat=mys ql_query("SELEC T * FROM tblCat",$db);
      > $myrow_Cat=mysq l_query($result _Cat);
      >
      >
      > //result set 1 - output
      > $memID =$myrow_M['memberID'];
      > $fname =$myrow_M['fname'];
      > $lname =$myrow_M['lname'];
      > //result set 2 - output
      > $contentID =$myrow_C['contentID'];
      > $Title =$myrow_C['Title'];
      > $e1m1 =$myrow_C['Descr'];
      > //result set 3 - output
      > $CatID = $myrow_Cat['CatID'];
      > $CatName = $myrow_Cat['CatName'];
      >
      >
      > echo ($memID);
      > echo ($fname);
      > echo ($lname);
      > echo ($contentID);
      > echo ($Title);
      > echo ($e1m1);
      > echo ($CatID);
      > echo ($CatName);
      >
      > return false;
      >
      > ?>
      >[/color]

      Check the results from your queries. If FALSE is returned, you have an
      error. Call mysql_errno() and mysql_error() to find out what it is, i.e.

      $result_C=mysql _query("SELECT * FROM tblContent WHERE contentID=1",$d b);
      if ($result_C) (
      $myrow_C=mysql_ query($result_C );
      }
      else {
      echo {"MySQL Error detected: " . mysql_error() . "<br>\n");
      }

      ALWAYS check the results of ANY call to MySQL!


      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • coder

        #4
        Re: Result Set Problem - Really Weird.....

        Thanks you both for your reply and assistance - this is exactly what I
        was missing. :-)

        Comment

        Working...