Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 12th, 2011, 06:08 AM
Authorized User
 
Join Date: Jul 2011
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default simple php error

hi all,
i am getting error on the following php program.it is displaying the error as "Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\newlogin.php on line 12"
not getting what is the problem with it..
below is my login.php code...
Code:
<?php
if(isset($_POST['sub']))
{
mysql_connect("localhost","root","");
mysql_select_db("test");
$uname=$_POST['txtuname'];
$pwd=$_POST['txtpwd'];
$sqlstt="select * from users where uid='$uname' and pwd='$pwd';
$data=mysql_query($sqlstt);
if(mysql_num_rows($data)==1)
{
header("Location:welcome.php?un=$uname");
}
else
{
echo "invalid";
}
}
?>
<form method="post" action="">
username:<input type='text' name='txtuser'>
<br>
password:<input type='text' name='txtpwd'>
<br>
<input type='submit' name='sub' value='login'>
</form>
also is the welcome.php
Code:
<?php
$user=$_REQUEST['un'];
echo "welcome to ".$user;
?>
 
Old August 26th, 2011, 07:20 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 125
Thanks: 0
Thanked 24 Times in 24 Posts
Default

Greetings,

The error is actually on line 8 as this line:
Code:
$sqlstt="select * from users where uid='$uname' and pwd='$pwd';
should be:
Code:
$sqlstt="select * from users where uid='$uname' and pwd='$pwd'";
You forgot to close the "





Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple PHP question - Obtaining the users IP address ramone_johnny Beginning PHP 6 May 7th, 2009 02:22 PM
upload a simple .php file scrowler Beginning PHP 3 November 15th, 2004 10:54 PM
Error: movie.php & commit.php on p182-186, ch6 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 12th, 2004 02:48 PM
simple apache and php question nulogix PHP How-To 1 July 19th, 2004 09:06 PM
Chapter 15 simple-mailer.php doesn't work Corey Wirun BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 18th, 2003 03:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.