Jump to content

Parse error: syntax error, unexpected T_VARIABLE


june_c21

Recommended Posts

can someone tell me what wrong with my wrong code? i get this error "Parse error: syntax error, unexpected T_VARIABLE line 2"

 

<? php
$host = 'localhost';
$user = 'root';
$password = 'admin';
$dbase = 'claim';

$dblink = mysql_connect($host,$user,$password);
mysql_select_db($dbase,$dblink);

echo "<table border=3 align=center width=90%>";
echo "<tr><td>ID</td>";
echo "<td>Month</td>";
echo "<td>Start Date </td>";
echo "<td>End Date</td>";
echo "<td>Name</td>";
echo "<td>Staff No</td>";
echo "<td>Details</td>";
echo "<td>Amount</td>";
echo "<td>GL code</td>";
  echo "<td>Bank </td>";
echo "<td>Account No. </td><tr>";


 $name = $_GET['name'];

$query = "SELECT report1.id, month, start_date, end_date, user.name, report1.staff_no,details,amount,gl_code,user.bank,user.acc_no FROM user,report1 WHERE user.name = "$name";
$result = mysql_query($query, $dblink);
while($myrow = mysql_fetch_row($result))
{
echo "<tr><td>" . $myrow[0] . "</td>";
  	 echo "<td>" . $myrow[1] . "</td>";
  	 echo "<td>" . $myrow[2] . "</td>";
  	 echo "<td>" . $myrow[3] . "</td>";
  	  echo "<td>" . $myrow[4] . "</td>";
   	 echo "<td>" . $myrow[5] . "</td>";
   	 echo "<td>" . $myrow[6] . "</td>";
   	echo "<td>" . $myrow[7] . "</td>";
echo "<td>" . $myrow[8] . "</td>";
echo "<td>" . $myrow[9] . "</td>";
echo "<td>" . $myrow[10] . "</td></tr>";

}

echo "</table>";

?>


Link to comment
Share on other sites

thanks rohan

 

but now the parse error: syntax error, unexpected T_VARIABLE  is at line 26 which is this line

 

$query = "SELECT report1.id, month, start_date, end_date, user.name, report1.staff_no,details,amount,gl_code,user.bank,user.acc_no FROM user,report1 WHERE user.name = "$name"";

Link to comment
Share on other sites

$query = "SELECT report1.id, month, start_date, end_date, user.name, report1.staff_no, details, amount, gl_code, user.bank, user.acc_no FROM user, report1 WHERE user.name = '$name'";

 

That should work.

Link to comment
Share on other sites

now there is no error. thanks for all the help .

but why when i wrote

 

$name = $_POST['name'];
$query = "SELECT report1.id,month,start_date,end_date,user.name,report1.staff_no,details,amount,gl_code,user.bank,user.acc_no FROM user,report1 WHERE report1.staff_no = '$name' ";
$result = mysql_query($query, $dblink);
while($myrow = mysql_fetch_row($result))
{
echo "<tr><td>" . $myrow[0] . "</td>";
  	 echo "<td>" . $myrow[1] . "</td>";
  	 echo "<td>" . $myrow[2] . "</td>";
  	 echo "<td>" . $myrow[3] . "</td>";
  	  echo "<td>" . $myrow[4] . "</td>";
   	 echo "<td>" . $myrow[5] . "</td>";
   	 echo "<td>" . $myrow[6] . "</td>";
   	echo "<td>" . $myrow[7] . "</td>";
echo "<td>" . $myrow[8] . "</td>";
echo "<td>" . $myrow[9] . "</td>";
echo "<td>" . $myrow[10] . "</td></tr>";

}

 

it came out all the data instead of where the staff_no = $name only?

Link to comment
Share on other sites

$name = $_POST['name'];

$query = "SELECT report1.id, month, start_date, end_date, user.name, report1.staff_no, details, amount, gl_code, user.bank, user.acc_no FROM user, report1 WHERE report1.staff_no = '$name'";

$result = mysql_query($query, $dblink);

while($myrow = mysql_fetch_array($result)) {
echo "<tr><td>" . $myrow[0] . "</td>";
  	echo "<td>" . $myrow[1] . "</td>";
  	echo "<td>" . $myrow[2] . "</td>";
  	echo "<td>" . $myrow[3] . "</td>";
  	echo "<td>" . $myrow[4] . "</td>";
   	echo "<td>" . $myrow[5] . "</td>";
   	echo "<td>" . $myrow[6] . "</td>";
   	echo "<td>" . $myrow[7] . "</td>";
echo "<td>" . $myrow[8] . "</td>";
echo "<td>" . $myrow[9] . "</td>";
echo "<td>" . $myrow[10] . "</td></tr>";
}

 

Try that.

Link to comment
Share on other sites

ok, first this is my html coding where user can chose the staff_no and click on submit. once submit, it will find in the database the same staff_no that match the one user select. if it is yes, it will display the records base on the staff_no .

 

