Skip to content Skip to sidebar Skip to footer

Validating Sql Query With Php

The validation seems to fail for some reason. By the validation, I mean the 'if ($result)' -part. How can I correctly validate SQL-query? $dbconn = pg_connect('host=localhost port=

Solution 1:

I suspect that the return value is integer zero which is also interprested as false in the if statement. By doing "if ($result !== FALSE)" (Note that it should be !== and not !=) you'll verify if the result really is different than FALSEand not just false...

Solution 2:

Should you add apostraphe's around $1 in your SQL query, as in?

SELECT user_id
FROM users
WHERE email ='$1'

I'm not sure how PHP expands the $1 variable.

Post a Comment for "Validating Sql Query With Php"