Fatal error: Call to a member function bind_param() on a non-object in

Hi, I was getting error messages (which I seem to have solved most of them on my own, but damn this one is killing me!).

Is there anything I have overlooked in my coding?

($con is the connection btw)

[php]
$con->query(“INSERT INTO form_corpo_test SELECT * FROM *”);

// Replace by $sql
$stmt = $con->prepare(“INSERT INTO form_corpo_test (compagnie, telephone, site_web, texte_fr, texte_en, categories, profil_exposant, stands_du_manufacturier, pourcentage_quebec, pourcentage_canada, pourcentage_usa, pourcentage_autre, exporte, exporte_souhaite, produits_vert, nouveau_produits, nom, courriel, telephone_ressource, personne_ressource_c_toi, autre_personne_ressource, autre_courriel, autre_telephone)
VALUES
(’$_POST[company]’,’$_POST[phone]’,’$_POST[website]’,’$_POST[messagefr]’,’$_POST[messageen]’,’$str’,’$_POST[profession]’,’$_POST[manufacturiers_stand]’,’$_POST[percent_quebec]’,’$_POST[percent_canada]’,’$_POST[percent_usa]’,’$_POST[percent_autre]’,’$_POST[bt_export]’,’$_POST[bt_export_souhaite]’,’$_POST[bt_prod_verts]’,’$_POST[bt_new_prod]’,’$_POST[name]’,’$_POST[email]’,’$_POST[resource_phone]’,’$_POST[personne_ressource]’,’$_POST[backup_name]’,’$_POST[backup_email]’,’$_POST[backup_phone]’)”);

$stmt->bind_param(“sssssssssssssssssssssss”, $compagnie, $telephone, $site_web, $texte_fr, $texte_en, $categories, $profil_exposant, $stands_du_manufacturier, $pourcentage_quebec, $pourcentage_canada, $pourcentage_usa, $pourcentage_autre, $exporte, $exporte_souhaite, $produits_vert, $nouveau_produits, $nom, $courriel, $telephone_ressource, $personne_ressource_c_toi, $autre_personne_ressource, $autre_courriel, $autre_telephone);
[/php]

It outputs THIS error

Fatal error: Call to a member function bind_param() on a non-object in /home/*******/public_html/*****/******/processForm-test.php on line 92

(Btw, someone suggest I use curly brackets in the values (and demonstrated how, but when I do that, nothing gets uploaded to my db)

You have something mixed up here.

  1. wrong binding

You are adding all the variables directly to the query, then you are binding something (not sure what) with the bindparam command.

I think, this will be correct. Didn’t have much time today, but you get the point. A better way would be to fill a parameter-array first, and then just send inn the entire param array into bindparam.

[php]$stmt = $con->prepare(“INSERT INTO form_corpo_test (compagnie, telephone, site_web, texte_fr, texte_en, categories, profil_exposant, stands_du_manufacturier, pourcentage_quebec, pourcentage_canada, pourcentage_usa, pourcentage_autre, exporte, exporte_souhaite, produits_vert, nouveau_produits, nom, courriel, telephone_ressource, personne_ressource_c_toi, autre_personne_ressource, autre_courriel, autre_telephone)
VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)”);

$stmt->bind_param(“sssssssssssssssssssssss”, $_POST[‘company’],$_POST[‘phone’],$_POST[‘website’],$_POST[‘messagefr’],$_POST[‘messageen’],$str,$_POST[‘profession’],$_POST[‘manufacturiers_stand’],$_POST[‘percent_quebec’],$_POST[‘percent_canada’],$_POST[‘percent_usa’],$_POST[‘percent_autre’],$_POST[‘bt_export’],$_POST[‘bt_export_souhaite’],$_POST[‘bt_prod_verts’],$_POST[‘bt_new_prod’],$_POST[‘name’],$_POST[‘email’],$_POST[‘resource_phone’],$_POST[‘personne_ressource’],$_POST[‘backup_name’],$_POST[‘backup_email’],$_POST[‘backup_phone’]);[/php]

  1. The error message

You should check for sql errors so you can see what happens. You probably get the error because stmt isn’t an object (as it says), but a boolean, probable value is false because something has failed.

See more about parameterized queries and getting error messages here
http://php.net/manual/en/mysqli.quickstart.prepared-statements.php

