PHP: What is wrong with my if statement?

Posted on 2006-04-07
Last Modified: 2010-04-17
What is wrong with my syntax?
if (mysql_num_rows($user) == 1) && if ( md5($us_pass) == $pass ) {
  //  stuff to do
Question by:rae_rae
    1 Comment
    LVL 54

    Accepted Solution


    Try this:

    if ((mysql_num_rows($user) == 1) && ( md5($us_pass) == $pass )) {
      //  stuff to do

    The complete block should be in parenthesis and you do not need the if statement in the second portion.


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    isEverywhere  challenge 19 48
    fix34  challenge 9 70
    thread-safe code in c++ 2 58
    White board coding practice 3 31
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 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

    17 Experts available now in Live!

    Get 1:1 Help Now