[Phplib-users] HELP! php-mysql weirdness
Brought to you by:
nhruby,
richardarcher
|
From: Stephen W. <wo...@me...> - 2001-09-20 14:12:05
|
Hi all,
Sorry this is a little off topic, but I'm can't figure this one out and
someone here might have run into this problem.
I have a SQL query to mysql from php3, the query has an optional WHERE
clause. I get results back if the where clause is included but none if
it is left out.
select distinct BIRT_PLAC as PLACE from INDI where BIRT_PLAC like "%%"
order by PLACE
num=719
select distinct BIRT_PLAC as PLACE from INDI order by PLACE
num=0
BOTH queries work FINE if I cut and paste them into mysql directly.
Anyone have any ideas?
-Steve
function Places($str) {
global $conn;
$aPlaces = array();
$sql = "select distinct BIRT_PLAC as PLACE from INDI ";
if ($str != "")
$sql .= "where BIRT_PLAC like \"%$str%\" ";
$sql .= "order by PLACE ";
print "<br>$sql<br>\n";
$result = @mysql_query($sql, $conn)
or die("Can't execute query: $sql ! $php_errormsg");
$num = 0;
while ($row = mysql_fetch_array($result)) {
$aPlaces[] = $row["PLACE"];
$num++;
}
print "num=$num<br>\n";
}
|