Posted on 2004-10-22
Last Modified: 2012-05-05
How do I split a line like say I put

$result = @mysql_query("select Email from Login where `username`='" . $_POST['Text1'] . "' and `Password`='" . $_POST['Text2'] . "'");

but I want the above statement split in two like instead of having it one to do ti

Question by:Moizsaif123
    LVL 2

    Accepted Solution

    if you mean this whole sentence

    $result = @mysql_query("select Email from Login where `username`='" . $_POST['Text1'] . "' and `Password`='" . $_POST['Text2'] . "'");

    >>you can do this:
    $result = @mysql_query("select Email from Login where
      `username`='" . $_POST['Text1'] . "' and `Password`='" . $_POST['Text2'] . "'");
    LVL 49

    Assisted Solution

    $query = 'select Email from Login'.
                  ' where'.
                  ' `username`="' . addSlashes($_POST['Text1']) . '"'.
                  ' and '.
                  ' `Password`="' .md5($_POST['Text2']).'"';


    $query = 'select Email from Login
                   `username`="' . addSlashes($_POST['Text1']) . '"
                   `Password`="' .md5($_POST['Text2']).'"';

    $result = @mysql_query($query);


    LVL 7

    Assisted Solution

    OR :

    $Query = "SELECT Email FROM Login ";
    $Query.= "WHERE `username` = '{$_POST['Text1']}' ";
    $Query.= "AND `Password` = '{$_POST['Text2']}'";

    ... But it may be a little slower (in theory...) so prefer :

    $Query = "SELECT Email FROM Login " .
        "WHERE `username` = '{$_POST['Text1']}' " .
        "AND `Password` = '{$_POST['Text2']}'";

    Don't forget to addslashes() you variables if you don't have magic_quotes_gpc enabled !
    (This might be a security hole...)

    See ya

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    759 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

    12 Experts available now in Live!

    Get 1:1 Help Now