I´m developing a website using php and I tried to implement pdo but it keeps returning
PDO::errorInfo():Array([0] => 00000 [1] => [2] => )
It´s very important that I can fix these error since this is an important project for me and I´ve tried everything I could. the connection works fine since I Any ideas? Here is the connection (in case you need it):
<?php
$redirect ="503.php";
$config = parse_ini_file('config.ini');
$basehost = $config['host'];
$basecon = $config['table'];
$seccon = $config['sectable'];
$basechar = $config['char'];
$smhost = $config['SMTPhost'];
$smauth = $config['SMTPAuth'];
$smuser = $config['SMTPUser'];
$smpass = $config['SMTPPass'];
$smsec = $config['SMTPSecure'];
$cartab = $config['cardtable'];
$con = "mysql:host=$basehost;dbname=$basecon;charset=$basechar";
$options = [PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,];
try {
$pdo = new PDO($con,$config['username'],$config['password'], $options);
} catch (Exception $e) {
exit(header("location:$redirect"));
}
?>
Here is the problem I can´t handle:
if($mail->send()) {
$stmt = $pdo->prepare("INSERT INTO $basecon.$seccon (C_Nome,C_email,C_User,C_Pass,Card_Number,N_fiscal,D_Nasc,C_Morada,N_tel,N_tel_emer,N_cid,N_saude,Tipo_Sangue,C_Hist,Reg_Code) VALUES (:name, :email,:user,:pass,:cardnum,:fisnum,:birth,:adressnum,:telf,:emertelf,:citcard,:healthcard,:bloodstring,:histstring,:value)");
$stmt->bindParam(array(':name', $_POST['name']), PDO::PARAM_STR);
$stmt->bindParam(array(':email', $_POST['email']), PDO::PARAM_STR);
$stmt->bindParam(array(':user', $_POST['username']), PDO::PARAM_STR);
$stmt->bindParam(array(':pass', md5($_POST['password'])), PDO::PARAM_STR);
$stmt->bindParam(array(':cardnum', $_POST['cardnumber']), PDO::PARAM_STR);
$stmt->bindParam(array(':fisnum', $_POST['fiscalnum']), PDO::PARAM_STR);
$stmt->bindParam(array(':birth', $_POST['birthdate']), PDO::PARAM_STR);
$stmt->bindParam(array(':adressnum', $_POST['address']), PDO::PARAM_STR);
$stmt->bindParam(array(':telf', $_POST['telnum']), PDO::PARAM_STR);
$stmt->bindParam(array(':emertelf', $_POST['emertelnum']), PDO::PARAM_STR);
$stmt->bindParam(array(':citcard', $_POST['citnumber']));
$stmt->bindParam(array(':healthcard', $_POST['healthnumber']), PDO::PARAM_STR);
$stmt->bindParam(array(':bloodstring', $_POST['bloodtype']), PDO::PARAM_STR);
$stmt->bindParam(array(':histstring','Conta criada a'), PDO::PARAM_STR);
$stmt->bindParam(array(':value', $regcode), PDO::PARAM_STR);
if($stmt->execute()) {
$successmsg = "Your registration was successful! <a href='login.php'>Clique aqui para efetuar login</a><br>";
} else {
$errormsg = "We couldn´t send you the confirmation E-mail, please check if you provided us with the correct E-mail, if so, please try again later.";
}
} else {
echo "\nPDO::errorInfo():\n";
print_r($pdo->errorInfo());
$errormsg = '<div class="alert alert-danger" role="alert">Something went wrong, please try again later." </div>' ;
}
And the E-mail works so that has nothing to do with the problem. And thank you :)