Announcement

Collapse
No announcement yet.

Mysql Query returning Resource id #6

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mysql Query returning Resource id #6

    I'm trying to get a single record to show based on a know customer id number stored in a mysql table, but I keep getting an output of "Resource id #6"

    Code is as follows:

    PHP Code:
    <?php

    $id 
    ifset($_GET['id']);


    if (
    $id == $default){
    echo 
    "No Customer Selected";
    }
    else {
      
         
    $idforquery intval($_GET['id']);

         
    $query "SELECT * FROM customers WHERE customerID = $idforquery";
         
    $result mysql_query($query$connection);


         echo 
    "Customer ID Selected is $result<p>";
         echo 
    $query;
             }
    ?>

    Would appreciate any help.
    Tom

    My questions might not make any sense but at least they are interesting.

  • #2
    Because you are returning the query Id not the result of the query. You need the red lines

    $query = "SELECT * FROM customers WHERE customerID = $idforquery";
    $qry = mysql_query($query, $connection);
    $result = mysql_fetch_arrary($qry);
    echo "Customer ID Selected is {$result['customerID ']}<p>";
    Have a Script or Snippet you want to share?

    WWW Standards: HTML 4.01,
    HTML 5, CSS2.1, CSS3, XHTML 1.0
    PHP Standards: PHP Standards

    Comment


    • #3
      Just wanted to say thanks so much for this, everything that I had done with Mysql queries etc had been through the process of returning values to use in a For loop so I was basically stripping it back and seeing what worked.
      Tom

      My questions might not make any sense but at least they are interesting.

      Comment

      Working...
      X