Current location: Hot Scripts Forums » Programming Languages » PHP » PHP Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRIN

PHP Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRIN

Reply
  #1 (permalink)  
Old
Newbie Coder
 
Join Date: Apr 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRIN

Can someone help me with this error

PHP Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

the problem line of code is the following:

$sql="select * from Admin where AdminName='$_POST['username']' and AdminPassword='$_POST['password']'";


what is causing the error?
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
Coding Addict
 
Join Date: Mar 2005
Posts: 263
Thanks: 0
Thanked 0 Times in 0 Posts
$sql="select * from Admin where AdminName='$_POST[username]' and AdminPassword='$_POST[password]' ";
__________________
onPHP5.com - PHP5: Articles, News, Tutorials, Interviews, Software and more
Reply With Quote
  #3 (permalink)  
Old
Newbie Coder
 
Join Date: Apr 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
thanks..
can you help me out with another error (sorry i'm pretty new to php)

$result = @mysql_query($sql);
$num_rows=mysql_num_rows($result);

I get an error

PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

what am I doing wrong?
Reply With Quote
  #4 (permalink)  
Old
wheezy360's Avatar
Newbie Coder
 
Join Date: Nov 2003
Location: Toronto, ON
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
This means that your sql query probably has an error (or there was some other error that occurred when performing the query).


PHP Code:

// Removed the @ warning suppression.  

// If you're in development, you _want_ warnings.  Suppressing them will only cause confusion
$result mysql_query($sql) or die(mysql_error());
$num_rows mysql_num_rows($result); 
Get back to us when you know what the mysql_error() returns.
Reply With Quote
  #5 (permalink)  
Old
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
eugh i hate that error!

PHP Code:

$sql "SELECT * FROM Admin WHERE AdminName='{$_POST['username']}' AND AdminPassword='{$_POST['password']}'";

$result mysql_query($sql);
$num_rows mysql_num_rows($result); 
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #6 (permalink)  
Old
Newbie Coder
 
Join Date: Apr 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
this is strange

when I write out the sql (using echo $sql) it is:

select from Admin where AdminName='abc' and AdminPassword='box1234'


But the error shows: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'from Admin where AdminName='abc' and AdminPassword='box123

seems to be custting teh 4 and end string tag.

what do you think is causing this?
Reply With Quote
  #7 (permalink)  
Old
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
have u tried my code?
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #8 (permalink)  
Old
Newbie Coder
 
Join Date: Apr 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
yes it returned the same error
Reply With Quote
  #9 (permalink)  
Old
wheezy360's Avatar
Newbie Coder
 
Join Date: Nov 2003
Location: Toronto, ON
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
This is because you haven't selected any fields in your SQL statement.

SELECT * FROM Admin .....

as opposed to

SELECT FROM Admin .....
Reply With Quote
  #10 (permalink)  
Old
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
that shouldnt matter, i use select * every time for user authentication :|
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP / Graphic Developers someotherguy582 Job Offers & Assistance 1 06-05-05 07:40 PM
Parse error in php file sahil PHP 1 06-30-04 05:05 AM
PHP script to parse HTML Skeleton Man Script Requests 2 10-05-03 08:41 PM


All times are GMT -5. The time now is 04:43 AM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.