I'm using 000webhost to run my code and phpmyadmin for my database. I'm trying to make it so when I seach a name it will give me the name and password under that name in the database.
This is the error:
Parse error: syntax error, unexpected '>' in /storage/h11/920/1783920/public_html/search.php on line 51
This is my html:
<!DOCTYPE html>
<html>
<head>
<title>Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<form action="search.php" method="GET">
<input type="text" name="query" />
<input type="submit" value="Search" />
</form>
</body>
</html>
and this is my php:
<?php
mysql_connect("localhost", "id1783920_123456", "") or die("Error connecting to database: ".mysql_error());
/* The Third "" is the password spot and I don't want to put it. It's not the problem*/
// LINE 10
mysql_select_db("id1783920_mydb") or die(mysql_error());
?>
<!DOCTYPE html>
<html>
<head>
<title>Search results</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
$query = $_GET['query'];
$min_length = 1;
// LINE 30
if(strlen($query) >= $min_length){ // if query length is more or equal minimum length then
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
// makes sure nobody uses SQL injection
$raw_results = mysql_query("SELECT * FROM Signup
WHERE (`username`='$query') OR (`password`='$query') or die(mysql_error());
// LINE 45
if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following
while($results = mysql_fetch_array($raw_results)){
echo "<p><h3>".$results['username']."</h3>".$results['password']."</p>";
}
}
else{ // if there is no matching rows do following
echo "No results";
}
}
else{ // if query length is less than minimum
echo "Minimum length is ".$min_length;
}
?>
</body>
</html>
Any help would be greatly appreceated. Thanks
(Another error showed up: Fatal error: Uncaught Error: Call to undefined function mysql_query() in /storage/h11/920/1783920/public_html/search.php:37 Stack trace: #0 {main} thrown in /storage/h11/920/1783920/public_html/search.php on line 37