473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Why getting parse error in PHP at line 20?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $username="root";
  3. $password="";
  4. $database="lko_phone";
  5. $host="localhost";
  6. $msg="";
  7. mysql_connect($host,$username,$password);
  8. @mysql_select_db($database);
  9.  
  10. if($_SERVER["REQUEST_METHOD"] == "POST")
  11. {
  12.   $myusername=$_POST['unm'];
  13.   $mypassword=$_POST['pwd'];
  14.  
  15.   $sql="SELECT * FROM login WHERE id='$myusername' and pwd='$mypassword'";
  16.   $result=mysql_query($sql);
  17.   $row = mysql_fetch_assoc($result)
  18.  
  19.   // Mysql_num_row is counting table row
  20.   $num = mysql_num_rows($result);
  21.  
  22.   // If result matched $myusername and $mypassword, table row must be 1 row
  23.  
  24.   if($count==1)
  25.   {
  26.  
  27.     session_start();
  28.  
  29.     $_SESSION['UID'] = $row['id'];
  30.     $_SESSION['PWD'] = $row['pwd'];
  31.     $_SESSION['RGT'] = $row['access'];
  32.  
  33.     header("location:Welcome.php");
  34.   }
  35.   else
  36.   {
  37.     msg="Wrong user name and/or Password"
  38.   }
  39.  
  40. }
  41.  
  42. mysql_free_result($result);
  43.  
  44. ?>
  45.  
  46. <html>
  47. <body background="Images/Back15.jpg" text='black'>
  48. <center>
  49. <table width=100% border=0>
  50. <tr>
  51.    <td align=center><img src="Images/Logo.JPG"></td>
  52.    <td><font face="courier new" size="5" color="orange"><strong>Welcome To: LII - ESS maintenance</strong></font>
  53.    <br><font face="courier new" size="2" color="yellow">Employee-System-Software Maintenance</font></td>
  54. </tr>
  55. </table>
  56. </center>
  57.  
  58. <form action="index.php" method=POST>
  59. <center>
  60. <table width="200" cellpadding="0" cellspacing="0" border="0">
  61. <tr>
  62.   <td width="14"><img src="TableImage/TL.png" width=14 height=23 border="0" /></td>
  63.  
  64.   <td background="Images/Back1.jpg" colspan="2" align="center">
  65.     <font face='arial' size='4' color='maroon'><strong>
  66.     Enter Login Information
  67.     </font>
  68.   </td>
  69.  
  70. <td width="14"><img src="TableImage/TR.png" width=14 height=23 border="0" /></td>
  71.  
  72. </tr>
  73.  
  74. <tr>
  75.  
  76. <td background="Images/Back1.jpg">&nbsp</td>
  77. <td background="Images/Back1.jpg">&nbsp</td>
  78. <td background="Images/Back1.jpg">&nbsp</td>
  79. <td background="Images/Back1.jpg">&nbsp</td>
  80.  
  81. </tr>
  82.  
  83. <tr>
  84.  
  85. <td background="Images/Back1.jpg"></td>
  86.  
  87. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='4'>Username:</font></td>
  88. <td background="Images/Back1.jpg"><input type='text' name='unm'/></td>
  89.  
  90. <td background="Images/Back1.jpg"></td>
  91.  
  92. </tr>
  93.  
  94. <tr>
  95.  
  96. <td background="Images/Back1.jpg"></td>
  97.  
  98. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='4'>Password:</font></td>
  99. <td background="Images/Back1.jpg"><input type='password' name='pwd'></td>
  100.  
  101. <td background="Images/Back1.jpg"></td>
  102.  
  103. </tr>
  104.  
  105. <tr>
  106.  
  107. <td background="Images/Back1.jpg">&nbsp</td>
  108. <td background="Images/Back1.jpg">&nbsp</td>
  109. <td background="Images/Back1.jpg">&nbsp</td>
  110. <td background="Images/Back1.jpg">&nbsp</td>
  111.  
  112. </tr>
  113.  
  114. <tr>
  115.  
  116. <td background="Images/Back1.jpg">&nbsp</td>
  117.  
  118. <td background="Images/Back1.jpg" align="center" colspan="2"><input type='submit' name='log' value='  login  '></td>
  119.  
  120. <td background="Images/Back1.jpg">&nbsp</td>
  121.  
  122. </tr>
  123.  
  124. <tr>
  125.  
  126. <td><img src="TableImage/BL.png" width=14 height=23 border="0" /></td>
  127. <td background="Images/Back1.jpg">&nbsp</td>
  128. <td background="Images/Back1.jpg">&nbsp</td>
  129. <td><img src="TableImage/BR.png" width=14 height=23 border="0" /></td>
  130.  
  131. </tr>
  132. </table>
  133. </center>
  134. <p align=Center><?php echo $msg ?></p>
  135. </form>
  136. </body>
  137. </html>
  138.  
Sep 14 '10 #1
12 1894
vjayis
134 100+
semicolon missing in line 17.,

try applying it.

Expand|Select|Wrap|Line Numbers
  1.  $row = mysql_fetch_assoc($result);
  2.  
Sep 14 '10 #2
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $username="root";
  3. $password="";
  4. $database="lko_phone";
  5. $host="localhost";
  6. $msg="";
  7. mysql_connect($host,$username,$password);
  8. @mysql_select_db($database);
  9.  
  10. if($_POST)
  11. {
  12.   $myusername=$_POST['unm'];
  13.   $mypassword=$_POST['pwd'];
  14.  
  15.   $sql="SELECT * FROM login WHERE id='$myusername' and pwd='$mypassword'";
  16.   $result=mysql_query($sql);
  17.   $row = mysql_fetch_assoc($result);
  18.  
  19.   // Mysql_num_row is counting table row
  20.   $num = mysql_num_rows($result);
  21.  
  22.   echo $num;
  23.   // If result matched $myusername and $mypassword, table row must be 1 row
  24.  
  25.   if($num==1)
  26.   {
  27.  
  28.     session_start();
  29.  
  30.     $_SESSION['UID'] = $row['id'];
  31.     $_SESSION['PWD'] = $row['pwd'];
  32.     $_SESSION['RGT'] = $row['access'];
  33.  
  34.     header("location:Welcome.php");
  35.   }
  36.   else
  37.   {
  38.     msg="Wrong user name and/or Password";
  39.   }
  40.  
  41. }
  42.  
  43. mysql_free_result($result);
  44.  
  45. ?>
  46.  
  47. <html>
  48. <body background="Images/Back15.jpg" text='black'>
  49. <center>
  50. <table width=100% border=0>
  51. <tr>
  52.    <td align=center><img src="Images/Logo.JPG"></td>
  53.    <td><font face="courier new" size="5" color="orange"><strong>Welcome To: LII - ESS maintenance</strong></font>
  54.    <br><font face="courier new" size="2" color="yellow">Employee-System-Software Maintenance</font></td>
  55. </tr>
  56. </table>
  57. </center>
  58.  
  59. <form action="index.php" method=POST>
  60. <center>
  61. <table width="200" cellpadding="0" cellspacing="0" border="0">
  62. <tr>
  63.   <td width="14"><img src="TableImage/TL.png" width=14 height=23 border="0" /></td>
  64.  
  65.   <td background="Images/Back1.jpg" colspan="2" align="center">
  66.     <font face='arial' size='4' color='maroon'><strong>
  67.     Enter Login Information
  68.     </font>
  69.   </td>
  70.  
  71. <td width="14"><img src="TableImage/TR.png" width=14 height=23 border="0" /></td>
  72.  
  73. </tr>
  74.  
  75. <tr>
  76.  
  77. <td background="Images/Back1.jpg">&nbsp</td>
  78. <td background="Images/Back1.jpg">&nbsp</td>
  79. <td background="Images/Back1.jpg">&nbsp</td>
  80. <td background="Images/Back1.jpg">&nbsp</td>
  81.  
  82. </tr>
  83.  
  84. <tr>
  85.  
  86. <td background="Images/Back1.jpg"></td>
  87.  
  88. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='4'>Username:</font></td>
  89. <td background="Images/Back1.jpg"><input type='text' name='unm'/></td>
  90.  
  91. <td background="Images/Back1.jpg"></td>
  92.  
  93. </tr>
  94.  
  95. <tr>
  96.  
  97. <td background="Images/Back1.jpg"></td>
  98.  
  99. <td background="Images/Back1.jpg" align="right"><font face='verdana' size='4'>Password:</font></td>
  100. <td background="Images/Back1.jpg"><input type='password' name='pwd'></td>
  101.  
  102. <td background="Images/Back1.jpg"></td>
  103.  
  104. </tr>
  105.  
  106. <tr>
  107.  
  108. <td background="Images/Back1.jpg">&nbsp</td>
  109. <td background="Images/Back1.jpg">&nbsp</td>
  110. <td background="Images/Back1.jpg">&nbsp</td>
  111. <td background="Images/Back1.jpg">&nbsp</td>
  112.  
  113. </tr>
  114.  
  115. <tr>
  116.  
  117. <td background="Images/Back1.jpg">&nbsp</td>
  118.  
  119. <td background="Images/Back1.jpg" align="center" colspan="2"><input type='submit' name='log' value='  login  '></td>
  120.  
  121. <td background="Images/Back1.jpg">&nbsp</td>
  122.  
  123. </tr>
  124.  
  125. <tr>
  126.  
  127. <td><img src="TableImage/BL.png" width=14 height=23 border="0" /></td>
  128. <td background="Images/Back1.jpg">&nbsp</td>
  129. <td background="Images/Back1.jpg">&nbsp</td>
  130. <td><img src="TableImage/BR.png" width=14 height=23 border="0" /></td>
  131.  
  132. </tr>
  133. </table>
  134. </center>
  135. <p align=Center><?php echo $msg ?></p>
  136. </form>
  137. </body>
  138. </html>
  139.  
