query problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
umbra
Forum Newbie
Posts: 21
Joined: Tue Sep 13, 2005 4:20 am

query problem

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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)
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

are you confused about being mad? ;) just picking on ya....
umbra
Forum Newbie
Posts: 21
Joined: Tue Sep 13, 2005 4:20 am

Post 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.
Post Reply