inserting date using PDO and php - php

I'm trying to insert into a table, I have managed this using the same syntax for another query but this fails, the only difference is that this contains date information. Can anyone spot the problem?
The date is in this format: 2016-07-07.
try {
$sql2 = "INSERT INTO excavation.contexts_spatial
(area_easting,
area_northing,
context_number,
open_date,
close_date,
excavation_method,
contamination,
zooarchaeology_comments,
ceramic_comments) VALUES (
:area_easting,
:area_northing,
:context_number,
:open_date,
:close_date,
:excavation_method,
:contamination,
:zooarchaeology_comments,
:ceramic_comments)";
$stmt2 = $conn->prepare($sql2);
// prepare sql and bind parameters
$stmt2->bindParam(':area_easting', $area_easting, PDO::PARAM_INT);
$stmt2->bindParam(':area_northing', $area_northing, PDO::PARAM_INT);
$stmt2->bindParam(':context_number', $nextContext, PDO::PARAM_INT);
$stmt2->bindParam(':open_date', $open_date, PDO::PARAM_STR);
$stmt2->bindParam(':close_date', $close_date, PDO::PARAM_STR);
$stmt2->bindParam(':excavation_method', $excavation_method, PDO::PARAM_STR);
$stmt2->bindParam(':contamination', $contamination, PDO::PARAM_STR);
$stmt2->bindParam(':zooarchaeology_comments', $excavation_method, PDO::PARAM_STR);
$stmt2->bindParam(':ceramic_comments', $excavation_method, PDO::PARAM_STR);
//$stmt2->execute();
// insert a row
$area_easting = $_SESSION['area_easting'];
$area_northing = $_SESSION['area_northing'];
$nextContext = $_SESSION['nextContext'];
$open_date = $_SESSION['dateOpen'];
$close_date = $_SESSION['dateClose'];
$excavation_method = $_SESSION['excavationMethod'];
$contamination = $_SESSION['contamination'];
$zooarchaeology_comments = $_SESSION['zooarchaeologyComments'];
$ceramic_comments = $_SESSION['ceramicComments'];
$stmt2->execute();
echo "New records created successfully in contexts spatial<br />";
}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}

You are executing your statement before setting the variables. Remove $stmt2->execute();
from below
$stmt2->bindParam(':ceramic_comments', $excavation_method, PDO::PARAM_STR);
$stmt2->execute(); // REMOVE THIS LINE
// insert a row
$area_easting = $_SESSION['area_easting'];

Related

Trying to populate sql table with html form