I have taken a look at it, modified it endless times. We have installed PHP 5.2.17. Could that be why?

I tried the code you proposed, but to no avail.
So I’ve tried the OOP style of MySQLi. But, it still gives me the same damned error! The code should be correct! According to PHP.net, unless I’m not seeing something? If there truly is something that is not object-oriented, what would it be? Hell, even the error I’m asking PHP to tell me is not being brought forth, with the line of code starting with my if statement :S As you suggested, I looked up error coding.

The error, is again about the bind param line.

[php]$stmt = $con->prepare(“INSERT INTO form_corpo_test VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)”);
$stmt->bind_param(“sissssssiiiissssssisssi”, $compagnie, $telephone, $site_web, $texte_fr, $texte_en, $categories, $profil_exposant, $stands_du_manufacturier, $pourcentage_quebec, $pourcentage_canada, $pourcentage_usa, $pourcentage_autre, $exporte, $exporte_souhaite, $produits_vert, $nouveau_produits, $nom, $courriel, $telephone_ressource, $personne_ressource_c_toi, $autre_personne_ressource, $autre_courriel, $autre_telephone); // bind $compagnie etc. to the parameter

if (!$stmt->bind_param(“sissssssiiiissssssisssi”, $compagnie, $telephone, $site_web, $texte_fr, $texte_en, $categories, $profil_exposant, $stands_du_manufacturier, $pourcentage_quebec, $pourcentage_canada, $pourcentage_usa, $pourcentage_autre, $exporte, $exporte_souhaite, $produits_vert, $nouveau_produits, $nom, $courriel, $telephone_ressource, $personne_ressource_c_toi, $autre_personne_ressource, $autre_courriel, $autre_telephone)) {
echo “Binding parameters failed: (” . $stmt->errno . ") " . $stmt->error;
}[/php]

This line throws an error

$stmt->bind_param("sissssssiiiissssssisssi", $comp...

The error clearly states “Fatal error: Call to a member function bind_param() on a non-object”

This means $stmt is not an object.

In your last code you try to get an error message from the bind itself, but it’s really the creation of $stmt you should check. Also you shouldn’t run bind_param and then if(!bind_param), you’re practically doing it twice.

Reading up on PHP.net we see that this is the code to check the $stmt
[php]if (!($stmt = $mysqli->prepare(“INSERT INTO test(id) VALUES (?)”))) {
echo “Prepare failed: (” . $mysqli->errno . ") " . $mysqli->error;
}[/php]http://php.net/manual/en/mysqli.quickstart.prepared-statements.php

Your entire code should look something like this to fetch all errors:

[php]$con = new mysqli(“example.com”, “user”, “password”, “database”);

if ($con->connect_errno) {
echo “Failed to connect to MySQL: (” . $con->connect_errno . ") " . $con->connect_error;
}

if (!($stmt = $con->prepare(“INSERT INTO form_corpo_test VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)”))) {
echo “Prepare failed: (” . $con->errno . ") " . $con->error;
}

if (!$stmt->bind_param(“sissssssiiiissssssisssi”, $compagnie, $telephone, $site_web, $texte_fr, $texte_en, $categories, $profil_exposant, $stands_du_manufacturier, $pourcentage_quebec, $pourcentage_canada, $pourcentage_usa, $pourcentage_autre, $exporte, $exporte_souhaite, $produits_vert, $nouveau_produits, $nom, $courriel, $telephone_ressource, $personne_ressource_c_toi, $autre_personne_ressource, $autre_courriel, $autre_telephone)) {
echo “Binding parameters failed: (” . $stmt->errno . ") " . $stmt->error;
}[/php]

There could be errors in this as I haven’t used mysqli, I converted to PDO years ago and never looked at anything else.

I feel like banging my head today lol. After working on that crap for so long without having it to work -_-
What you are saying makes a lot of sense concerning the $stmt. I was not sure what could have been the problem. If it lies with that, then arrrrrrgh! lol

Although, after posting the comment, I created a different one using PDO. Would you suggest I simply switch to PDO? I wouldn’t mind getting this one to work first lol (which means reverting the new code to the old and modding it), but if you would highly suggest I switch to PDO, I wouldn’t mind switching to it.

I’ll show you the code I prepared so far. I am pretty concerned about its security (I am highly security minded, but as I’m an integrator and not a programmer, this part is much harder for me to grasp).

I’ll post my code here and you could suggest whether I should try continuing with MySQLi or PDO. This code works well so far. All I’m worried about is security.

Oddly enough, people keep using a ‘word’ with the single quotations (as demonstrated) for the values. That fails, so I resort in outright using $_POST.

[php]try {
$con = new PDO(“mysql:host=$hostname;dbname=$db”, $username, $password);
/*** echo a message saying we have connected ***/
//echo ‘Connected to database
’;

/*** INSERT data ***/
$count = $con->exec("INSERT INTO form_corpo_test (compagnie, telephone, site_web, texte_fr, texte_en, categories, profil_exposant, stands_du_manufacturier, pourcentage_quebec, pourcentage_canada, pourcentage_usa, pourcentage_autre, exporte, exporte_souhaite, produits_vert, nouveau_produits, nom, courriel, telephone_ressource, personne_ressource_c_toi, autre_personne_ressource, autre_courriel, autre_telephone)

 VALUES ('$_POST[company]','$_POST[phone]','$_POST[website]','$_POST[messagefr]','$_POST[messageen]','$str','$_POST[profession]','$_POST[manufacturiers_stand]','$_POST[percent_quebec]','$_POST[percent_canada]','$_POST[percent_usa]','$_POST[percent_autre]','$_POST[bt_export]','$_POST[bt_export_souhaite]','$_POST[bt_prod_verts]','$_POST[bt_new_prod]','$_POST[name]','$_POST[email]','$_POST[resource_phone]','$_POST[personne_ressource]','$_POST[backup_name]','$_POST[backup_email]','$_POST[backup_phone]')");

/*** echo the number of affected rows ***/
//echo $count;

/*** close the database connection ***/
$con = null;
}

catch(PDOException $e)
{
echo $e->getMessage();
}[/php]

I would recommend it, but I am biased :stuck_out_tongue:

You should also use array referencing with quotes. Without quotes PHP will first check if you have any constants with that name (since you claim you do), then it will fall back to using it as a string value (as you probably mean to do).

This is not safe, you are entering the parameters directly into the query and leave yourself wide open to sql injection.
[php]$count = $con->exec("INSERT INTO form_corpo_test (compagnie, telephone, site_web, texte_fr, texte_en, categories, profil_exposant, stands_du_manufacturier, pourcentage_quebec, pourcentage_canada, pourcentage_usa, pourcentage_autre, exporte, exporte_souhaite, produits_vert, nouveau_produits, nom, courriel, telephone_ressource, personne_ressource_c_toi, autre_personne_ressource, autre_courriel, autre_telephone)

 VALUES ('$_POST[company]','$_POST[phone]','$_POST[website]','$_POST[messagefr]','$_POST[messageen]','$str','$_POST[profession]','$_POST[manufacturiers_stand]','$_POST[percent_quebec]','$_POST[percent_canada]','$_POST[percent_usa]','$_POST[percent_autre]','$_POST[bt_export]','$_POST[bt_export_souhaite]','$_POST[bt_prod_verts]','$_POST[bt_new_prod]','$_POST[name]','$_POST[email]','$_POST[resource_phone]','$_POST[personne_ressource]','$_POST[backup_name]','$_POST[backup_email]','$_POST[backup_phone]')");[/php]

One of the great things with PDO is that you can prepare (with ?,?,?) first, and then execute with just sending all the parameters in as an array.

You should look up more on PHP.net/tutorials on running PDO prepared statements :slight_smile:

Ahah, really? Well, good enough for me!

Yes, I had that but it failed lol. Until I realized it was bindParam and not bind_param. I then realized that I might have been mixing up mysqli and pdo on top of things.

I’m currently looking on this website:
http://www.php.net/manual/en/pdo.prepared-statements.php

This is highly confusing. They keep writing the words name and value. I assume this is THE place for me to use material from?

If so,

In this case, is “name” and “value” reserved words? Or should I replace the words by the names from the form and the values from the db? For example,
(question name, question name, question name, db value, db value, db value)
and for VALUES
(:question name, :question name, :question name :db value, :db value, :db value)
[php]
$stmt = $dbh->prepare(“INSERT INTO REGISTRY (name, value) VALUES (:name, :value)”);
$stmt->bindParam(’:name’, $name);
$stmt->bindParam(’:value’, $value);[/php]

The numbers, what are they?
If I have 23 entries, should I use the words one through twenty-three for every entry $name? Followed by an ascending numerical number from 1-23?

[php]// insert one row
$name = ‘one’;
$value = 1;
$stmt->execute();

// insert another row with different values
$name = ‘two’;
$value = 2;
$stmt->execute();
?>
[/php]

Oh, and you stated that I could substitute a portion of the above for question marks. Since I can do that, would it be like mysqli? Where I would (in my case), use 23 question marks?

In PDO you can use both named (:name) and unnamed (?) Placeholders. I prefer unnamed and executing an array as it’s shortest

-_- It inserted nothing inside my db :frowning:
Unsure about the question marks in conjunction with the bottom part. I didn’t know how to use it with it. So, I left that out and used the colons instead with the values from my db.

Anyhow, so confused right now. I tried executing only one of course (as seen at the bottom).

[php]$stmt = $con->prepare(“INSERT INTO form_corpo_test VALUES (:company,:phone,:website,:messagefr,:messageen,:cats,:profession,:manufacturiers_stand,:percent_quebec,:percent_canada,:percent_usa,:percent_autre,:bt_export,:bt_export_souhaite,:bt_prod_verts,:bt_new_prod,:name,:email,:resource_phone,:personne_ressource,:backup_name,:backup_email,:backup_phone)”);
//(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

$stmt->bindParam(’:company’, $compagnie);
$stmt->bindParam(’:phone’, $telephone);
$stmt->bindParam(’:website’, $site_web);
$stmt->bindParam(’:messagefr’, $texte_fr);
$stmt->bindParam(’:messageen’, $texte_en);

$stmt->bindParam(’:cats’, $categories);
$stmt->bindParam(’:profession’, $profil_exposant);
$stmt->bindParam(’:manufacturiers_stand’, $stands_du_manufacturier);
$stmt->bindParam(’:percent_quebec’, $pourcentage_quebec);
$stmt->bindParam(’:percent_canada’, $pourcentage_canada);

$stmt->bindParam(’:percent_usa’, $pourcentage_usa);
$stmt->bindParam(’:percent_autre’, $pourcentage_autre);
$stmt->bindParam(’:bt_export’, $exporte);
$stmt->bindParam(’:bt_export_souhaite’, $exporte_souhaite);
$stmt->bindParam(’:bt_prod_verts’, $produits_vert);

$stmt->bindParam(’:bt_new_prod’, $nouveau_produits);
$stmt->bindParam(’:name’, $nom);
$stmt->bindParam(’:email’, $courriel);
$stmt->bindParam(’:resource_phone’, $telephone_ressource);
$stmt->bindParam(’:personne_ressource’, $personne_ressource_c_toi);

$stmt->bindParam(’:backup_name’, $autre_personne_ressource);
$stmt->bindParam(’:backup_email’, $autre_courriel);
$stmt->bindParam(’:backup_phone’, $autre_telephone);

$compagnie = ‘company’;
$stmt->execute();[/php]

This should work

[php]$stmt = $con->prepare(“INSERT INTO form_corpo_test VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)”);

if (!$stmt) {
$error = $stmt->errorInfo();
echo 'PDO error: ’ . $error[2] . ‘(’ . $stmt->errorCode() . ‘)’;

} else {
$stmt->execute(array(
$_POST[‘company’], $_POST[‘phone’], $_POST[‘website’], $_POST[‘messagefr’], $_POST[‘messageen’], $str, $_POST[‘profession’], $_POST[‘manufacturiers_stand’], $_POST[‘percent_quebec’], $_POST[‘percent_canada’], $_POST[‘percent_usa’], $_POST[‘percent_autre’], $_POST[‘bt_export’], $_POST[‘bt_export_souhaite’], $_POST[‘bt_prod_verts’], $_POST[‘bt_new_prod’], $_POST[‘name’], $_POST[‘email’], $_POST[‘resource_phone’], $_POST[‘personne_ressource’], $_POST[‘backup_name’], $_POST[‘backup_email’], $_POST[‘backup_phone’]
));

if (!$stmt) {
$error = $stmt->errorInfo();
echo 'PDO error: ’ . $error[2] . ‘(’ . $stmt->errorCode() . ‘)’;
} else {

  echo 'Insert OK';

}
}[/php]

Notice how messy it is though. I would suggest you consider using a wrapper class for the DB.

Save this as db.php
[php] <?php

class DB {

 /**
  *
  * PDO connection
  * @var PDO
  */
private $pdoConn = null;

/**
 * Default charset
 *
 * @var string
 */
private $charset = 'utf8';

/**
 * Class constructor
 */
public function __construct() {
  $this->_initDb();
}

/**
 * Get PDO database connection
 *
 * @return
 */
public function getPDOConn() {
  return $this->pdoConn;
}

/**
 * Init db connection based on config
 */
private function _initDb() {
  try {
    $this->pdoConn = new \PDO('mysql:dbname=' . DB_NAME . ';host=' . DB_HOST . ';charset=' . $this->charset, DB_USER, DB_PASS);
    $this->pdoConn->exec("set names utf8");
    $this->pdoConn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
    $this->pdoConn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
  } catch (PDOException $e) {
    // Here you should do some error handling
    $errormessage = "Database error occured at: " . strftime("%Y-%m-%d %H:%M:%S") . "\">\n";
    $errormessage .= "[DB] _initDb: could not get PDO connection: " . $e->getMessage() . "\n";
    echo '<pre>' . $errormessage . '</pre>';
    return;
  }
}

/**
 * Executes parametarized query
 * @param string $query
 * @param array $params
 * @param string $fetch_method
 */
public function query($query, $params = [], $fetch_method = 'OBJ') {
  $stmt = $this->pdoConn->prepare($query);
  try {
    $result = $stmt->execute($params);
  } catch (PDOException $e) {
    // Here you should do some error handling
    $errormessage = "\tDatabase error occured at: " . strftime("%Y-%m-%d %H:%M:%S") . "\">\n";
    $errormessage .= "\tQuery: " . $query . "\n";
    $errormessage .= "\tError code: " . $e->getCode() . "\n";
    $errormessage .= "\tError message: " . $e->getMessage() . "\n";
    echo '<pre>' . $errormessage . '</pre>';
  }
  if ($result) {
    $querybit = explode(" ", $query);
    if (trim($querybit[0]) == 'SELECT') {
      $ret = $stmt->fetchAll(constant('PDO::FETCH_' . strtoupper($fetch_method)));
    } else {
      return array(TRUE);
    }
  }
  return !empty($ret) ? $ret : null;
}

/**
 * Get last inserted id
 *
 * @return integer
 */
public function getLastInsertedId() {
  return $this->pdoConn->lastInsertId();
}

/**
 * Wrapper for mysql_real_escape_string
 *
 * @param string $string
 * @return string
 */
protected function _escape($string) {
  return mysql_real_escape_string($string);
}

}[/php]

Then you can use your db like this:

[php]<?php
define(‘DB_HOST’, ‘localhost’);
define(‘DB_USER’, ‘test’);
define(‘DB_PASS’, ‘test’);
define(‘DB_NAME’, ‘test’);

require_once (‘db.php’);

$db = new DB();

$db->query(‘INSERT INTO form_corpo_test VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)’, array(
$_POST[‘company’], $_POST[‘phone’], $_POST[‘website’], $_POST[‘messagefr’], $_POST[‘messageen’], $str, $_POST[‘profession’], $_POST[‘manufacturiers_stand’], $_POST[‘percent_quebec’], $_POST[‘percent_canada’], $_POST[‘percent_usa’], $_POST[‘percent_autre’], $_POST[‘bt_export’], $_POST[‘bt_export_souhaite’], $_POST[‘bt_prod_verts’], $_POST[‘bt_new_prod’], $_POST[‘name’], $_POST[‘email’], $_POST[‘resource_phone’], $_POST[‘personne_ressource’], $_POST[‘backup_name’], $_POST[‘backup_email’], $_POST[‘backup_phone’]
));[/php]

I have never seen this type of coding before. I had tried the messy code (as you called it lol), and nothing was adding to my db. With the other piece of code which I tried afterwards, these errors popped up:

[php]
Warning: Unexpected character in input: ‘’ (ASCII=92) state=1 in /home/product/public_html/sidim.com/formulaires/db.php on line 40

Warning: Unexpected character in input: ‘’ (ASCII=92) state=1 in /home/product/public_html/*******/********/db.php on line 42

Warning: Unexpected character in input: ‘’ (ASCII=92) state=1 in /home/product/public_html/*******/********/db.php on line 42

Warning: Unexpected character in input: ‘’ (ASCII=92) state=1 in /home/product/public_html/*******/********/db.php on line 43

Parse error: syntax error, unexpected ‘[’ in /home/product/public_html/*******/********/db.php on line 59[/php]

They refer to:
[php]
40 $this->pdoConn = new \PDO(‘mysql:dbname=’ . DB_NAME . ‘;host=’ . DB_HOST . ‘;charset=’ . $this->charset, DB_USER, DB_PASS);

42 $this->pdoConn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

43 $this->pdoConn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);

59 public function query($query, $params = [], $fetch_method = ‘OBJ’) {[/php]

Which PHP version are you on? The first errors suggest you are using PHP < 5.3 while the last one suggest using PHP < 5.4

I would seriously change host to someone not using an ancient PHP library…

Indeed, the server is running 5.2.17. I have zero control over that, unfortunately :confused: Just an employee. There is no way for me to install a new version of PHP, is there? Since the server is God knows where lol.

Would there be a non-deprecated PDO code that I can use? I mean of a code similar to yours, but which would work with 5.2. Also, why would my Dreamweaver detect an error on line 59? It was an error concerning the brackets. (I use CS6 suite)

For sure, I will try it with my own host when I get the chance to (but I rather not connect to my host via my work pc, for security reasons).

You can if you get access to it, but if you guys are running several services on it you might break something else. As you see there are changes that can make (or break) stuff between versions.

Do not try to update without consulting whoever is in charge of running things. The proper way to do this is to request an update.

5.2.17 was released in january 2011, while it might not sound like a long time it really is… If the rest of the server runs with as outdated software as this then you’re in luck not having gotten trouble yet :stuck_out_tongue:

PDO should work just fine for all versions of PHP > 5. What you’re having a problem with is namespaces. If you change \PDO to just PDO it might resolve the issue.

It is not valid code for PHP < 5.4. It is called short array referencing, and you should change it to the old method of doing things.

Change line 59 to:
[php]public function query($query, $params = array(), $fetch_method = ‘OBJ’) {[/php]

OMG, everything seems ok code wise (I think) after changing what you proposed, except when I had to Google for half an hour this stupid message:

[php]SQLSTATE[28000] [1045] Access denied for user ‘product’@‘localhost’ (using password: NO)[/php]

Can I strangle the server now? Yes, there is a password. -_-
Since every thread seems to have Linux users, this doesn’t help. They keep speaking about a terminal :’( The Linux one, I assume.

I modified the content to 127.0.0.1 as well, and changed the user to the bare minimum, to no avail.

Are you sure? Add var_dump(DB_PASS) before line 40 and see if it’s set.

Yup, I am sure. I am the one who personally created the database. Prior to using PDO, I was using MySQLi (unsecured) and the password was working properly.

This is what it spews out:

[php]string(7) “DB_PASS” SQLSTATE[28000] [1045] Access denied for user ‘product’@‘localhost’ (using password: NO[/php]

My password is longer than 7 characters. Don’t know what string(7) means.

That makes no sense o.O

Try to hard code the connection

[php]$this->pdoConn = new PDO(‘mysql:dbname=database_name;host=database_host;charset=UTF-8’, ‘database_username’, ‘database_password’);[/php]

Just to be extra extra extra safe, I tried 4 combinations (plus a few more variants)

[php]$this->pdoConn = new PDO(‘mysql:dbname=;host=localhost;charset=UTF-8’, '*’, ‘******’);[/php]This gave no error, but uploaded nothing.

[php]$this->pdoConn = new PDO(‘mysql:dbname=******;host=127.0.0.1;charset=UTF-8’, ‘******’, ‘******’);[/php]This gave no error, but uploaded nothing.

[php]$this->pdoConn = new PDO(‘mysql:dbname=$db;host=$hostname;charset=UTF-8’, ‘$username’, ‘$password’);[/php]This gave no error, but uploaded nothing.

[php]$this->pdoConn = new PDO(‘mysql:dbname=db;host=hostname;charset=UTF-8’, ‘username’, ‘password’);[/php]This gave no error, but uploaded nothing.

I agree, it makes no sense.

Method 1 and 2 looked ok, try to do a normal select query.

Sponsor our Newsletter | Privacy Policy | Terms of Service