1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development More MySQL Problems!

Discussion in 'Software' started by Bogomip, 6 Mar 2003.

  1. Bogomip

    Bogomip ... Yo Momma

    Joined:
    15 Jun 2002
    Posts:
    5,164
    Likes Received:
    40
    right, my program is whining about this code...

    PHP:
            include 'db-info.php';
            
    $select=="1";
        
            
    $query "SELECT * from UKAB_Candidate WHERE no='$select'";

            while(
    $a_row mysql_fetch_object($query)) {
                
    $FORENAME == $a_row->forename;
                
    $SURNAME == $a_row->surname;
                
    $DOB == $a_row->dob;
                
    $CAND_NO == $a_row->cand_no;
                
    $CENT_NO == $a_row->cent_no;
            }
    the error reports this line...
    PHP:
    while($a_row mysql_fetch_object($query))
    to be causing the problems! but i cannot work out why! any help is appreciated, thnks!

    jafefr
     
  2. linear

    linear Minimodder

    Joined:
    5 Oct 2001
    Posts:
    4,393
    Likes Received:
    1
    Not to go after the obvious, but there's a mysql_connect() and a mysql_select_db() in there somewhere before you blast away with mysql_fetch_object(), right?

    What's the error message you get? It's usually kinda helpful.
     
  3. Bogomip

    Bogomip ... Yo Momma

    Joined:
    15 Jun 2002
    Posts:
    5,164
    Likes Received:
    40
    yes there is :)

    sorry, forgot to give you there error :) it is...

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/usr/abunting/public_html/CWK/candidate.php on line 27

    :)
     
  4. linear

    linear Minimodder

    Joined:
    5 Oct 2001
    Posts:
    4,393
    Likes Received:
    1
    that means mysql_connect() failed usually, try echoing mysql_error() right after you connect, and if you have one of those @ signs in front of mysql_connect() remove it, and more info should appear magically.

    This is an excellent example of a common mistake in PHP programming, assuming that a function call succeeded. In fact, it's number 12.
     
  5. sheepgoat

    sheepgoat What's a Dremel?

    Joined:
    8 Nov 2001
    Posts:
    48
    Likes Received:
    0
    PHP:
    include 'db-info.php';
            
    $select=="1";
        
            
    $query "SELECT * from UKAB_Candidate WHERE no='$select'";

            while(
    $a_row mysql_fetch_object($query)) {
    try

    PHP:
            $query "SELECT * from UKAB_Candidate WHERE no='$select'";
            
    $result mysql_query(mysql_query);
            while(
    $a_row mysql_fetch_object($result)) {
    1) you need to get the query before getting the objects with mysql_query($query).
    2) did you mean to have
    $DOB == $a_row->dob; instead of
    $DOB = $a_row->dob; single '=' insead of 2
     

Share This Page