My simple PHP is outputting wrong things
EDIT: I forgot to add semi colons. Now there is another problems. I'm getting a error:
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\useraccess.php on line 12
It outputs:
0){ echo 'si'; } ?>
When it should only output 'si' in the body.
Here's the code:
<html>
<head>
</head>
<body&开发者_如何学Gogt;
<?
$user = mysql_real_escape_string($_GET["u"])
$pass = mysql_real_escape_string($_GET["p"])
$query = "SELECT * FROM usario WHERE username = '$user' AND password = '$pass'"
mysql_connect(localhost, "sergio", "123");
@mysql_select_db("multas") or die( "Unable to select database");
$result=mysql_query($query);
if(mysql_numrows($result) > 0){
echo 'si';
}
?>
</body>
</html>
That is because you are using short php tags <?
that most likely are not enabled in php.ini. Try using <?php
or enable short tags from php.ini but this is not recommended.
Also note that you are missing semi-colon (;
) fot these lines:
$user = mysql_real_escape_string($_GET["u"])
$pass = mysql_real_escape_string($_GET["p"])
$query = "SELECT * FROM usario WHERE username = '$user' AND password = '$pass'"
Regarding the "Unexpected T String" error:
The mysql connect statement should read:
mysql_connect('localhost', 'sergio', '123');
You need semicolons on your $user, $pass, and $query variables.
Missing semi-colon after
$query = "SELECT * FROM usario WHERE username = '$user' AND password = '$pass'"
Stick quotes around 'localhost'
精彩评论