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 8240667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:34:01+00:00 2026-06-07T20:34:01+00:00

I started over with a project I was working on earlier. With the help

  • 0

I started over with a project I was working on earlier. With the help of my PHP book and a few people on Stack Overflow, I was able to get rid of a lot of the errors I was getting.

Now, I am left with a warning and a fatal error. I understand both errors, I am just not sure how to fix the errors I am getting. Could anyone please help? I am not asking for anyone to write the code or just do everything for me, I just need a point in the right direction.

This is the warning, and it sounds like I need to put __construct somewhere in the uploadFile() method, but again, not sure about this:

Warning: PDO::prepare() [pdo.prepare]: SQLSTATE[00000]: No error: PDO
constructor was not called in C:\xampp\htdocs\files\upload.php on line
23

The second, I am just completely lost on what to do about. I realize what the error is telling me, I just don’t know where to start in terms of fixing it. Here it is:

Fatal error: Call to undefined method upload::bindParam() in
C:\xampp\htdocs\files\upload.php on line 24

If there’s anymore information I could provide that would make this easier to answer, please tell me and I will try to get it for you. I appreciate any help!

upload.php

  <?php
error_reporting(E_ALL);
require('config.php');

class upload extends PDO
{
    public $conURL, $filename, $tmpname, $filesize, $filetype, $file;

    public function __construct($config) {
        $conURL = "mysql:host=" . $config['host'] . ";dbname=" . $config['db'];
        parent::__construct($conURL, $config['user'], $config['pass']);

    }       

    public function uploadFile() {
        if ($_FILES['file']['size'] >= 2000000) {
           echo "File is too large!"; 
        }
        else {
            $sth = $this->prepare("INSERT INTO uploads (name, type, size, file) VALUES (?, ?, ?, ?)");
            $sth->bindParam(1, $filename);
            $sth->bindParam(2, $filetype);
            $sth->bindParam(3, $filesize);
            $sth->bindParam(4, $file);
            $sth->execute();
        }
    }
}

$upload = new upload($config);

$upload->filename = $_FILES['file']['name'];
$upload->tmpname = $_FILES['file']['tmp_name'];
$upload->filesize = $_FILES['file']['size'];
$upload->filetype = $_FILES['file']['type'];    
$upload->file = $_FILES['file'];


$upload->uploadFile();

config.php

<?php
$config = array(
        'host' => 'localhost', // db host
        'user' => 'root', // db user
        'pass' => '', //db pass
        'db' => 'files' // db name
);

Edit: Thanks to everyone here, only one error remains and it is the following:

Fatal error: Call to undefined method stdClass::uploadFile() in
C:\xampp\htdocs\files\upload.php on line 43

Edit 2: All errors have been resolved, but nothing is being inserted into the database.

  • 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-07T20:34:03+00:00Added an answer on June 7, 2026 at 8:34 pm

    Your constructor should look like:

    public function __construct($config) {
            $conURL = "mysql:host=" . $config['host'] . ";dbname=" . $config['db'];
            try {
                parent::__construct($conURL, $config['user'], $config['pass']);
            } catch (PDOException $e) {
                $e->getMessage();
            }
    }  
    

    or even

    public function __construct($config)
    {
        $conURL = "mysql:host=" . $config['host'] . ";dbname=" . $config['db'];
        parent::__construct($conURL, $config['user'], $config['pass']);
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning NHibernate. Over the past few months I have been
Solved: Unfortunately I wasn't able to solve the problem but I started over and
I am trying to get started with working with named pipes as I will
I recently started working on a small personal project in Ruby on Rails, and
I've been working on a (nearly finished) Javascript project for a little over 14
As part of a small project I'm working on, I need to be able
I just started working on a new project with a ton of existing code,
I've recently taken over a MVVM project started by someone who's now left the
As I started working with Hibernate a few days ago, I was just wondering
I just started using vim a few hours ago and am working on a

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.