MySQL syntax problem, can anyone correct?

Posted on 2006-04-01
Last Modified: 2006-11-18
$sql2 = "SELECT numberforsession FROM sessions WHERE userone = '$sessions_waiting[1]' AND where usertwo = '$usernumber' LIMIT 1";

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where usertwo = '1' LIMIT 1' at line 1
Question by:stormist
    LVL 36

    Accepted Solution

    Hi stormist,

    Should be:

    $sql2 = "SELECT numberforsession FROM sessions WHERE userone = '$sessions_waiting[1]' AND usertwo = '$usernumber' LIMIT 1";

    LVL 36

    Expert Comment


    Although if usertwo and user1 are a number type, you also don't need the single quotes surrouding them.

    LVL 10

    Author Comment

    Thanks Ted!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    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