weird problem with mysql_fetch_array

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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

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

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

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

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

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

        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
                <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='viewClientMain.php'
method='post'><input type='hidden' name='client_id' value='%s'><input
type='image' border='0' name='submitgif' src='images/view_client.gif'
            </tr>", $row["last_name"], $row["first_name"], $row["email"],
$row["email"], $row["client_id"]);

Re: weird problem with mysql_fetch_array

wrw[three] ( decided we needed to hear...
Quoted text here. Click to load it
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

Quoted text here. Click to load it
Same reason as above.

Quoted text here. Click to load it
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

(Remove REMOVE for email address)

Re: weird problem with mysql_fetch_array

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

Site Timeline