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

I'm working a log-in script that I found on the web. (

As I was trying to make it work, I stumbled upon this error:

bool(false) Fatal error: Call to a member function bindParam() on a non-object in /srv/disk3/1446018/www/ on line 25

My code:



  //  Establishing the connection:
  $MyConnection = mysqli_connect('hostname', 'user', 'pass', 'database')
    or die('An error has occured when you were trying to login. You can return to the main page
      by clicking: <a href="index.php">here</a>. <br />
      If this error is consistent, please <a href="contact.php">contact us</a>.');

  //  Information provide by the user:
  $username = $_POST['username'];
  $password = $_POST['password']; // Text version.

  $StatementHandle = $MyConnection->prepare('
    FROM Users
      username = :username
    LIMIT 1

  $StatementHandle->bindParam(':username', $username);


  $user = $StatementHandle->fetch(PDO::FETCH_OBJ);

  // Hashing the password with its hash as the salt returns the same hash:
  if(crypt($password, $user->hash) == $user->hash) {
    echo 'You are logged in. Well, not actually. We only just confirmed that
      our system works. This service\'ll cost you $1';



your connection object is mysqli, you should use PDO to connect mysql like

$dsn = 'mysql:dbname=testdb;host=';
$user = 'dbuser';
$password = 'dbpass';

try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();

Need Your Help

NHibernate-friendly database design for dynamically recreated tables


I have an application design question for the nhibernate gurus our there. My application tracks a list of documents submitted and displays data parsed from those documents to the public as a searc...

Position the point in the center on Highcharts even if the Timezone is not UTC

php highcharts

I have tried every possible thing but because my timezone is set to America/New_York my points are like 5px right to the actual tick. (I really tried to do everything and was googling for an answer...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.