My code handler.php
...
// independent variables
$dbHost = "localhost";
$dbPort = 5432;
$dbName = "masi";
$dbUser = "masi";
$dbPassword = "123456";
$conn = "host=$dbHost port=$dbPort dbname=$dbName user=$dbUser password=$dbPassword";
$dbconn = pg_connect($conn);
$sql = "SELECT username, passhash_md5, email
FROM users$
WHERE username='a' // to get these data from lomake.php
AND email='a'
AND passhash_md5='a'";
$result = pg_query($conn, $sql);
if(!$result) {
echo "An error occurred - Masiii!\n";
exit;
}
?>
I put "username=a", "email=a" and password="a" to a form which processes the script handler.php in Firefox. I get
Warning: pg_query(): supplied argument is not a valid PostgreSQL link resource in /var/www/sivusto/handler.php on line 56
An error occurred - Masiii!
I am not sure where the bug is, since I use the same syntax as some examples at PHP.net.
How can you solve the bug?