query problem
Posted: Thu Sep 22, 2005 3:01 pm
I have to find the records that starts with the chosen letter. I wrote a code like this:
(article is a table in my database and author is a column in it)
but it didn't work. When I wrote mysql_error($query), it gave me this error: supplied argument is not a valid MySQL-Link resource
It seems that there is a mistake in the query but I can't find it. Thanks in advance if anyone can help
Code: Select all
$letter = @$_GET['letter'];
echo '<a href= \'browse_author.php?letter=A\'>' .chr(65).'</a>';
for ($i = 66; $i <91; $i++) {
echo '<a href=\'browse_author.php?letter=' . chr($i). '\'> | '.chr($i).'</a>';
}
$query = "SELECT * FROM article WHERE substr(author,0,1) = '$letter'";
echo $query;
$result = mysql_query ($query);
$whatever = mysql_fetch_assoc($result);but it didn't work. When I wrote mysql_error($query), it gave me this error: supplied argument is not a valid MySQL-Link resource
It seems that there is a mistake in the query but I can't find it. Thanks in advance if anyone can help