[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • 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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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