+ Reply to Thread
Results 1 to 7 of 7

Thread: PHP error.

  1. #1
    taekwondokid42 is offline x10 Lieutenant taekwondokid42 is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    268

    PHP error.

    Parse error: syntax error, unexpected T_STRING in /home/mike/public_html/loginp.php on line 13


    Line 13 reads like this:

    $sql = SELECT FROM users WHERE name == "$username" AND pass == "$password";

    what is the problem?

    There are no syntax errors in the line above or below it.

  2. #2
    sms_dre is offline x10Hosting Member sms_dre is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    18

    Re: PHP error.

    you need single quote marks round the whole query as its a string (and you're already using doubles inside the string):

    $sql = 'SELECT FROM users WHERE name == "$username" AND pass == "$password"';

  3. #3
    taekwondokid42 is offline x10 Lieutenant taekwondokid42 is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    268

    Re: PHP error.

    thank you.

  4. #4
    deadimp is offline x10 Sophmore deadimp is an unknown quantity at this point
    Join Date
    Jun 2007
    Posts
    249

    Re: PHP error.

    Be sure to sanitize (escape) your strings to prevent MySQL injection!
    deadimp.org
    > Thacmus [v0.3.0] - Open source CMS, PHP 5, MySQL

    "¡Ya lo sabo!" - Lo Ausente

  5. #5
    *Face is offline x10Hosting Member *Face is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    62

    Re: PHP error.

    Code:
    $sql = 'SELECT FROM users WHERE name == "$username" AND pass == "$password"';
    That doesn't look like it'll actually work, since PHP doesn't parse variables in strings with single quotes.
    Code:
    $sql = 'SELECT FROM users WHERE name == "'.$username.'" AND pass == "'.$password.'"';
    This should work, always assuming you have proper protection in place.

  6. #6
    conker87 is offline x10Hosting Member conker87 is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    UK
    Posts
    65

    Re: PHP error.

    Or do it the logical way:

    Code:
    $sql = "SELECT FROM users WHERE name = '$username' AND pass = '$password'";
    I've never seen '==' used ever in MySQL.
    Last edited by conker87; 11-02-2007 at 11:01 AM.

  7. #7
    taekwondokid42 is offline x10 Lieutenant taekwondokid42 is an unknown quantity at this point
    Join Date
    Aug 2007
    Posts
    268

    Re: PHP error.

    Thank you.

    I like the last way the best. And if you were wondering, I got the script working now.

+ Reply to Thread

Similar Threads

  1. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  2. Sigo con problemas con phpbb2
    By reciecho in forum Soporte
    Replies: 7
    Last Post: 10-20-2007, 06:28 PM
  3. Replies: 6
    Last Post: 10-18-2007, 06:07 AM
  4. Error after php update
    By Slat1 in forum Free Hosting
    Replies: 2
    Last Post: 09-30-2007, 03:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers