473,407 Members | 2,676 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,407 software developers and data experts.

I've got a "Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\php\vali"

hi im new to php and i want to code a admin login page where i want to match the values from the login form with the values of the database table.....when i run the login page after entering the user name and the password i've got a Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\php\validate.php on line 16. Can anybody please help me to slove this matter.

validate.php
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start();
  3. $username= $_POST['adminusername'];
  4. $password= $_POST['adminpass'];
  5.  
  6. $conn= mysql_connect('localhost','root','');
  7. mysql_select_db('onlinestore',$conn);
  8.  
  9. $query='SELECT * FROM admin WHERE adminusername='$username' and adminpassword='$password'';
  10. $result=mysql_query($query);
  11. if(mysql_num_rows($result)==1)
  12. {
  13. header("location:menu.php");
  14. exit();
  15. }
  16. header("location:adminlogin.php");
  17. exit();
  18. ?>
  19. </body>
Jun 3 '10 #1
5 2840
Dormilich
8,658 Expert Mod 8TB
wrap your query in double quotes. single quoted strings are not parsed and in your case cause the error.
Jun 3 '10 #2
Hey thanks but when i wrap it with double quotes it should go to the menu.php when giving correct username & password right???? but it act as an incorrect input........can u help me???
Jun 3 '10 #3
Dormilich
8,658 Expert Mod 8TB
what does the corrected code look like?
Jun 3 '10 #4
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  
  3. $username= $_POST['adminusername'];
  4. $password= $_POST['adminpass'];
  5.  
  6. $conn= mysql_connect('localhost','root','');
  7. mysql_select_db('onlinestore',$conn);
  8.  
  9. $query="SELECT * FROM `admin` WHERE adminusername='$username' and adminpassword='$adminpass';
  10. $result=mysql_query($query);
  11. if(mysql_num_rows($result)==1)
  12. {
  13. header("location:menu.php");
  14. exit();
  15. }
  16. header("location:adminlogin.php");
  17. exit();
  18. ?>
now it says "Parse error: syntax error, unexpected T_STRING in C:\wamp\www\php\validate.php on line 20"
which is ,header("location:menu.php");
Jun 3 '10 #5
Dormilich
8,658 Expert Mod 8TB
if you open a string, you should also close it (i.e. missing closing string delimiter).
Jun 3 '10 #6

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

Similar topics

8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
36
by: rhys | last post by:
My Gurus and Angels -- Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My...
3
by: SilvaZodiac | last post by:
Hi everyone, I'm still rather new to PHP code, and I have a syntax error. I've tried several different solutions, but it won't fix. It seems to suggest that I need a new bracket somewhere in the...
3
paulrajj
by: paulrajj | last post by:
hi to all, i am getting syntax error on my code.. Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in D:\xampp\htdocs\Dummy\paulraj\matrim\exam.php on line 62 ...
10
by: benicio | last post by:
Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\wamp\www\study_group\includes\functions.php on line 19 I got this error and this syntax is from 8 to 19th line. <?php ...
5
maxamis4
by: maxamis4 | last post by:
Hello folks, Learning PHP here and I am using sendmail.php to send an email. I have setup my html contact form and I am using the following to send an email once a confirmation has been made: ...
3
by: brkseven | last post by:
Looking for help with this Contact Form. The error is on line 1, but that' doesn't mean a lot, I think. In fact, a php syntax check passed it, but I was hoping for an easy syntax error, it looks...
3
by: CYNTHIA CUTRER | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> ...
5
by: vultren | last post by:
Parse error: syntax error, unexpected $end in I keep getting that, I have no clue where to fix it. Any help would be VERY APPRECIATED! <?php if(isset($_POST)) { // EDIT THE 2 LINES...
2
by: Vicki Hendra | last post by:
Hi I am new to php fullstop I and colleagues have setup wordpress blogs for our local towns, giving the local businesses free advertisment. Part of the problem started when using wordpress...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.