473,320 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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_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
changed.

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

mysql_free_result($result);
?>

Jul 17 '05 #1
2 1780
wrw[three] (wi***@avantd.biz) decided we needed to hear...
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_array(): supplied argument is not a valid MySQL
result resource in
/home/content/s/i/t/siteadmin/html/clientmanager/searchClients.php on
line 61 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

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 Same reason as above.

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

<?php
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 ");

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 <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #2
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):

http://php.net/mysql-fetch-assoc

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: redneck_kiwi | last post by:
All: I have an application that has been working well for 3-4 months now without any issues (that I am aware of). A day or two ago, one of our employees that use this application called to say...
3
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed...
2
by: Dave Moore | last post by:
Hi All, I've got a simple query hopefully somebody can clear up for me. I need to make a query on a database to select a set of table rows, using something like: $result = mysql_query($query);...
4
by: Marcel Brekelmans | last post by:
Hello, I seem to get an extra empty field in every 'mysql_fetch_array' command I issue. For example: I have a simple table 'tblName': ID Name 1 Jane 2 Joe 2 Doe
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
10
by: isynclere | last post by:
Hi all, I am stuck with a very strange session prob. Developing on locahost. Have just gone back to a project I was working on to check all is ok and the login function is no longer working...
10
by: paul814 | last post by:
I am having a bit of a problem with some code....can someone give me some suggestions? Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\production \date2.php on line 28 line 28 is...
2
by: William Gill | last post by:
given the query: SELECT * FROM customers left join addresses on customer.cusid=addresses.cusid The mysql monitor returns all fields from both tables, including repeating the field matching...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.