systax error: mysql_fetch_array( )

Posted on 2007-07-23
Last Modified: 2008-03-06

I'm using these php statments:
$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!

Question by:lilyyan
    LVL 33

    Accepted Solution

    try this

    $sql ="SELECT * FROM users WHERE firstLetter='$letter'";

    Author Comment

    hi, thanks so much. works great !
    LVL 33

    Expert Comment

    welcome :)
    glad your problem is solved.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now