www.webdeveloper.com
Results 1 to 8 of 8

Thread: mysql_error(): Unexpected T_STRING??

  1. #1
    Join Date
    Mar 2007
    Posts
    11

    Exclamation mysql_error(): Unexpected T_STRING??

    Hey, I would be very appreciative to anyone who could help me solve this problem.

    The PHP code that has the error is:
    PHP Code:

    if($password != $password2)//checks to see if passwords match
    {
    die(
    'Passwords don't match please go back');//error msg

    The error is: Parse error: syntax error, unexpected T_STRING in /home/sitesfor/public_html/login/register.php on line 68

    The code above is line 68...

    Any help would be extremely helpful, thank you.

  2. #2
    Join Date
    Apr 2007
    Posts
    10
    You have a single quote in your die message. You need to escape it with a back slash. eg
    PHP Code:
    if($password != $password2)//checks to see if passwords match
    {
    die(
    'Passwords don\'t match please go back');//error msg


  3. #3
    Join Date
    Jul 2006
    Posts
    14

  4. #4
    Join Date
    Mar 2007
    Posts
    11
    Thank you, it worked. I have a few errors in the script it seems... It's not my code, so... lol. Do you want me to post it all?

    Again, thank you for your help now and in future problems.

  5. #5
    Join Date
    Jul 2006
    Posts
    14

  6. #6
    Join Date
    Mar 2007
    Posts
    11

    Exclamation The rest of my code. It's a bit sloppy, but again, it's not my code.

    As soon as it is debugged, I will work on the readability.

    PHP Code:
    <html>
    <head>
    </head>
    <body>
    <?php
    $dbname 
    "sitesfor_users";
    $dbuname "sitesfor_sfy";
    $dbpass "jj1a3m5"
    mysql_connect("localhost",$dbuname,$dbpass) or die("Couldn't connect to database");
    mysql_select_db($dbname) or die("Couldn't select database table");
    ?>

    <div align="center">
    <?php
    if($_SESSION['username']){
    echo (
    "You are already Logged in");
    }
    else{
    ######################
    /*
    Define some varibles.    
    */        
    $register $_POST['register'];//This is the submit button input
    $username $_POST['user'];//username value
    $password $_POST['pass'];//password value
    $password2 $_POST['pass2'];//password check value
    $msn $_POST['msn'];//msn input value
    $avy $_POST['avy'];//avy input value
    $email $_POST['email'];//avy input value
    ######################
    if(!$register){
    echo (
    "
    <form action='register.php' method='post' name='registration'>
    <table colspan='2' cellspacing='0'>
    <tr>
    <td>Username*</td><td><input type='text' name='user' value='' /></td>
    </tr>
    <tr>
    <td>Password*</td><td><input type='text' name='pass' value='' /></td>
    </tr>
    <tr>
    <td>Password*</td><td><input type='text' name='pass2' value='' /></td>
    </tr>
    <tr>
    <td>Email*</td><td><input type='text' name='user' value='' /></td>
    </tr>
    <tr>
    <td>MSN</td><td><input type='text' name='user' value='' /></td>
    </tr>
    <tr>
    <td>Avatar</td><td><input type='text' name='user' value='' /></td>
    </tr>
    </table>
    <input type='submit' value='Register' name='register' />
    </form>
    "
    ); }
    else {
    /*Select Data from the sql to see if user exist or email exist*/
    $checkusers mysql_query("SELECT * FROM usertable where username='$username.');
    $valid = mysql_fetch_array($checkusers);
        if(!empty(
    $valid)){
            die('The username you chose is already in use, please choose another.');
        exit;
        }
    if(
    $password != $password2)//checks to see if passwords match
    {
    die('Passwords don\'t match please go back');//error msg

    $query_data = "INSERT INTO `usertable
    (`
    username`,`password`,`msn`,`avatar`,`email`) 
    VALUES('$username','$password','$msn','$avy','$email')";
    $insert_data = mysql_query($query_data) or die(mysql_error());
    //inserts data into 
    the database
    //echo message
    echo ("
    You are now registered please login here <a href='login.php'><b>Login</b></a>");
        }
    }
    ?>
    </div>
    </body>
    </html>
    Any help would be greatly appreciated. This is my first PHP website...

  7. #7
    Join Date
    Apr 2007
    Posts
    10
    I havent tested this at all but I think i have removed the parsing errors

    PHP Code:

    <html>
    <head>
    </head>
    <body>
    <?php
    $dbname 
    "sitesfor_users";
    $dbuname "sitesfor_sfy";
    $dbpass "jj1a3m5";
    mysql_connect("localhost",$dbuname,$dbpass) or die("Couldn't connect to database");
    mysql_select_db($dbname) or die("Couldn't select database table");
    ?>

    <div align="center">
    <?php
    if($_SESSION['username'])
    {
        echo (
    "You are already Logged in");
    }
    else
    {
        
    ######################
        /*
        Define some varibles.
        */
        
    $register $_POST['register'];//This is the submit button input
        
    $username $_POST['user'];//username value
        
    $password $_POST['pass'];//password value
        
    $password2 $_POST['pass2'];//password check value
        
    $msn $_POST['msn'];//msn input value
        
    $avy $_POST['avy'];//avy input value
        
    $email $_POST['email'];//avy input value
        ######################
        
    if(!$register)
        {
            echo 
    "
            <form action='register.php' method='post' name='registration'>
            <table colspan='2' cellspacing='0'>
            <tr>
            <td>Username*</td><td><input type='text' name='user' value='' /></td>
            </tr>
            <tr>
            <td>Password*</td><td><input type='text' name='pass' value='' /></td>
            </tr>
            <tr>
            <td>Password*</td><td><input type='text' name='pass2' value='' /></td>
            </tr>
            <tr>
            <td>Email*</td><td><input type='text' name='user' value='' /></td>
            </tr>
            <tr>
            <td>MSN</td><td><input type='text' name='user' value='' /></td>
            </tr>
            <tr>
            <td>Avatar</td><td><input type='text' name='user' value='' /></td>
            </tr>
            </table>
            <input type='submit' value='Register' name='register' />
            </form>
            "
    ;
        }
        else
        {
            
    /*Select Data from the sql to see if user exist or email exist*/
            
    $checkusers mysql_query("SELECT * FROM usertable where username='$username'");
            
    $valid mysql_fetch_array($checkusers);
            if(!empty(
    $valid))
            {
                die(
    'The username you chose is already in use, please choose another.');
                exit;
            }
            if(
    $password != $password2)//checks to see if passwords match
            
    {
                die(
    'Passwords don\'t match please go back');//error msg
            
    }
            
    $query_data "INSERT INTO `usertable`
            (`username`,`password`,`msn`,`avatar`,`email`)
            VALUES('
    $username','$password','$msn','$avy','$email')";


            
    $insert_data mysql_query($query_data) or die(mysql_error());
            
    //inserts data into the database
            //echo message
            
    echo "You are now registered please login here <a href='login.php'><b>Login</b></a>";
        }
    }
    ?>
    </div>
    </body>
    </html>

  8. #8
    Join Date
    Mar 2007
    Posts
    11
    Thank you, very much! It works now. All I have to do now is make the login script Again, thank you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles