Code error

Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\dwest(

Page 1 of 1

3 Replies - 1456 Views - Last Post: 03 June 2010 - 03:21 PM Rate Topic: -----

#1 westdot   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-January 10

Code error

Posted 03 June 2010 - 02:43 PM

I continue to get the following error..Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\dwest(2)\Program 3\prog3out.php on line 42.
I have checked my syntax, but have not be able to locate the error. Would someone take a look.

Thank you

<?php
session_start();
ob_start();  // begin buffering the output
?>

<html>
<head>
<title>Maintaining State With Sessions Form 2</title>
<!-- Maintaining State With Sessions Form 2-->
</head>
<body>
<?php
$ebits = ini_get('error_reporting');
error_reporting($ebits ^ E_NOTICE);


$un = $_POST['username'];
$pw = $_POST['password'];
if (session_id() == $_SESSION["sid"]) {
  if ($un=="username" && $pw=="password") 
    {print "Welcome $un, you have successfully made it to form 2";
    $_SESSION["form2error"]= " ";}  
  else
    {$_SESSION["form2error"]= "Invalid Username and/or Password";
    header('location: prog3in.php');}  }
else  {
  $_SESSION["form2error"]= "You Must Login Before You Proceed to Screen2";
  header('location: prog3in.php');}

ob_end_flush(); // output the data in the buffer



$server = 'localhost';
$user = 'root';
$password = '';
// Database definitions
$mydb = 'mydb';
$table_name = 'sign_in'; // Table name 
$SQLcmd = "select * from $table_name where username = $un and password = $pw;"
// Connect to server and select databse.
$connect = mysql_connect(localhost, root, '');
if (!$connect) {
	die ("Cannot connect to the $server using $user");  }

// Select/Connect to the database
mysql_select_db(mydb, $connect);
		
$result = mysql_query($SQLcmd, $connect) or die(mysql_error());	
if ($result){


	while($row = mysql_fetch_array($result)){
Print "You have successfully logged in";
}
}	
mysql_close($connect);
//Using PHP Sessions Ouput Form



?>

<form action="prog3in.php" method="post">
<input type="submit" value="Return to Form 1">

</body>
</html> 




Attached File  prog3out.php (1.62K)
Number of downloads: 83

This post has been edited by JackOfAllTrades: 03 June 2010 - 03:03 PM
Reason for edit:: Fixed code tags.


Is This A Good Question/Topic? 0
  • +

Replies To: Code error

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12332
  • View blog
  • Posts: 45,435
  • Joined: 27-December 08

Re: Code error

Posted 03 June 2010 - 02:56 PM

Please, :code:

What is at line 42?
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Code error

Posted 03 June 2010 - 03:06 PM

$SQLcmd = "select * from $table_name where username = $un and password = $pw;"


your semi-colon is inside the quote there.

If you go to the line number, then go back a line or two, you can usually find these kinds of errors.
Was This Post Helpful? 0
  • +
  • -

#4 westdot   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 29-January 10

Re: Code error

Posted 03 June 2010 - 03:21 PM

Thanks much.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1