2 Replies - 230 Views - Last Post: 19 October 2017 - 04:05 AM Rate Topic: -----

#1 sadaiyappan_  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 04-October 17

another php question

Posted 19 October 2017 - 03:47 AM

It gives this error: ( ! ) Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\wamp64\www\sample\process.php on line 15

<?php
	$username = $POST['username'];
	$password = $POST['password'];

	$username = stripcslashes($username);
	$password = stripcslashes($password);
	$username = mysql_real_escape_string($username);
	$password = mysql_real_escape_string($password);

	mysql_connect("localhost", "root", "");
	mysql_select_db("test");

	$result = mysql_query("select * from stuff where name = '$username' and password = '$password'") or die("Failed to query database " .mysql_error());
	$row = mysql_fetch_array($result);
	if (($row['name']== $username) && ($row['password'] == $password)){echo "Login success!! Welcome ".$row['username']} else {echo "Failed login!";}
?>


Is This A Good Question/Topic? 0
  • +

Replies To: another php question

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4136
  • View blog
  • Posts: 13,051
  • Joined: 08-June 10

Re: another php question

Posted 19 October 2017 - 03:49 AM

you're missing a ;
Was This Post Helpful? 1
  • +
  • -

#3 andrewsw  Icon User is offline

  • the case is sol-ved
  • member icon

Reputation: 6375
  • View blog
  • Posts: 25,756
  • Joined: 12-December 12

Re: another php question

Posted 19 October 2017 - 04:05 AM

It will be easier to see the missing semi-colon if you don't bunch your code up onto a single line.

(BTW please use a more informative title in future than "another php question".)



The mysql extension library has been deprecated for a long time and should not be used; it is no longer present in PHP 7. See the links in my signature below (or Dormilich's links).

Also use prepared statements.

It is also redundant to retrieve the username and password from the database when you have a where clause that confirms the existence of the combination.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1