Sep 14 '10 #3
SOlved it. wrote msg="...." instead of $msg="..."
Thanks....
Sep 14 '10 #4
vjayis
134 100+
yeah., u missed '$' symbol there .,

thanks
Sep 14 '10 #5
Thanks to you too for paying kind attention. will come back if got stuck anywhere.
Sep 16 '10 #6
mysql_fetch_assoc() expects parameter 1 to be resource at line 58... Please help
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. if($_SESSION['UID'])
  4.   {
  5.    if($_SESSION['RGT'] == "R")
  6.       header("location:NoAccess.php");
  7.   }
  8. else
  9.       header("location:NoAccess.php");
  10. $message="";
  11. $username="root";
  12. $password="";
  13. $database="lko_phone";
  14. $host="localhost";
  15. mysql_connect($host,$username,$password);
  16. @mysql_select_db($database);
  17. ?>
  18. <html>
  19. <head>
  20.     <title>Delete Employee Record</title>
  21. </head>
  22. <body background="Images/Back5.jpg" text="white" link="white" alink="white" vlink="white">
  23. <center>
  24. <table background="Images/Back10.jpg" width="100%" border="0">
  25. <tr>
  26.    <td><img src="Images/Logo.JPG"></td>
  27.    <td  align=center><font face="courier new" size="5" color="orange"><strong>Welcome To: LKO - TelWin</strong></font>
  28.    <br><font face="courier new" size="2" color="yellow">Online Telephone Address Book/Call-Register Maintenance</font></td>
  29.    <td align=right>
  30.     <?php
  31.       $welcome=$_SESSION['UID'];
  32.       if(strcmp($welcome,"mbchaudhuri")==0)
  33.       {
  34.        $query = sprintf("SELECT * FROM notes");
  35.        $result=mysql_query($query);
  36.        $num=mysql_num_rows($result);
  37.        $message=sprintf("<font face=verdana color=aqua size=2>You have :<strong>".$num." Notes to see</strong></font><br>");
  38.       }
  39.       else
  40.        $message="";
  41.       echo "<font face=verdana size=2 color=yellow>Welcome: ".$welcome."<br>";
  42.       echo "<font face=verdana color=orange size=2>Today is :<strong>".date("d-M-Y, l")."</strong></font><br>";
  43.       echo $message;
  44.       echo "<a href=Logout.php>Logout</a>";
  45. ?>
  46. </table>
  47. </center>
  48. <form action=SearchEmployee.php>
  49. <h2>Deleted the following employee record..<?php echo $_POST['esrl']?></h2>
  50. <?php
  51.   if($_POST && !empty($_POST['Delete']))
  52.   {
  53.     $r=$_POST['esrl'];
  54.     $query=sprintf("select * from employee where srl = $r");
  55.     echo $query;
  56.     $result=mysql_query($query);
  57.  
  58.     while($row = mysql_fetch_assoc($result))
  59.     {
  60.     echo "<br><strong>Employee Name:".$row['ename'];
  61.     echo "<br>Designation  :".$row['desig'];
  62.     echo "<br>Department   :".$row['dept'];
  63.     echo "<br>Direct No    :".$row['d_no'];
  64.     echo "<br>Extension    :".$row['extn'];
  65.     echo "<br>Mobile No    :".$row['mobile'];
  66.     echo "<br>Residential  :".$row['res_no'];
  67.     echo "<br>Other Contact:".$row['other_no'];
  68.     echo "</strong>";
  69.     }
  70.     echo mysql_error();
  71.     echo "<br><br><input type=submit value='Back to search page' >";
  72.     mysql_query("delete from emloyee where srl=$r");
  73.   }
  74.  
  75. ?>
  76. </form>
  77. </body>
  78. </html>
  79.  
Sep 20 '10 #7
Yep.. solved the problem. I changed the code as follows:
Expand|Select|Wrap|Line Numbers
  1. $query="select * from employee where srl ='". $r."'";
  2. $result=mysql_query($query);
  3. while($row = mysql_fetch_assoc($result))
  4.     {
  5.     echo "<br><strong>Employee Name:".$row['ename'];
  6.     echo "<br>Designation  :".$row['desig'];
  7.     echo "<br>Department   :".$row['dept'];
  8.     echo "<br>Direct No    :".$row['d_no'];
  9.     echo "<br>Extension    :".$row['extn'];
  10.     echo "<br>Mobile No    :".$row['mobile'];
  11.     echo "<br>Residential  :".$row['res_no'];
  12.     echo "<br>Other Contact:".$row['other_no'];
  13.     echo "</strong>";
  14.     }
  15. $query="delete from employee where srl ='". $r."'";
  16.     mysql_query($query);
  17.  
