+ Reply to Thread
Results 1 to 5 of 5

Thread: T string

  1. #1
    fileupload is offline x10Hosting Member fileupload is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    3

    T string

    I am following login tutorials on the internet and it comes up with this error code:
    Parse error: syntax error, unexpected T_STRING in /home/file1234/public_html/do_login.php on line 35
    and here is the code could you help me out:
    <html>
    <head>
    <title>Login</title>
    <body bgcolor="#009933">
    </head>
    <body>
    <br><br>
    <font color="white"><center><h1>FileFlame.Pcriot.Com</center></font></h1>
    <br><br>
    <DIV ALIGN=LEFT>
    <FORM>
    <INPUT TYPE="BUTTON" VALUE="Home" ONCLICK="window.location.href='index.php'">
    <INPUT TYPE="BUTTON" VALUE="Register" ONCLICK="window.location.href='register.php'">
    <INPUT TYPE="BUTTON" VALUE="Login" ONCLICK="window.location.href='login.php'">
    <INPUT TYPE="BUTTON" VALUE="Search" ONCLICK="window.location.href='browse.php'">
    <INPUT TYPE="BUTTON" VALUE="News" ONCLICK="window.location.href='news.php'">
    </FORM>
    <br><br>
    <?php

    $connection = mysql_connect(localhost, prefix_user, password);
    $db = mysql_select_db(prefix_dbname, $connection);

    $sql = "SELECT id FROM user
    WHERE username='$_POST[username]'
    AND PASSWORD='$_POST[password]'";

    $result = mysql_query ($sql);
    $num = mysql_num_rows($result);

    if ($num > 0) (
    //USER AND PASS ARE CORRECT
    $id = mysql_fetch_assoc($result))

    header("Location: main.php");
    } else {
    header ("Location: incorrect.php");
    };

    ?>
    Successful Login, click <INPUT TYPE="BUTTON" VALUE="here" ONCLICK="window.location.href='index.php'"> to go back home
    <font color="#ffffff"><font size='+1'><strong><br><center>Copyright &copy; 2010-2014 FileRiver. All Rights Reserved.</font>
    </body>
    </html>

  2. #2
    Zubair's Avatar
    Zubair is offline x10 Super Spammer Zubair has a reputation beyond reputeZubair has a reputation beyond reputeZubair has a reputation beyond repute
    Join Date
    Jul 2009
    Location
    Pakistan
    Posts
    8,747

    Re: T string

    Wrong Section

    ***Moved to Programming Help***
    Zubair Barkat | Level 2 Tech
    █ 888-X10-9668 - zubair[@]x10hosting.com
    x10Hosting - Giving Away Hosting Since 2004

  3. #3
    vishal's Avatar
    vishal is offline -::-X10 Guru-::- vishal has a brilliant futurevishal has a brilliant future
    Join Date
    Nov 2009
    Location
    INDIA
    Posts
    5,254

    Re: T string

    I think this is the error
    if ($num > 0) (
    //USER AND PASS ARE CORRECT
    $id = mysql_fetch_assoc($result))
    It should be " { "

    Replace that part with this.
    Code:
    if ($num > 0) {
    //USER AND PASS ARE CORRECT
    $id = mysql_fetch_assoc($result);
    header("Location: main.php");
    }
    
    
     else {
    header ("Location: incorrect.php");
    }
    ?>
    Last edited by vishal; 05-08-2010 at 12:41 PM.
    Regards ~ Vishal
    Giving Reputation (at bottom of my post ) is the best way to encourage the person who helped you on forums.

  4. #4
    includes is offline x10Hosting Member includes is an unknown quantity at this point
    Join Date
    Apr 2010
    Posts
    10

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: T string

    • When posting code, use the [php], [html] or [code] tags (as appropriate) to separate the code from the rest of the post and format it.
    • Mark which lines are referred to in error messages. Even if posting doesn't alter the line count, we shouldn't have to pour over the code to find the appropriate lines.
    • Your script is vulnerable to SQL injection (see also "SQL Injection Walkthrough"). Instead of the outdated mysql driver, use PDO and prepared statements. Search the web for more information.
    • Don't store plain passwords. Passwords should be salted and hashed, giving each password its own salt.
    • Make sure you test for error conditions on any functions that might fail. With PDO, you can set the error mode to PDO::ERRMODE_EXCEPTION and catch PDOExceptions. Make your error messages useful but not too revealing.
    • Don't use SELECT *.
    • Validate your HTML and fix the errors.
    • Don't use <font>, <center>, align=, bgcolor= or any other presentational element or attribute (except potentially the style attribute, and that only in very limited circumstances). Use CSS for presentation instead. Keep HTML semantic.
    • All elements should be closed (except <meta>, <link> and <base> in HTML 4 docs). For example, use "<br/>", not "<br>". Actually, you shouldn't be using <br/> at all the way you are (see previous point).
    • Add a doctype to your document.
    • Follow the instructions in my sig.
    • Lastly, but most importantly, file hosting breaks the terms of service. It will get your site shut down permanently (it's covered under "severe misuse of server resources"), with no chance to recover anything. Immediately download anything you don't want to lose, then remove the file hosting scripts.

    Quote Originally Posted by includes View Post
    That tutorial has some error checking, but otherwise is full of bad practices, including SELECT *, or die, outputting mysql_error to visitors, SQL injection vulnerabilities... In short, avoid.
    Last edited by misson; 05-09-2010 at 04:51 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Reg connection String for database
    By sudheer_oct26 in forum Free Hosting
    Replies: 1
    Last Post: 04-30-2010, 05:22 PM
  2. extracting from a string
    By garrensilverwing in forum Programming Help
    Replies: 28
    Last Post: 06-09-2009, 07:00 PM
  3. PHP found in string help
    By Chris S in forum Programming Help
    Replies: 9
    Last Post: 04-06-2009, 12:08 PM
  4. Split string
    By radofeya in forum Programming Help
    Replies: 3
    Last Post: 10-02-2008, 02:35 AM
  5. MB String Support?
    By civilr in forum Free Hosting
    Replies: 5
    Last Post: 06-19-2007, 09:26 AM

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