-5

(1) first file is fill.php and i am using a second file search.php, i pass parameters from fill.php to search.php , but i am getting an error i am getting unexpected t_variable error in line 16 in search.php

fill.php

<?php
?>
<html>
<body>
<form action="search.php" method="post">

   <table style="color:purple;border-style:groove; height:150px;width:350px" >
            <tr>
                <td style=" height:25px; font-family:'Copperplate Gothic 
Bold'">&nbsp;</td>
            </tr>
            <tr>
                <td style="color:red;background-color:aqua;height:25px">Enter Employee id&nbsp;&nbsp;&nbsp;&nbsp;
                    <input name="name" id="name" type="text"/></td>
            </tr>
            <tr>
                <td style="height:25px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="submit" value="Submit" style="color:white;background-color:brown; height:30px" /></td>
            </tr>
        </table>
</form>
</body>
</html>

Search.php

 <?php
        $con = mysql_connect("localhost","root","");
        if (!$con)
         {
          die('Could not connect: ' . mysql_error());
          }
          mysql_select_db("ravi", $con);
          $con = mysql_connect("localhost","root","");
          if (!$con)
           {
              die('Could not connect: ' . mysql_error());
           }
           mysql_select_db("mysql", $con);
           $name = (int)$_post['name']
           $sql = "SELECT * from empmast where empid= $name";
           $result = mysql_query($sql);
           if (!$result)
            {
               die("Error running $sql: " . mysql_error());
             }
            while($rowval = mysql_fetch_array($result))
                {
                   $empid= $rowval['empid'];
                   $empname= $rowval['empname'];
                 }
                 mysql_close($con);

         ?>
Mureinik
  • 297,002
  • 52
  • 306
  • 350
ravi
  • 3
  • 1
  • 1

1 Answers1

0

In your search.php file, you are missing a ; semicolon on line 15.

$name = (int)$_POST['name']

should be

$name = (int)$_POST['name'];

You should also stop using mysql_. Here's why.

Use mysqli_ or PDO.

Community
  • 1
  • 1
Edward
  • 2,291
  • 2
  • 19
  • 33
  • @ravi This is the correct answer. But you should learn about debugging before just posting on stack. This is a very simple error to debug. Do you use an IDE to write your scripts? I suggest PHP Storm or Komodo. – Edward May 06 '17 at 18:01
  • 2
    @Edward Nice name :). Agreed. I use Sublime Text with SublimeLinter with SublimeLinter-php. You could also use PHP Storm. – Edward May 06 '17 at 18:04
  • 1
    :) i hope @ravi is taking notes... – Edward May 06 '17 at 18:11