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

  • SEARCH
  • Home
  • 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 9052961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:18:32+00:00 2026-06-16T13:18:32+00:00

i am actually started using PDO , i have seen many questions on PDO

  • 0

i am actually started using PDO , i have seen many questions on PDO but i am not able resolve my problem by reading those questions.

I have one file PDO Config File called db.php , this file having no problem.

db.php 

<?php 
######## PDO Config File ##########
        $mysql_hostname = "localhost";
        $mysql_user = "web";
        $mysql_password = "123123";
        $mysql_database = "123123";
        //$odb = new PDO ("mysql:host=".$mysql_hostname.";dbname=".$mysql_database;charset:UTF-8",$mysql_user,$mysql_password);
        try{
                $connect = new PDO("mysql:host=".$mysql_hostname.";dbname=".$mysql_database.";charset:UTF-8", $mysql_user, $mysql_password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
        }
        catch(PDOException $pe){
            die('Could connect to the database because: ' .$pe->getMessage());
        }
 ?>

I have Included this file in to the following PHP file[setting.php] .

setting.php

class Account
{
    public function userEmailChnage($inputCurrentEmail,$inputChangeEmail,$inputConfirmEmail)
    {
        if(!empty($inputCurrentEmail) AND !empty($inputChangeEmail) AND !empty($inputConfirmEmail)){
            $selectEmail        = "select mail from users where mail = ?";
            $selectEmailPrepare = $connect -> prepare($selectEmail);
            $selectEmailPrepare -> execute(array($inputConfirmEmail));

        if ($selectEmailPrepare ->rowCoun() > 0 ) {     
                if($inputChangeEmail == $inputConfirmEmail) {
                        $EmailUpdate = "UPDATE users SET mail= ?";
                        $EmailUpdatePrepare = $connect->prepare($EmailUpdate);
                        $EmailUpdatePrepare -> execute(array($inputChangeEmail));
                        $msg[EmailUpdateOpration]=Success;

                }else{
                        $msg[IsConfirmMailMatching]=FALSE; //---------------- > JSON ERROR Msg 
                }
            }else{
                    $msg[IsEmailInDatabase]=FALSE; //---------------- > JSON ERROR Msg 
            }
        }else{
            $msg[IsEmailFieldEmpty]=TRUE; //---------------- > JSON ERROR Msg 
        }   
        header("Content-Type: application/json", true); 
        echo json_encode($msg); 
    }

}

After the execution of the file i am facing following error :

Fatal error: Call to a member function prepare() on a non-object in /home/admin/public_html/class/setting.php on line 12

I am tried to change PDO config file , it didn’t worked. I started testing setting.php .. Not able to solve it !

  • 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-16T13:18:33+00:00Added an answer on June 16, 2026 at 1:18 pm

    In this line:

    $EmailUpdatePrepare = $connect->prepare($EmailUpdate);
    

    … you get this error:

    Call to a member function prepare() on a non-object

    That means exactly that: $connect is not an object. It appears to be a global variable so you need to handle it as such: either call global $connect; before you use it or read it through $GLOBALS['connect']. (Or, even better, pass it as argument to the method.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently started using mercurial (it's actually my first experience with version control) but
I just started using YUI3 Test module (http://yuilibrary.com/yui/docs/test/). I have testcases with many asserts
Hello i have recently started using vim editor ( actually the plugin for netbeans
I started to use Borland's Turbo C++ a few days ago. I actually have
I've started using the HTML5 data- attributes in my application, but when this is
I recently started using the DisplayTag library and I've run into a problem. I'm
I've just started using Team Foundation Server and have added a new Solution that
I've recently started using NetBeans, coming from Eclipse. I have a simple implementation of
I have just started using the audio elements buffered attribute. I have only tested
I have just started using SCSS for the first time. I'm noticing that the

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.