Hi, could anyone help resolve this error message for the code below? Thanks so much.

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/web/admin/index.php on line 69

<script language=php>
session_start();
session_register("myauth");
include ("../connection.php");
$user_id=$username;
$pass=$pws;

    $checkadmin = 0;
    $la_checkadmin = 0;

if ($user_id!="" OR $pass!="")
{
    $query = "SELECT * FROM member WHERE username='$user_id'";
    if (!($result = mysql_query($query))) 
        echo "$query".mysql_error();  
    $row=mysql_fetch_object($result);
    if($row->username."a" != "a" )
        $checkadmin = 1;
        $username=$row->username;
    $pws=$row->pws;                      

    $query = "SELECT * FROM localadmin WHERE username='$user_id'";
    if (!($result = mysql_query($query))) 
        echo "$query".mysql_error();  

    $row=mysql_fetch_object($result); 
    if($row->username."a" != "a" )
        $la_checkadmin = 1;
        $lausername=$row->username;
    $lapws=$row->password;                      
    $lavalidcityid=$row->validcityid;
    $laid = $row->id;

    if($checkadmin == 1)
    {
        if (($username=="admin") and ($pass==$pws)) 
        {
            $myauth = "admin";
            $_SESSION['adminauth'] = "admin";
                header("location: home.php?PHPSESSID=".session_id());
                exit;
        }
    }
    elseif($la_checkadmin == 1)
    {
        if (($lausername==$user_id) and ($pass==$lapws)) 
        {
            $myauth = "admin";
            $_SESSION['adminauth'] = "localadmin";
            $_SESSION['localadmin'] = "localadmin";
            $_SESSION['localadmin_city'] = $lavalidcityid;
            $_SESSION['localadmin_id'] = $laid;

                           $query = "INSERT INTO localadmin_monitor (adminid,action) values('$laid','<b>LOGIN</b>')";
                           if (!($result = mysql_query($query))) 
                            echo "$query".mysql_error();  

                        header("location: home.php?PHPSESSID=".session_id());                           
                exit;
        }
    } 
    else
    {
            $is_false="false";
    }           
    if($is_false=="false")
        echo "<body><p align=center><b><font face='arial' size='2' color='#FF0000'>Wrong User ID or Password <a href='$PHP_SELF'> Go Back </a> and login again.</font></b></p>

<div align="center">
  <center>

<table border="0" width="780" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%">
      <p align="center"><img border="0" src="../images/EC-30.gif" width="291" height="59"><br>
      &nbsp;</td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#686868" height="10"></td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#D09850" height="21">
      <p align="center"><b><font size="2" face="Verdana" color="#FFFFFF">Coordinator
      Login</font></b></td>
  </tr>
  <tr>
    <td width="100%">&nbsp;<br>
      <br>
      &nbsp;<br>
      &nbsp;<br>
      &nbsp;<br>
    </td>
  </tr>
  <tr>
    <td width="100%">
 <form method="POST" action="index.php">
 <center>
  <table  align="center">
    <tr>
      <td align="right"><p><b><font color="#000000" face="Verdana" size="2">Username:</font></b></p></td>
      <td><input type="text" name="username" size="15" style="font-family : Verdana;"></td>
    </tr>
    <tr>
      <td align="right"><p><b><font color="#000000" size="2" face="Verdana">Password:</font></b></p></td>
      <td><input type="password" name="pws" size="15" style="font-family : Verdana;"></td>
    </tr>

    <tr>
      <td colspan="2">
        <p align="center"><INPUT TYPE="image" SRC="../images/submit.jpg" BORDER=0 ALT="">
        </p>
      </td>
    </tr>
  </table>
  </center>
</form>

    </td>
  </tr>
  <tr>
    <td width="100%"></td>
  </tr>
</table>

  </center>
<!--/div-->

</body>"
</html>
<script language=php>
}
</script>
Member Avatar for Zagga

The error message is showing the script was parsed correctly until it got to line 69, where it found an unexpected character. Work backwards from line 69 to find the error.
I won't point out exactly where, but your error is on line 67.

Hi, thanks for your reply. I only just learned HTML and opened this code in PHP, in which I have zero background or knowledge. Could you please do me a big favor and advise how line 67 should read? I can at least copy and paste and upload. Thanks so much.

Member Avatar for diafol

Sorry, but wading through all that is a bit of a chore. You do have unescaped " " double quotes in the echo text, so that will throw an error. Escaping just means placing a backslash before it, e.g. name=\"username\"

However, this approach should be avoided whenever possible. Placing a huge chunk of html for php to parse is a waste of time.

A better approach would be to use a template or plain html with the odd bit of inline php.

Hi, thanks for your reply. I read it 3 times but still have no idea how to fix the problem. As I mentioned above, I have zero background or knowledge of PHP. Zagga said that the problem is in line 67, so I am thinking that if I can get the corrected version of line 67, I can at least copy, paste and upload it. Would it be ok for me to ask for that?

Member Avatar for diafol

