• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

systax error: mysql_fetch_array( )

Hello,

I'm using these php statments:
$letter='t';
$sql ="SELECT * FROM users WHERE firstLetter=$letter";  //line 8
$res = mysql_query( $sql);

while($row = mysql_fetch_array($res))   // line 10
  {
  echo $row['firstName'] . " " . $row['lastName'];
  echo "<br />";
  }

------------------------------------------------------
I got a systax in line 10. If  I change line 8 to $sql ="SELECT * FROM users WHERE firstLetter= 't' ";
then the erro is gone. I'm wondering why I can't use $letter variable in line 8.

Thanks so much for your reply!
lilyyan


0
lilyyan
Asked:
lilyyan
  • 2
1 Solution
 
hongjunCommented:
try this

$sql ="SELECT * FROM users WHERE firstLetter='$letter'";
0
 
lilyyanAuthor Commented:
hi, thanks so much. works great !
0
 
hongjunCommented:
welcome :)
glad your problem is solved.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now