Closed Thread
Results 1 to 10 of 10
Like Tree2Likes
  • 1 Post By elliott1
  • 1 Post By elliott1

Thread: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.php

  1. #1
    elliott1 is offline x10Hosting Member elliott1 is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    31

    Exclamation Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.php

    the above comes up when trying to create a user using a php script the script is below where is says ther error is in:

    <?php
    $server = "localhost"; // server to connect to.
    $database = "xxxxxx"; // the name of the database.
    $db_user = "xxxxxx"; // mysql username to access the database with.
    $db_pass = "xxxxxx; // mysql password to access the database with.
    $table = "users"; // the table that this script will set up and use.
    ?>
    i use this instead of having to type out each personal detail, below is the script to create user:

    <?php
    include("xxxxx.php");
    // connect to the mysql server
    $link = mysql_connect("$server", "$db_user","$db_pass")
    or die ("Could not connect to mysql because ".mysql_error());
    // select the database or table?
    mysql_select_db("$table")
    or die ("Could not select database because ".mysql_error());
    // check if the users is taken
    $check = "select id from $table where Users = '".$_POST['users']."';";
    $qry = mysql_query($check) or die ("Could not match data because ".mysql_error());
    $num_rows = mysql_num_rows($qry);
    if ($num_rows != 0) {
    echo "Sorry, there the username $users is already taken.<br>";
    echo "<a href=register.html>Try again</a>";
    exit;
    } else {
    // insert the data
    $insert = mysql_query("insert into $table values ('NULL', '".$_POST['username']."',
    '".$_POST['password']."')")
    or die("Could not insert data because ".mysql_error());
    // print a success message
    echo "Your user account has been created!<br>";
    echo "Now you can <a href=main_login.html>log in</a>";
    }
    ?>
    Thanks everyone for your help
    dinomirt96 likes this.

  2. #2
    alfred is offline x10Hosting Member alfred is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    The internet
    Posts
    87

    Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    Well, you look at more recent php coding for this.

    PHP Code:
    <?php
    // Connecting, selecting database
    $link mysql_connect('mysql_host''mysql_user''mysql_password')
        or die(
    'Could not connect: ' mysql_error());
    echo 
    'Connected successfully';
    mysql_select_db('my_database') or die('Could not select database');


    ?>
    I tried the older version (you way), the same way you did, and it yielded me the same error. You are trying PHP4 in a PHP5 environment, and we all have to update our scripts. Visit http://us.php.net/manual/en/ for more help.
    Last edited by alfred; 10-10-2007 at 07:43 AM.

  3. #3
    elliott1 is offline x10Hosting Member elliott1 is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    31

    Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    it still doesnt work i dont know what php am using spend hours trying to fix it , do i need to upgrade my php account?

  4. #4
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,151

    Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    PHP Code:
    <?php
    $server 
    "localhost"// server to connect to.
    $database "xxxxxx"// the name of the database.
    $db_user "xxxxxx"// mysql username to access the database with.
    $db_pass "xxxxxx; // mysql password to access the database with.
    $table = "users"; // the table that this script will set up and use.
    ?>
    $db_pass = "xxxxxx; // mysql password to access the database with.

    This line in your code is missing a ", it should be:
    $db_pass = "xxxxxx"; // mysql password to access the database with.

  5. #5
    elliott1 is offline x10Hosting Member elliott1 is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    31

    Unhappy Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    i have already changed the above , but thanks , still doesnt work though :dunno::dunno::dunno::dunno:

  6. #6
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,151

    Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    Are you receiving the same error? Also it usually tells you what line the error is on. Can you paste the line that the error is on?

  7. #7
    elliott1 is offline x10Hosting Member elliott1 is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    31

    Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    i get a differnt error but it says on line 9:

    <?php
    include ("config.php");
    ////////////////////////////////////////
    ////// DONOT EDIT BELOW /////////
    ///////////////////////////////////////
    //
    connect to the mysql server
    $link = mysql_connect($server, $db_user, $db_pass)
    or die ("Could not connect to mysql because ".mysql_error());
    mysql_select_db("$mysql_database",$link) or die ("could not open db".mysql_error());
    thanks
    karimirt47 likes this.

  8. #8
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,151

    Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    It needs to be:
    PHP Code:
    <?php
    include ("config.php");
    ////////////////////////////////////////
    ////// DONOT EDIT BELOW /////////
    ///////////////////////////////////////
    //connect to the mysql server
    $link mysql_connect($server$db_user$db_pass) or die ("Could not connect to mysql because ".mysql_error());
    mysql_select_db("$mysql_database",$link) or die ("could not open db".mysql_error());

  9. #9
    elliott1 is offline x10Hosting Member elliott1 is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    31

    Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    THANKS! again but now it says there a error on line 12

    <html>
    <head>
    <title>(Type a title for your page here)</title>
    <meta name="GENERATOR" content="Arachnophilia 4.0">
    <meta name="FORMATTER" content="Arachnophilia 4.0">
    </head>
    <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
    if(isset($todo) and $todo=="post"){
    $status = "OK";
    $msg="";
    // if userid is less than 3 char then status is not ok
    if(!isset($userid) or strlen($userid) <3){
    $msg=$msg."User id should be =3 or more than 3 char length<BR>";
    $status= "NOTOK";}
    if(mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'"))){
    $msg=$msg."Userid already exists. Please try another one<BR>";
    $status= "NOTOK";}

  10. #10
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,151

    Re: Parse error: syntax error, unexpected T_STRING in /home/xxxxxx/public_html/xxxx.p

    Not really sure where you're getting this script from...
    Change
    PHP Code:
    <html>
    <
    head>
    <
    title>(Type a title for your page here)</title>
    <
    meta name="GENERATOR" content="Arachnophilia 4.0">
    <
    meta name="FORMATTER" content="Arachnophilia 4.0">
    </
    head>
    <
    body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
    if(isset(
    $todo) and $todo=="post"){
    $status "OK";
    $msg="";
    // if userid is less than 3 char then status is not ok
    if(!isset($userid) or strlen($userid) <3){
    $msg=$msg."User id should be =3 or more than 3 char length<BR>";
    $status"NOTOK";}
    if(
    mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'"))){
    $msg=$msg."Userid already exists. Please try another one<BR>";
    $status"NOTOK";} 
    TO
    PHP Code:
    <html>
    <head>
    <title>(Type a title for your page here)</title>
    <meta name="GENERATOR" content="Arachnophilia 4.0">
    <meta name="FORMATTER" content="Arachnophilia 4.0">
    </head>
    <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
    <?php
    if(isset($todo) and $todo=="post"){
    $status "OK";
    $msg="";
    // if userid is less than 3 char then status is not ok
    if(!isset($userid) or strlen($userid) <3){
    $msg=$msg."User id should be =3 or more than 3 char length<BR>";
    $status"NOTOK";}
    if(
    mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'"))){
    $msg=$msg."Userid already exists. Please try another one<BR>";
    $status"NOTOK";}
    Last edited by Corey; 10-11-2007 at 11:45 AM.

Closed Thread

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