Re: double check query statement??
| From: | Hugh Bothwell | Date: | Tue, 28 Aug 2001 22:54:13 +0000 |
| Subject: | Re: double check query statement?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64909@lists.php.net to get a copy of this message | ||
"Gerard Samuel" <trini0@optonline.net> wrote in message
news:3B8C1CA2.6050205@optonline.net...
> $query = "SELECT mpn_job.ID, job, assigned_to, status_date, category";
> $query .= "FROM mpn_job, mpn_job_category WHERE CID =
> mpn_job_category.ID";
> $query .= "AND category = '$category'";
> $result = mysql_query($query);
> $row = mysql_fetch_row($result);
> foreach ($row as $data) {
> echo "$data[0]";
> }
>
> I tried the SELECT statement from mysql command line (less $category, I
> used an actual category name) and it works there. I try it out in php,
> and I get nothing. (I echoed $category before this and it works
> correctly) Do you guys see anything in there that may need correcting?
Sure - you need to have an extra space at the
end of each line... right now, it comes out like
... status_date, categoryFROM mpn_job ...
... mpn_job_category.IDAND category ...
I often find it useful to echo the query statement
just before using it... it makes mistakes like this
kind of obvious.
Also, if you used
$result = @mysql_query($query)
or die("Error querying: ".mysql_error());
you should get more-useful error messages.