Hello guys
this is the first time I see this message while i'm trying to register a new account:
the message : __php_incomplete_class could not be converted to string
I try var_dumb($_SESSION) and i get this:
object(__PHP_Incomplete_Class)[1]
public '__PHP_Incomplete_Class_Name' => string 'Customer' (length=8)
public 'id' => string '3' (length=1)
public 'firstName' => null
public 'lastName' => null
public 'email' => null
public 'balance' => int 0
public 'message' => string '' (length=0)
public 'password' => null
public 'address' => null
the code:
public static function getCartId()
{
$dbh = mySqlDatabase::getConnectionObject();
// if customer is logged in
if (isset($_SESSION['customerId']) && !empty($_SESSION['customerId'])) {
$customerId = $_SESSION['customerId'];
$sql = "SELECT id FROM shoppingcarts WHERE customerId = :id AND isCompleted = 0";
$stmt = $dbh->prepare($sql);
$stmt->bindParam(':id', $customerId, PDO::PARAM_INT);
$stmt->execute();
$result = $stmt->fetchColumn();
if ($stmt->rowCount() == 0) {
// if there's a cart but not completed
$sql = "INSERT INTO shoppingcarts(customerId, isCompleted, isShipped) VALUES ($customerId, 0, 0)";
$stmt = $dbh->prepare($sql);
$stmt->execute();
$result = $dbh->lastInsertId();
return $result;
} else return $result;
} else {
// if customer is guest
if (isset($_COOKIE['trace']) && !empty($_COOKIE['trace'])) {
$shoppingCartId = $_COOKIE['trace'];
return $shoppingCartId;
} else {
// user not logged in in and have no cookie
$sql = "INSERT INTO shoppingcarts(customerId, isCompleted, isShipped) VALUES (1,0 ,0 )";
$stmt = $dbh->prepare($sql);
$stmt->execute();
$result = $dbh->lastInsertId();
setcookie('trace', $result, time() + 3 * 30 * 24 * 60 * 60);
return $result;
}
}
}