<html>
<head>
<script src="selectuser.js"></script>
</head>
<body><form id="form1" name="form1" method="post" action="checking.php">
  <p><strong>KEV Claim</strong></p>
  <table width="497" border="0">
    <tr>
      <td width="284">Claim</td>
      <td width="203"><select name="name" id="name" onChange="showUser(this.value)">
        <?php
  $host = 'localhost';
  $user = 'root';
  $password = 'admin';
  $dbase = 'claim';

  $dblink = mysql_connect($host,$user,$password);
  mysql_select_db($dbase,$dblink);

  $query = "SELECT staff_no, name from user order by name ";
      		$result = mysql_query($query);
		while($myrow = mysql_fetch_row($result))
		{
			echo "<OPTION VALUE=\"" . $myrow[0] . "\">" . $myrow[1]."</OPTION>";
		}
?>
            </select></td>
    </tr>
  </table>
  <p> </p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form></body>
</html>

 

<?php
$host = "localhost";
$user = "root";
$password = "admin";
$dbase = "claim";

$dblink = mysql_connect($host,$user,$password);
mysql_select_db($dbase,$dblink);

echo "<table border=3 align=center width=90%>";
echo "<tr><td>ID</td>";
echo "<td>Month</td>";
echo "<td>Start Date </td>";
echo "<td>End Date</td>";
echo "<td>Name</td>";
echo "<td>Staff No</td>";
echo "<td>Details</td>";
echo "<td>Amount</td>";
echo "<td>GL code</td>";
  echo "<td>Bank </td>";
echo "<td>Account No. </td><tr>";

$name = $_POST['name'];
$query = "SELECT report1.id, month, start_date, end_date, user.name, report1.staff_no, details, amount, gl_code, user.bank, user.acc_no FROM user, report1 WHERE report1.staff_no = '$name'";
$result = mysql_query($query, $dblink);
while($myrow = mysql_fetch_array($result)) {
echo "<tr><td>" . $myrow[0] . "</td>";
  	echo "<td>" . $myrow[1] . "</td>";
  	echo "<td>" . $myrow[2] . "</td>";
  	echo "<td>" . $myrow[3] . "</td>";
  	echo "<td>" . $myrow[4] . "</td>";
   	echo "<td>" . $myrow[5] . "</td>";
   	echo "<td>" . $myrow[6] . "</td>";
   	echo "<td>" . $myrow[7] . "</td>";
echo "<td>" . $myrow[8] . "</td>";
echo "<td>" . $myrow[9] . "</td>";
echo "<td>" . $myrow[10] . "</td></tr>";
}
echo "</table>";

?>

Link to comment
Share on other sites

<html>
<head>
<script src="selectuser.js"></script>
</head>
<body>
<form id="form1" name="form1" method="post" action="checking.php">
  <p><strong>KEV Claim</strong></p>
  <table width="497" border="0">
    <tr>
      <td width="284">Claim</td>
      <td width="203"><select name="name" id="name" onChange="showUser(this.value)">

<?php

$host     = 'localhost';
$user     = 'root';
$password = 'admin';
$dbase    = 'claim';

$dblink = mysql_connect($host, $user, $password);

mysql_select_db($dbase, $dblink);

$query = "SELECT staff_no, name FROM user ORDER BY name";
      		
$result = mysql_query($query);

while($myrow = mysql_fetch_row($result)) {

echo "<option value=\"" . $myrow[0] . "\">" . $myrow[1]."</option>";
}

?>
        </select></td>
    </tr>
  </table>
  <p> </p>
  <p>
    <input type="submit" name="Submit" value="Submit">
  </p>
</form>
</body>
</html>

 

<?php

$host     = 'localhost';
$user     = 'root';
$password = 'admin';
$dbase    = 'claim';

$dblink = mysql_connect($host, $user, $password);

mysql_select_db($dbase, $dblink);

echo "<table border=3 align=center width=90%>";
echo "<tr><td>ID</td>";
echo "<td>Month</td>";
echo "<td>Start Date </td>";
echo "<td>End Date</td>";
echo "<td>Name</td>";
echo "<td>Staff No</td>";
echo "<td>Details</td>";
echo "<td>Amount</td>";
echo "<td>GL code</td>";
echo "<td>Bank </td>";
echo "<td>Account No. </td><tr>";

$name = $_POST['name'];

$query = "SELECT report1.id, month, start_date, end_date, user.name, report1.staff_no, details, amount, gl_code, user.bank, user.acc_no FROM user, report1 WHERE report1.staff_no = '$name'";

$result = mysql_query($query, $dblink);

while($myrow = mysql_fetch_array($result)) {
echo "<tr><td>" . $myrow . "</td>";
  	echo "<td>" . $myrow . "</td>";
  	echo "<td>" . $myrow . "</td>";
  	echo "<td>" . $myrow . "</td>";
  	echo "<td>" . $myrow . "</td>";
   	echo "<td>" . $myrow . "</td>";
   	echo "<td>" . $myrow . "</td>";
   	echo "<td>" . $myrow . "</td>";
echo "<td>" . $myrow . "</td>";
echo "<td>" . $myrow . "</td>";
echo "<td>" . $myrow . "</td></tr>";
}

echo "</table>";

?>

Link to comment
Share on other sites

but that haven't solve my problem. i need to output the user that have the same staff no not all the user.

i wrote

 

SELECT report1.id, month, start_date, end_date, user.name, report1.staff_no, details, amount, gl_code, user.bank, user.acc_no FROM user, report1 WHERE report1.staff_no = '$name'

 

 

but it output all the staff.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.