Im trying to create a new row in the table 'Colaboradores' but it doesn't populate, but when i 'echo' the '$sql' with works fine along with the connection. I already check the name of the columns in the sql table. Im using MAMP as a sever
<?php
include("../../config.php");
session_start();
if($_SERVER["REQUEST_METHOD"] === "POST") {
$nomeF = $_POST['nomeF'];
$nomeL = $_POST['nomeL'];
$Prof = $_POST['Profissao'];
$morada = $_POST['morada'];
$cod = $_POST['cod'];
$num = $_POST['num'];
$mail = $_POST['mail'];
$ordeb = $_POST['ordb'];
$orde = $_POST['orde'];
$dataI = $_POST['dataI'];
$dataF = $_POST['dataF'];
$notas1 = $_POST['notas1'];
$notas2 = $_POST['notas2'];
try
{
$db = new PDO('mysql:host=localhost;dbname=SCMMM;charset=utf8', 'root', 'root');
}
catch(Exception $e)
{
die('Error : '.$e->getMessage());
}
$sql = "INSERT INTO Colaboradores (NomeF, NomeL, Profissao, Morada, CodPostal, Telemovel, mail, precoh, precohmais, dataI, dataF, notas1, notas2)
VALUES (:nomeF, :nomeL, :Prof, :morada, :cod, :num, :mail, :ordeb, :orde, :dataI, :dataF, :notas1, :notas2)";
$stmt = $db->prepare($sql);
$stmt->bindValue('nomeF', $nomeF, PDO::PARAM_STR);
$stmt->bindValue('nomeL', $nomeL, PDO::PARAM_STR);
$stmt->bindValue('Prof', $Prof, PDO::PARAM_STR);
$stmt->bindValue('morada', $morada, PDO::PARAM_STR);
$stmt->bindValue('cod', $cod, PDO::PARAM_STR);
$stmt->bindValue('num', $num, PDO::PARAM_INT);
$stmt->bindValue('mail', $mail, PDO::PARAM_STR);
$stmt->bindValue('ordb', $ordeb, PDO::PARAM_INT);
$stmt->bindValue('orde', $orde, PDO::PARAM_INT);
$stmt->bindValue('dataI', $dataI, PDO::PARAM_STR);
$stmt->bindValue('dataF', $dataF, PDO::PARAM_STR);
$stmt->bindValue('notas1', $notas1, PDO::PARAM_STR);
$stmt->bindValue('notas2', $notas2, PDO::PARAM_STR);
$stmt->execute();
}
?>
You can easily improve your code :
Avoid symbol as ã or + in database
Avoid space in database (replace by _)
Inform yourself about OOP and PDO
Inform yourself about SQL injection, Prepare query, ...
Use a convention for your variables names, lower camelcase ? upper camelcase ? whatever but stay regular
Now try with this code
$nomeF = $_POST['nomeF'];
$nomeL = $_POST['nomeL'];
$descP = $_POST['descP'];
$morada = $_POST['morada'];
$num = $_POST['num'];
$mail = $_POST['mail'];
$dataI = $_POST['dataI'];
$dataF = $_POST['dataF'];
$ordeb = $_POST['ordeb'];
$orde = $_POST['orde'];
$notas1 = $_POST['notas1'];
$notas2 = $_POST['notas2'];
try
{
$db = new PDO('mysql:host=localhost;dbname=DBNAME;charset=utf8', 'USERNAME', 'PASSWORD');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$sql = "INSERT INTO Colaboradores (nomeF, nomeL, descP, morada, mail, ordeb, orde, dataI, dataF, notas1, notas2)
VALUES (:nomeF, :nomeL, :descP, :morada, :num, :mail, :ordeb, :orde, :dataI, :dataF, :notas1, :notas2)";
$stmt = $db->prepare($sql);
$stmt->bindValue('nomeF', $nomeF, PDO::PARAM_STR);
$stmt->bindValue('nomeL', $nomeL, PDO::PARAM_STR);
$stmt->bindValue('descP', $descP, PDO::PARAM_STR);
$stmt->bindValue('morada', $morada, PDO::PARAM_STR);
$stmt->bindValue('num', $num, PDO::PARAM_INT);
$stmt->bindValue('mail', $mail, PDO::PARAM_STR);
$stmt->bindValue('ordeb', $ordeb, PDO::PARAM_STR);
$stmt->bindValue('dataI', $dataI, PDO::PARAM_STR);
$stmt->bindValue('dataF', $dataF, PDO::PARAM_STR);
$stmt->bindValue('notas1', $notas1, PDO::PARAM_STR);
$stmt->bindValue('notas2', $notas2, PDO::PARAM_STR);
$stmt->execute();
EDIT
I build your project on my computer, try to add
$error = $stmt->errorInfo();
print_r($error);
To see what's happen during your request.
On my side, I found a mismatch with the word ordeb and ordb
For example : $stmt->bindValue('ordb', $ordeb, PDO::PARAM_INT);
And can you check also the format of your date, it should be "Y-m-d H:i:s")
Note : All your columns in your table are of text type, text should be used only for long text (like in textarea), you should use varchar which allow you to save up to 255 characters (enough).

lastInsertId() returns NULL

