weird problem with mysql_fetch_array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wrw[three]

    weird problem with mysql_fetch_array

    Hey Okay so i have a page that lists a bunch of clients... then another
    page that would limit it to a specific chosen client.... the one that
    lists all the clients is working just fine, however when i limit the
    mysql query with "WHERE 1 AND last_name LIKE Harder" it gives me these
    errors

    Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL
    result resource in
    /home/content/s/i/t/siteadmin/html/clientmanager/searchClients.p hp on
    line 61

    Warning: mysql_free_resu lt(): supplied argument is not a valid MySQL
    result resource in
    /home/content/s/i/t/siteadmin/html/clientmanager/searchClients.p hp on
    line 70

    Here is the code in case you see anything you see that neeeds to be
    changed.

    <?php
    require_once ('############# .php');

    $result = mysql_query("SE LECT last_name, first_name, email, client_id,
    company FROM client_info WHERE 1 AND last_name LIKE Harder ");

    while ($row = mysql_fetch_arr ay($result, MYSQL_ASSOC)) {
    printf("
    <tr>
    <td class='cd_data' >%s, %s</td>
    <td class='cd_data' ><a href='mailto:%s ' class='cd_link' >%s</a></td>
    <td class='cd_data' ><form action='viewCli entMain.php'
    method='post'>< input type='hidden' name='client_id ' value='%s'><inp ut
    type='image' border='0' name='submitgif ' src='images/view_client.gif '
    onclick='submit form()'></form></td>
    </tr>", $row["last_name"], $row["first_name "], $row["email"],
    $row["email"], $row["client_id"]);
    }

    mysql_free_resu lt($result);
    ?>

  • Dave

    #2
    Re: weird problem with mysql_fetch_arr ay

    wrw[three] (willy@avantd.b iz) decided we needed to hear...[color=blue]
    > Hey Okay so i have a page that lists a bunch of clients... then another
    > page that would limit it to a specific chosen client.... the one that
    > lists all the clients is working just fine, however when i limit the
    > mysql query with "WHERE 1 AND last_name LIKE Harder" it gives me these
    > errors
    >
    > Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL
    > result resource in
    > /home/content/s/i/t/siteadmin/html/clientmanager/searchClients.p hp on
    > line 61[/color]
    Above error is because your SQL statement has an error in it and you
    don't check if it worked or not before your script continues
    [color=blue]
    >
    > Warning: mysql_free_resu lt(): supplied argument is not a valid MySQL
    > result resource in
    > /home/content/s/i/t/siteadmin/html/clientmanager/searchClients.p hp on
    > line 70[/color]
    Same reason as above.
    [color=blue]
    >
    > Here is the code in case you see anything you see that neeeds to be
    > changed.
    >
    > <?php
    > require_once ('############# .php');
    >
    > $result = mysql_query("SE LECT last_name, first_name, email, client_id,
    > company FROM client_info WHERE 1 AND last_name LIKE Harder ");[/color]
    You need to check if the above statement worked or not by testing
    $result. The statement didn't work in your case which is why you get
    the two error's above. If $result is false, you should check the error
    message returned from mysql_error.
    Best guess - your main problem is you should have single quotes around
    the word 'Harder' - I'm assuming its a literal and not a column name.
    As an aside, the '1 AND' part can be removed - it doesn't serve any
    purpose.

    --
    Dave <dave@REMOVEbun dook.com>
    (Remove REMOVE for email address)

    Comment

    • Philip  Olson

      #3
      Re: weird problem with mysql_fetch_arr ay

      And see the manual for an example on how to do some simple error
      checking (making sure $result is a valid resource, and that rows
      exist):



      Comment

      Working...