Unfortunately, it looks like your line 67 spans to line 128 in this code display, which means that the error(s) could be anywhere between. As I mentioned, if you backslash (escape) EVERY double quote within the echo string, it may magically work.

Hi, I put a backslash just before EVERY quotation mark in between lines 67 to 128 (is that what you meant by "echo string"?)as below and got this error:

Parse error: syntax error, unexpected $end in /home/vg008web08/52/58/2915852/web/admin/index.php on line 133

<script language=php>
session_start();
session_register("myauth");
include ("../connection.php");
$user_id=$username;
$pass=$pws;

    $checkadmin = 0;
    $la_checkadmin = 0;

if ($user_id!="" OR $pass!="")
{
    $query = "SELECT * FROM member WHERE username='$user_id'";
    if (!($result = mysql_query($query))) 
        echo "$query".mysql_error();  
    $row=mysql_fetch_object($result);
    if($row->username."a" != "a" )
        $checkadmin = 1;
        $username=$row->username;
    $pws=$row->pws;                      

    $query = "SELECT * FROM localadmin WHERE username='$user_id'";
    if (!($result = mysql_query($query))) 
        echo "$query".mysql_error();  

    $row=mysql_fetch_object($result); 
    if($row->username."a" != "a" )
        $la_checkadmin = 1;
        $lausername=$row->username;
    $lapws=$row->password;                      
    $lavalidcityid=$row->validcityid;
    $laid = $row->id;

    if($checkadmin == 1)
    {
        if (($username=="admin") and ($pass==$pws)) 
        {
            $myauth = "admin";
            $_SESSION['adminauth'] = "admin";
                header("location: home.php?PHPSESSID=".session_id());
                exit;
        }
    }
    elseif($la_checkadmin == 1)
    {
        if (($lausername==$user_id) and ($pass==$lapws)) 
        {
            $myauth = "admin";
            $_SESSION['adminauth'] = "localadmin";
            $_SESSION['localadmin'] = "localadmin";
            $_SESSION['localadmin_city'] = $lavalidcityid;
            $_SESSION['localadmin_id'] = $laid;

                           $query = "INSERT INTO localadmin_monitor (adminid,action) values('$laid','<b>LOGIN</b>')";
                           if (!($result = mysql_query($query))) 
                            echo "$query".mysql_error();  

                        header("location: home.php?PHPSESSID=".session_id());                           
                exit;
        }
    } 
    else
    {
            $is_false="false";
    }           
    if ($is_false == "false") { ?>
<body><p align=center><b><font face='arial' size='2' color='#FF0000'>Wrong User ID or Password <a href=<?php echo $_SERVER['PHP_SELF']; ?>> Go Back </a> and login again.</font></b></p>
echo
<div align=\"center\">
  <center>

<table border=\"0\" width=\"780\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td width=\"100%\">
      <p align=\"center\"><img border=\"0\" src=\"../images/EC-30.gif\" width=\"291\" height=\"59\"><br>
      &nbsp;</td>
  </tr>
  <tr>
    <td width=\"100%\" bgcolor=\"#686868\" height=\"10\"></td>
  </tr>
  <tr>
    <td width=\"100%\" bgcolor=\"#D09850\" height=\"21\">
      <p align=\"center\"><b><font size=\"2\" face=\"Verdana\" color=\"#FFFFFF\">Coordinator
      Login</font></b></td>
  </tr>
  <tr>
    <td width=\"100%\">&nbsp;<br>
      <br>
      &nbsp;<br>
      &nbsp;<br>
      &nbsp;<br>
    </td>
  </tr>
  <tr>
    <td width=\"100%\">
 <form method=\"POST\" action=\"index.php\">
 <center>
  <table  align=\"center\">
    <tr>
      <td align=\"right\"><p><b><font color=\"#000000\" face=\"Verdana\" size=\"2\">Username:</font></b></p></td>
      <td><input type=\"text\" name=\"username\" size=\"15\" style=\"font-family : Verdana;\"></td>
    </tr>
    <tr>
      <td align=\"right\"><p><b><font color=\"#000000\" size=\"2\" face=\"Verdana\">Password:</font></b></p></td>
      <td><input type=\"password\" name=\"pws\" size=\"15\" style=\"font-family : Verdana;\"></td>
    </tr>

    <tr>
      <td colspan=\"2\">
        <p align=\"center\"><INPUT TYPE=\"image\" SRC=\"../images/submit.jpg\" BORDER=0 ALT=\"\">
        </p>
      </td>
    </tr>
  </table>
  </center>
</form>

    </td>
  </tr>
  <tr>
    <td width=\"100%\"></td>
  </tr>
</table>

  </center>
<!--/div-->

</body>
</html>

<script language=php>
}
</script>
Member Avatar for diafol

You've now taken the parsing off at line 68:

echo
<div align=\"center\">

If you intend to just have plain html with the occasional bit of php, then you don't need to backslash.

Also this:

<script language=php>
}
</script>

Doesn't make sense.
I believe you're looking for this?

<?php
}
?>

