Page 1 of 1

query problem

Posted: Thu Sep 22, 2005 3:01 pm
by umbra
I have to find the records that starts with the chosen letter. I wrote a code like this:

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);
(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

Posted: Thu Sep 22, 2005 3:07 pm
by feyd
posting coding problems in the general discussion board doesn't help you any faster, but will make me mad a whole lot faster... :?



SUBSTRING(author,1,1)

Posted: Thu Sep 22, 2005 3:12 pm
by Charles256
are you confused about being mad? ;) just picking on ya....

Posted: Thu Sep 22, 2005 3:36 pm
by umbra
feyd wrote:posting coding problems in the general discussion board doesn't help you any faster, but will make me mad a whole lot faster... :?



SUBSTRING(author,1,1)
Ehmm sorry, I was just reading an entry when I decided to post a new topic but i didn't pay attention that it was in the general discussion board. Thanks for the help.