Now working perfectly. I do not why it is taking string value, but, in table it srl is defined as integer.
Sep 21 '10 #9
Dormilich
8,658 Expert Mod 8TB
you pass srl as a string. (omit the ')
Sep 21 '10 #10
I just want to display three columns in one row. But, when value of $i is 1 or 4, the statements under if is firing. Dont know why it is happening, and how to solve it.
Expand|Select|Wrap|Line Numbers
  1. $i=0;
  2.    while ($row = mysql_fetch_assoc($result))
  3.    {
  4.     if(($i%3)==0)
  5.     {
  6.       echo "<tr>";
  7.       echo "<td><input type=radio name=JobNo value=".$row['job_no']." />"</td>";
  8.       echo "<td><font face=verdana size=2>".$row['job_no']."</font></td>";
  9.       echo "</tr>";
  10.     }
  11.     else
  12.     {
  13.       echo "<td><input type=radio name=JobNo value=".$row['job_no']." />"</td>";
  14.       echo "<td><font face=verdana size=2>".$row['job_no']."</font></td>";
  15.     }
  16.  
  17.     $i=$i+1;
  18.    }
  19.  
Sep 22 '10 #11
OK got it.... <tr> and </tr> is firing for only one column...... Sorry for the sily question.
Sep 22 '10 #12
This code removed the problem....
Expand|Select|Wrap|Line Numbers
  1. <center><table border="1" bordercolor="orange">
  2.   <tr>
  3.     <td bgcolor="black">&nbsp</td>
  4.     <td bgcolor="black"><font color="orange" face="verdana" size="2"><b>Job Number</b></font></td>
  5.     <td bgcolor="black">&nbsp</td>
  6.     <td bgcolor="black"><font color="orange" face="verdana" size="2"><b>Job Number</b></font></td>
  7.     <td bgcolor="black">&nbsp</td>
  8.     <td bgcolor="black"><font color="orange" face="verdana" size="2"><b>Job Number</b></font></td>
  9. <?php
  10.   $query = sprintf("SELECT * FROM job order by job_no");
  11.   $result=mysql_query($query);
  12.   $i=3;
  13.  
  14.    while ($row = mysql_fetch_assoc($result))
  15.    {
  16.     if(($i%3)==0) echo "</tr><tr>";
  17.  
  18.       echo "<td><input type=radio name=JobNo value=".$row['job_no']." />->".($i%3)."</td>";
  19.       echo "<td><font face=verdana size=2>".$row['job_no']."</font></td>";
  20.  
  21.     $i=$i+1;
  22.    }
  23.   mysql_free_result($result);
  24.   echo "</tr>";
  25. ?>
  26. </table>
  27.  
Sep 22 '10 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dave | last post by:
Hi, I know i shouldn't work on php forms when i'm going on 30 hours of no sleep, but i did anyway. I'm trying to get the below to work, and i keep getting a parse error line 74, an unexpected ','...
2
by: Salim | last post by:
Hi people, keep getting this errorParse error: parse error, unexpected T_STRING in order_fns.php line 91. the code is below for the file and I've indicated line 91 <?php function...
2
by: urmyfriend | last post by:
Hi, I am getting the parse error while i try to execute a simple sql query in postgres. java.sql.SQLException: ERROR: parser: parse error at or near "and" at character 58 The Query has...
4
kestrel
by: kestrel | last post by:
I have some html code that is supposed to be displayed by php echo. But for some reason i keep getting a syntax error, and i cant figure out what is going on. Heres what i have <?php...
2
by: DavidPr | last post by:
I'm getting - parse error, unexpected T_LNUMBER - error messages referring to the last "if" lines of this code. What I'm trying to do is check the database and if this user's article row isn't...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
0
by: JRough | last post by:
On Sep 26, 3:23 pm, Captain Paralytic <paul_laut...@yahoo.comwrote: without the exit I get this again: Warning: Cannot modify header information - headers already sent by (output started at...
15
by: micky125 | last post by:
Lo all, Ive been getting the error message Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/moneill/public_html/input.html...
45
by: angelicdevil | last post by:
i have 2 tables 1 is status_type with field name status and other is users with field username and status now i want that the first listbox lists all status from status type ( this i have achieved...
6
by: angelicdevil | last post by:
i m trying to display a message based on code status against the code in the database for on the code entered. however it gives me a parse error <?php require_once("includes/functions.php"); ?>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.