Was going over my code to turn all my queries into prepared queries (PDO). I changed my connection page accordingly. As I was cleaning up my functions page I came across the error mysql_error() expects parameter 1 to be resource, integer given which referred to my email function
email_exists($email){
$query1 = mysql_query("SELECT COUNT(user_id) FROM tempusers WHERE
`email` = '$email'") OR die(mysql_error(0));
$email = sanitize($email);
return (mysql_result($query1,0)==1)? true : false;
}
Because it is a function page meaning I can’t call on the variables in my connection page coupled with the fact I’m still stuck in the old query ways I’m having a hard time fixing this query. I’d appreciate any ideas on the process of making this query work as well as any tips in general.
You should handle errors in your function the same way you handle them everywhere else.
However, as this is inside a function, you need to make the connection available in the scope of the function.
There are several ways to do that, some examples (from not that good to better…):