Results 1 to 2 of 2

Thread: [resolved] What is wrong with this syntax?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Resolved [resolved] What is wrong with this syntax?

    PHP Code:
    $sql mysql_query('SELECT golf_course_code FROM availability WHERE golf_course_code='.$_POST['txtGolfCourse'].' AND t_date="'.$temp_date.'"');
        while (
    $row mysql_fetch_object($sql)) {\
            echo 
    $row->golf_course_code.'<br>';
        } 
    I'm getting this rather unhelpful error message:
    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\golf_engine_php\xt_index.php on line 33
    Any help is appreciated.
    Many thanks.
    Last edited by solitario; May 27th, 2005 at 02:54 PM.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: What is wrong with this syntax?

    You have to execute your query before you can get the rows it returns. The mysql_query() function does this and returns a result point which can then be supplied as an argument to functions like mysql_fetch_object().
    PHP Code:
    $sql mysql_query('SELECT golf_course_code FROM availability WHERE
                golf_course_code='
    .$_POST['txtGolfCourse'].' AND t_date="'.$temp_date.'"');

    if (! 
    $result mysql_query($sql)) {
        die(
    mysql_error());
    }

    while (
    $row mysql_fetch_object($result)) {
        echo 
    $row->golf_course_code.'<br>';

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width