Code help

Support, Snippets & Projects

Moderators: Moderator, Global Moderator

Post Reply
Wayne
Sr. Member
Sr. Member
Posts: 362
Joined: Wed Jun 16, 2004 5:37 pm

Code help

Post by Wayne »

Code: Select all

  // if ok, put in db
$result = $conn->query(
"insert into user values
	('$username', sha1('$password'), '$email')");
  if (!$result)
{
    echo 'Could not register you in database - please try again later.';
}
  return true;
}

function login($username, $password)
// check username and password with db
// if yes, return true
// else throw exception
{
  // connect to db
  $conn = db_connect();

  // check if username is unique
  $result = $conn->query("select * from user
	where username='$username'
	and passwd = sha1('$password')");
  if (!$result)
     echo "Could not log you in.";

  if ($result->num_rows>0)
     return true;
  else
     echo "Could not log you in.";
}

This is the first part of a code I'm having problems with
its line 24 and 42-44 which is this:

Code: Select all

 
$result = $conn->query(
"insert_into_user_values
	('$username', sha1('$password'), '$email')");


and

Code: Select all

  $result = $conn->query("select * from user
	where username='$username'
	and passwd = sha1('$password')");
I really don't know enough PHP to beable to fix this. I'm sure it can't be anything that drastic, but I don't know much to be able to fix it. The exact error I'm getting is this:
Parse error: parse error, unexpected T_STRING in /home/httpd/vhosts/tkdfc.hopto.org/httpdocs/user_auth_fns.php on line 24

Please help!
Thanks
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 7:54 am

Code help

Post by Josh »

Maybe change those 2 codes to this?:

Code: Select all

$result = $conn->query("insert_into_user_values('$username', sha1('$password'), '$email')");
and

Code: Select all

$result = $conn->query("select * from user where  username='$username' and passwd = sha1('$password')");
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
Wayne
Sr. Member
Sr. Member
Posts: 362
Joined: Wed Jun 16, 2004 5:37 pm

Code help

Post by Wayne »

nope... don't work :'(
Post Reply

Return to “PHP & MySQL”