i am trying to get the last id inserted in my sql query, but my varieble returns with NULL
here is my code
$conn->beginTransaction();
try{
$stmt=$conn->prepare("SELECT cn_id FROM food_category WHERE catname= :catname");
$stmt->bindParam(':catname', $_POST['catname'], PDO::PARAM_STR);
$stmt->execute();
$catres= $stmt->fetch(PDO::FETCH_ASSOC);
if(count($catres) > 0 ){
$cn_id= $catres['cn_id'];
}else{
$stmt1= $conn->prepare("INSERT INTO food_category (catname) VALUES (:catname)");
$stmt1->bindParam(':catname', $_POST['catname'], PDO::PARAM_STR);
$stmt1->execute();
$cn_id= $stmt1->lastInsertId();
}
$stmt2=$conn->prepare("SELECT cn_id FROM food_category_en WHERE catname= :catname_en");
$stmt2->bindParam(':catname_en', $_POST['catname_en'], PDO::PARAM_STR);
$stmt2->execute();
$catresen= $stmt2->fetch(PDO::FETCH_ASSOC);
if(count($catresen) > 0 ){
$cn_id_en= $catresen['cn_id'];
}else{
$stmt3= $conn->prepare("INSERT INTO food_category_en (catname) VALUES (:catname_en)");
$stmt3->bindParam(':catname_en', $_POST['catname_en'], PDO::PARAM_STR);
$stmt3->execute();
$cn_id_en= $stmt3->lastInsertId();
}
$stmt4=$conn->prepare("INSERT INTO food_category_main (st_id, cn_id, cn_id_en, catcount) VALUES (:st_id, :cn_id, :cn_id_en, :catcount)");
$stmt4->bindParam(':st_id', $_POST['st_id'], PDO::PARAM_INT);
$stmt4->bindParam(':cn_id', $cn_id, PDO::PARAM_INT);
$stmt4->bindParam(':cn_id_en', $cn_id_en, PDO::PARAM_INT);
$stmt4->bindParam(':catcount', $noc, PDO::PARAM_INT);
$stmt4->execute();
$stmt5=$conn->prepare("UPDATE magazia_main SET noc= :noc WHERE st_id= :st_id");
$stmt5->bindParam(':st_id', $_SESSION['st_id'], PDO::PARAM_INT);
$stmt5->bindParam(':noc', $noc, PDO::PARAM_INT);
$stmt5->execute();
$conn->commit();
header ("Location:dashboard.php?store=".$_SESSION['name']);
exit;
}catch(Exception $e){
//An exception has occured, which means that one of our database queries
//failed.
//Print out the error message.
echo $e->getMessage();
//Rollback the transaction.
$conn->rollBack();
}
I read in the php manual here that if am i using transaction the lastInsertId will return 0. As you see both lastInsertId (1st in stmt1, 2nd in stmt3) are before $conn->commit();, although they return with NULL.
cn_id in food_category and cn_id in food_category_en are both primary keys and AUTO_INCREMENT
i search for some solutions in the internet but none of them seems to fix my problem.
here is a printscreen from php my admin
*** connection to database****
$servername = "localhost";
$username = "root";
$password = "12345";
try {
$conn = new PDO("mysql:host=$servername;dbname=superdb; charset=utf8", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
Any ideas?
Thanks in advance
Vaggelis
After hours of searching, i didnt find the reason why lastInsertId() returns NULL. Anyway changed my code a little bit and now is working.
I removed the SELECT queries from transaction and i put them in the if statement which checks if the input has value. After that i made two if statements in the pdo transaction to check that if the value cn_id= 0 or cn_id_en= 0.
Here is my code now:
//check is inputs has value
if (empty($_POST['catname'])) {
$errors[] = 'Ξεχάσατε το όνομα της κατηγορίας!';
}else{
$stmt=$conn->prepare("SELECT cn_id FROM food_category WHERE catname= :catname");
$stmt->bindParam(':catname', $_POST['catname'], PDO::PARAM_STR);
$stmt->execute();
$catres= $stmt->fetch(PDO::FETCH_ASSOC);
if(count($catres) > 0 ){
$cn_id= $catres['cn_id'];
}else{
$cn_id=0;
}
}
if (empty($_POST['catname_en'])) {
$errors[] = 'Ξεχάσατε το όνομα της κατηγορίας στα Αγγλικά!';
}else{
$stmt2=$conn->prepare("SELECT cn_id FROM food_category_en WHERE catname= :catname_en");
$stmt2->bindParam(':catname_en', $_POST['catname_en'], PDO::PARAM_STR);
$stmt2->execute();
$catresen= $stmt2->fetch(PDO::FETCH_ASSOC);
if(count($catresen) > 0 ){
$cn_id_en= $catresen['cn_id'];
}else{
$cn_id_en=0;
}
}
if(empty($errors)){
//pdo trasaction
$conn->beginTransaction();
try{
if($cn_id == 0){
$stmt1= $conn->prepare("INSERT INTO food_category (catname) VALUES (:catname)");
$stmt1->bindParam(':catname', $_POST['catname'], PDO::PARAM_STR);
$stmt1->execute();
$cn_id= $conn->lastInsertId();
echo "id1=" . $cn_id;
}
if($cn_id_en == 0){
$stmt3= $conn->prepare("INSERT INTO food_category_en (catname) VALUES (:catname_en)");
$stmt3->bindParam(':catname_en', $_POST['catname_en'], PDO::PARAM_STR);
$stmt3->execute();
$cn_id_en= $conn->lastInsertId();
}
$stmt4=$conn->prepare("INSERT INTO food_category_main (st_id, cn_id, cn_id_en, catcount) VALUES (:st_id, :cn_id, :cn_id_en, :catcount)");
$stmt4->bindParam(':st_id', $_POST['st_id'], PDO::PARAM_INT);
$stmt4->bindParam(':cn_id', $cn_id, PDO::PARAM_INT);
$stmt4->bindParam(':cn_id_en', $cn_id_en, PDO::PARAM_INT);
$stmt4->bindParam(':catcount', $noc, PDO::PARAM_INT);
$stmt4->execute();
$stmt5=$conn->prepare("UPDATE magazia_main SET noc= :noc WHERE st_id= :st_id");
$stmt5->bindParam(':st_id', $_SESSION['st_id'], PDO::PARAM_INT);
$stmt5->bindParam(':noc', $noc, PDO::PARAM_INT);
$stmt5->execute();
$conn->commit();
header ("Location:dashboard.php?store=".$_SESSION['name']);
exit;
}catch(Exception $e){
//An exception has occured, which means that one of our database queries
//failed.
//Print out the error message.
echo $e->getMessage();
//Rollback the transaction.
$conn->rollBack();
}
i wont accept this as an answer for few days, in order to be seen from as many users is possible
Please replace $stmt1, $stmt3 with $conn your code is like this
$conn->beginTransaction();
try{
$stmt=$conn->prepare("SELECT cn_id FROM food_category WHERE catname= :catname");
$stmt->bindParam(':catname', $_POST['catname'], PDO::PARAM_STR);
$stmt->execute();
$catres= $stmt->fetch(PDO::FETCH_ASSOC);
if(count($catres) > 0 ){
$cn_id= $catres['cn_id'];
}else{
$stmt1= $conn->prepare("INSERT INTO food_category (catname) VALUES (:catname)");
$stmt1->bindParam(':catname', $_POST['catname'], PDO::PARAM_STR);
$stmt1->execute();
$cn_id= $conn->lastInsertId();
}
$stmt2=$conn->prepare("SELECT cn_id FROM food_category_en WHERE catname= :catname_en");
$stmt2->bindParam(':catname_en', $_POST['catname_en'], PDO::PARAM_STR);
$stmt2->execute();
$catresen= $stmt2->fetch(PDO::FETCH_ASSOC);
if(count($catresen) > 0 ){
$cn_id_en= $catresen['cn_id'];
}else{
$stmt3= $conn->prepare("INSERT INTO food_category_en (catname) VALUES (:catname_en)");
$stmt3->bindParam(':catname_en', $_POST['catname_en'], PDO::PARAM_STR);
$stmt3->execute();
$cn_id_en= $conn->lastInsertId();
}
$stmt4=$conn->prepare("INSERT INTO food_category_main (st_id, cn_id, cn_id_en, catcount) VALUES (:st_id, :cn_id, :cn_id_en, :catcount)");
$stmt4->bindParam(':st_id', $_POST['st_id'], PDO::PARAM_INT);
$stmt4->bindParam(':cn_id', $cn_id, PDO::PARAM_INT);
$stmt4->bindParam(':cn_id_en', $cn_id_en, PDO::PARAM_INT);
$stmt4->bindParam(':catcount', $noc, PDO::PARAM_INT);
$stmt4->execute();
$stmt5=$conn->prepare("UPDATE magazia_main SET noc= :noc WHERE st_id= :st_id");
$stmt5->bindParam(':st_id', $_SESSION['st_id'], PDO::PARAM_INT);
$stmt5->bindParam(':noc', $noc, PDO::PARAM_INT);
$stmt5->execute();
$conn->commit();
header ("Location:dashboard.php?store=".$_SESSION['name']);
exit;
}catch(Exception $e){
//An exception has occured, which means that one of our database queries
//failed.
//Print out the error message.
echo $e->getMessage();
//Rollback the transaction.
$conn->rollBack();
}
If you get by SQL query then
$stmt1 = $db->query("SELECT LAST_INSERT_ID()");
$lastId = $stmt1->fetchColumn();

Error in PHP PDO Prepared Statement

try
{
$stmt = $conn->prepare(" Update site_users SET users_first_name = :users_first_name, users_last_name = users_last_name
,users_email_verified = :users_email_verified , users_password = :users_password, users_dob_day = :users_dob_day, users_dob_month = :users_dob_month
,users_dob_year = :users_dob_year, users_password_1 = :users_password_1, users_registration_time= :users_registration_time
WHERE users_email = :users_email");
$stmt->bindParam(':users_first_name', $_POST["firstname"] , PDO::PARAM_STR);
$stmt->bindParam(':users_last_name', $_POST["lastname"] , PDO::PARAM_STR);
$stmt->bindParam(':users_email', $_POST["email"] , PDO::PARAM_STR);
$stmt->bindParam(':users_password', $hashed_password , PDO::PARAM_STR);
$stmt->bindParam(':users_password_1', $_POST["password"] , PDO::PARAM_STR);
$stmt->bindParam(':users_email_verified', $users_email_verified , PDO::PARAM_STR);
$stmt->bindParam(':users_dob_day', $_POST["day"], PDO::PARAM_STR);
$stmt->bindParam(':users_dob_month', $_POST["month"], PDO::PARAM_STR);
$stmt->bindParam(':users_dob_year', $_POST["year"], PDO::PARAM_STR);
$stmt->bindParam(':users_registration_time',$date, PDO::PARAM_STR);
$stmt->execute();
}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}
This is the error, the code echo
Error: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
Where is the problem in this code?
i think you are missing the : in your users_last_name = users_last_name query
probably it has to be users_last_name = :users_last_name

PDO insert only one record

I have been trying to overcome this problem for a while now and i need your help on this.
The code on the below only insert one record in mysql table and only one. Data from html forms are posted very well but it simple doesn't record more than once. I also use phpmyadmin and i don't know what is the problem. I'd be appriciated if you could help me.
Here is the code:
try {
$DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$STH1 = $DBH->query("SELECT isim, adet, kategori
FROM stock
WHERE isim = '$isim' AND kategori = '$kategori'");
$STH1->setFetchMode(PDO::FETCH_ASSOC);
if($STH1->rowCount() == 0) {
echo "There is no such record";
}
else {
$STH2 = $DBH->prepare("INSERT INTO outgoing
(isim, adet, nereye, cikis_tarih, kategori)
values
(:isim, :adet, :nereye, :cikis_tarih, :kategori)");
$STH2->bindParam(':isim', $isim, PDO::PARAM_STR);
$STH2->bindParam(':adet', $adet, PDO::PARAM_STR);
$STH2->bindParam(':nereye', $nereye, PDO::PARAM_STR);
$STH2->bindParam(':cikis_tarih', $cikis_tarih, PDO::PARAM_STR);
$STH2->bindParam(':kategori', $kategori, PDO::PARAM_STR);
$STH2->execute();
}
}
catch(PDOException $e) {
echo $e->getMessage();
}
?>
Instead of doing:
$STH2->bindParam(':isim', $isim, PDO::PARAM_STR);
$STH2->bindParam(':adet', $adet, PDO::PARAM_STR);
$STH2->bindParam(':nereye', $nereye, PDO::PARAM_STR);
$STH2->bindParam(':cikis_tarih', $cikis_tarih, PDO::PARAM_STR);
$STH2->bindParam(':kategori', $kategori, PDO::PARAM_STR);
$STH2->execute();
Execute it through an array:
$STH2->execute(array(':isim'=>$isim,
':adet'=>$adet,
':nereye'=>$nereye,
':cikis_tarih'=>$cikis_tarih,
':kategori'=>$kategori));

Invalid parameter number on PDO Prepared Statement

I'm working with a sequence of queries created with PDO class, in some case, my queries needs the same parameter.
I've created an array used in a foreach statement which save the data but some variables come from outside, can I use both data in one query?
the example:
// $connection is the PDO object;
// $full_data contains:
// $full_data[$i]["address"]
// $full_data[$i]["phone"]
// $full_data[$i]["email"]
// $full_data[$i]["user_id"]
// $full_data[$i]["surname"] // not used but present
// $full_data[$i]["name"] // not used but present
$sql = "UPDATE users_table SET city = :address, phone = :phone, email = :email, admin_id = :admin_id, admin_name = :admin_name WHERE user_id = :user_id";
$statement = $connection->prepare ($sql);
$statement->bindParam (':admin_id', trim($admin_id), PDO::PARAM_INT);
$statement->bindParam (':admin_name', trim($admin_name), PDO::PARAM_STR);
foreach ($full_data as $value) {
$ok = $statement->execute ($value);
$num = $statement->rowCount ();
}
} catch (PDOException $e) {
return $e->getMessage ();
}
this page return me the error:
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
what is exactly the problem, on an UPDATE statement the technique works
damn, I've found the problem after hours...
// $connection is the PDO object;
// $full_data contains:
// $full_data[$i]["address"]
// $full_data[$i]["phone"]
// $full_data[$i]["email"]
// $full_data[$i]["user_id"]
// ==> $full_data[$i]["surname"] // not used but present
// ==> $full_data[$i]["name"] // not used but present
the array data not saved in the query ["surname"] and ["name"] generate the error.
It seems like execute (); needs precise array data structure.
I've solved the problem by using this:
$sql = "UPDATE users_table SET city = :address, phone = :phone, email = :email, admin_id = :admin_id, admin_name = :admin_name WHERE user_id = :user_id";
$statement = $connection->prepare ($sql);
// must be removed ==> $statement->bindParam (':admin_id', trim($admin_id), PDO::PARAM_INT);
// must be removed ==> $statement->bindParam (':admin_name', trim($admin_name), PDO::PARAM_STR);
for ($i = 0; $i < count($full_data); $i++) {
$full_data[$i]["admin_name"] = "the admin name";
$full_data[$i]["admin_id"] = "100";
unset ($full_data[$i]["surname"]); // IMPORTANT: must remove the unused vars
unset ($full_data[$i]["name"]); // IMPORTANT: must remove the unused vars
}
foreach ($full_data as $value) {
// bindParam can be avoided, but it's recommended for data type security
$statement->bindParam(':address', trim($value['address']), PDO::PARAM_STR);
$statement->bindParam(':phone', trim($value['phone']), PDO::PARAM_STR);
$statement->bindParam(':email', trim($value['email']), PDO::PARAM_STR);
$statement->bindParam(':admin_id', trim($value['admin_id']), PDO::PARAM_INT);
$statement->bindParam(':admin_name', trim($value['admin_name']), PDO::PARAM_STR);
$ok = $statement->execute ($value);
$num = $statement->rowCount ();
}
} catch (PDOException $e) {
return $e->getMessage ();
}
You need to bind the :address, :phone, and :email parameters.
To elaborate on BD answer you're missing the following lines of code:
$statement->bindParam (':address', trim($address), PDO::PARAM_STR);
$statement->bindParam (':phone', trim($phone), PDO::PARAM_STR);
$statement->bindParam (':email', trim($email), PDO::PARAM_STR);
Plus, something seems to be wrong with your foreach loop, I think this is what you want:
$sql = "UPDATE users_table SET city = :address, phone = :phone, email = :email, admin_id = :admin_id, admin_name = :admin_name";
$statement = $connection->prepare($sql);
$statement->bindParam(':admin_id', trim($admin_id), PDO::PARAM_INT);
$statement->bindParam(':admin_name', trim($admin_name), PDO::PARAM_STR);
foreach ($full_data as $value)
{
$statement->bindParam(':address', trim($value['address']), PDO::PARAM_STR);
$statement->bindParam(':phone', trim($value['phone']), PDO::PARAM_STR);
$statement->bindParam(':email', trim($value['email']), PDO::PARAM_STR);
$ok = $statement->execute();
$num = $statement->rowCount();
}

Categories