I don't know what is "parsing". Fyi, I am not a programmer and know nothing about PHP. I know a little bit of HTML but that's about it, and now I am totally confused about the backslashes. I've played with the code based on your input but am still getting errors:

Parse error: syntax error, unexpected $end in /home/vg008web08/52/58/2915852/web/admin/index.php on line 132

Here is the code. Could you please just make whatever edits need to be made and advise? I am not asking you to do what I can do; I'm asking you to help me with something that I cannot do. Thanks very much in advance.

<script language=php>
session_start();
session_register("myauth");
include ("../connection.php");
$user_id=$username;
$pass=$pws;

    $checkadmin = 0;
    $la_checkadmin = 0;

if ($user_id!="" OR $pass!="")
{
    $query = "SELECT * FROM member WHERE username='$user_id'";
    if (!($result = mysql_query($query))) 
        echo "$query".mysql_error();  
    $row=mysql_fetch_object($result);
    if($row->username."a" != "a" )
        $checkadmin = 1;
        $username=$row->username;
    $pws=$row->pws;                      

    $query = "SELECT * FROM localadmin WHERE username='$user_id'";
    if (!($result = mysql_query($query))) 
        echo "$query".mysql_error();  

    $row=mysql_fetch_object($result); 
    if($row->username."a" != "a" )
        $la_checkadmin = 1;
        $lausername=$row->username;
    $lapws=$row->password;                      
    $lavalidcityid=$row->validcityid;
    $laid = $row->id;

    if($checkadmin == 1)
    {
        if (($username=="admin") and ($pass==$pws)) 
        {
            $myauth = "admin";
            $_SESSION['adminauth'] = "admin";
                header("location: home.php?PHPSESSID=".session_id());
                exit;
        }
    }
    elseif($la_checkadmin == 1)
    {
        if (($lausername==$user_id) and ($pass==$lapws)) 
        {
            $myauth = "admin";
            $_SESSION['adminauth'] = "localadmin";
            $_SESSION['localadmin'] = "localadmin";
            $_SESSION['localadmin_city'] = $lavalidcityid;
            $_SESSION['localadmin_id'] = $laid;

                           $query = "INSERT INTO localadmin_monitor (adminid,action) values('$laid','<b>LOGIN</b>')";
                           if (!($result = mysql_query($query))) 
                            echo "$query".mysql_error();  

                        header("location: home.php?PHPSESSID=".session_id());                           
                exit;
        }
    } 
    else
    {
            $is_false="false";
    }           
    if ($is_false == "false") { ?>
<body><p align=center><b><font face='arial' size='2' color='#FF0000'>Wrong User ID or Password <a href=<?php echo $_SERVER['PHP_SELF']; ?>> Go Back </a> and login again.</font></b></p>
<div align="center">
  <center>

<table border="0" width="780" cellspacing="0" cellpadding="0">
  <tr>
    <td width="100%">
      <p align="center"><img border="0" src="../images/EC-30.gif" width="291" height="59"><br>
      &nbsp;</td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#686868" height="10"></td>
  </tr>
  <tr>
    <td width="100%" bgcolor="#D09850" height="21">
      <p align="center"><b><font size="2" face="Verdana" color="#FFFFFF">Coordinator
      Login</font></b></td>
  </tr>
  <tr>
    <td width="100%">&nbsp;<br>
      <br>
      &nbsp;<br>
      &nbsp;<br>
      &nbsp;<br>
    </td>
  </tr>
  <tr>
    <td width="100%">
 <form method="POST" action="index.php">
 <center>
  <table  align="center">
    <tr>
      <td align="right"><p><b><font color="#000000" face="Verdana" size="2">Username:</font></b></p></td>
      <td><input type="text" name="username" size="15" style="font-family : Verdana;"></td>
    </tr>
    <tr>
      <td align="right"><p><b><font color="#000000" size="2" face="Verdana">Password:</font></b></p></td>
      <td><input type="password" name="pws" size="15" style="font-family : Verdana;"></td>
    </tr>

    <tr>
      <td colspan="2">
        <p align="center"><INPUT TYPE="image" SRC="../images/submit.jpg" BORDER=0 ALT="">
        </p>
      </td>
    </tr>
  </table>
  </center>
</form>

    </td>
  </tr>
  <tr>
    <td width="100%"></td>
  </tr>
</table>

  </center>
<!--/div-->

</body>"
</html>

<?php 
} 
?>
Member Avatar for diafol

I have to respectfully decline your request. My time on DW is spent helping those who are prepared to help themselves. I believe the advice I gave should be sufficient to get you most of the way. Learning php would not be a bad idea if you wish to use it.

Member Avatar for Zagga

Hi again,

Okay, there are quite a few errors in the code you have supplied. Fixing one will lead to another and another.

Like diafol said, PHP is just like any other language, if you want to use it, you are best off learning a bit about it first.

If you still want to fix this particular piece of code now, instead of learning how to write your own version, start by changing line 1 to

<?php

This is the tag you need to start PHP

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.