Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8787565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:55:21+00:00 2026-06-13T21:55:21+00:00

Was going over my code to turn all my queries into prepared queries (PDO).

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:55:22+00:00Added an answer on June 13, 2026 at 9:55 pm

    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…):

    1. declare your PDO connection variable global in your function. I would not recommend this as a final solution, but it would work while you improve on things;
    2. add the PDO connection as an additional parameter to your function. Although better than 1., you would need to change all function calls to include the new parameter(s);
    3. refactor to OOP and use dependency injection to add your PDO connection to your email class / object.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was going over some old C code (listed below) with a view to
I am going over/studying the facebook code that was leaked in 2007, I notice
I just joined a project, and have been going over the code. We need
I am going over some code i wrote in 2006 as an undergrad. It's
I'm currently going over my user registration code. The part I'm focusing on right
So, I was going over some old code I wrote about 5 years ago
I've been going over and refactoring some code. I ended up changing a function
Been going over my predecessor's code and see usage of the request scope frequently.
While going over some code I came across the following line of code ostream&
I am going over some code written by another developer and am not sure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.