help with a t string error

t sting error i'm missing some thing

Page 1 of 1

3 Replies - 868 Views - Last Post: 05 August 2008 - 09:23 PM Rate Topic: -----

#1 stuartru34   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-July 08

help with a t string error

Post icon  Posted 05 August 2008 - 08:31 PM

hi again
I'm trying to create a simple login I've just bought a book on php/ mysql
copied a code from it to make the login then I get a t string error please can someone help me sort it out

this is the error


Parse error: syntax error, unexpected T_STRING in /hsphere/local/home/revolotion/revolotionarysounds.com/login.php on line 3

this is the Code

<?php
//check for required fields from form
[b]if ((!isset($_POST["username"]))  (!isset($_POST["password"])))[/b] {
	header("Location: staffroom.php");
	exit;
}

//connect to server and select database
$msyql= mysql_connect("mysql.worria.com", "Revolot_login", "freddy78", "Revolot_login",);

//create and issue the query
$query = "SELECT FROM login WHERE
		username ='".$_POST["username"]."' AND
		password = PASSWORD('".$_POST["password"]."')";
&result = mysql_query($query,) or die(mysql_error($mysql));

//get the number of rows in the result set; should be 1 if a match
if (mysql_num_rows($result) ==1) {

   //if authorised, get the values of username
   while ($info = mysql_fetch_array(&result)) {
		 $usename = stripslashes($info['username']);
	}
	
	//set authorization cookie
	setcookie("login", "1",0, "/", "revolotionarysounds.com",0);
	
	//create display string
	$display_block = "
	<p>".$username." ".$username." is live on air!</p>
	<u1>
	<li<a href=\"index.php\">Log Out</a></li>
	</u1>";
} else {
	//redirect back to login form if not authorized
	header("location: login.php");
	exit;
}
?>


Is This A Good Question/Topic? 0
  • +

Replies To: help with a t string error

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6696
  • View blog
  • Posts: 31,046
  • Joined: 10-May 07

Re: help with a t string error

Posted 05 August 2008 - 08:50 PM

I could code it like this, because then I can handle if they didn't post the user name or the password. When you check for the error, you know which one it is.

<?php
//check for required fields from form
$err=0;
if(!isset($_POST["username"])) {
  $err=1;
}
isset($_POST["password"])) {
  $err=2;
}

if($err!=0) {
	header("Location: staffroom.php");
	exit;
}
?>



But to answer your question, I'm not sure if you can squeeze two isset() return values into one if statement using the OR operator.
Was This Post Helpful? 0
  • +
  • -

#3 stuartru34   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 29-July 08

Re: help with a t string error

Posted 05 August 2008 - 09:18 PM

View Postno2pencil, on 5 Aug, 2008 - 08:50 PM, said:

I could code it like this, because then I can handle if they didn't post the user name or the password. When you check for the error, you know which one it is.

<?php
//check for required fields from form
$err=0;
if(!isset($_POST["username"])) {
  $err=1;
}
isset($_POST["password"])) {
  $err=2;
}

if($err!=0) {
	header("Location: staffroom.php");
	exit;
}
?>



But to answer your question, I'm not sure if you can squeeze two isset() return values into one if statement using the OR operator.


Sorry matey but that one did not work it kept moving th errors have you got any other ways i can try this sorry thanks for helping i much appreicate it

stuart russell
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6696
  • View blog
  • Posts: 31,046
  • Joined: 10-May 07

Re: help with a t string error

Posted 05 August 2008 - 09:23 PM

If this code works, then the error is in your header field, or within the php file you are loading (staffroom.php).
<?php
//check for required fields from form
$err=0;
if(!isset($_POST["username"])) {
  $err=1;
}
if(!isset($_POST["password"])) {
  $err=2;
}

if($err!=0) {
	if($err==1) echo "The user name was not set<br>";
	if($err==2) echo "The password was not set<br>";
}
?>


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1