Questions tagged as 'pdo'

1
answer

Error handling PHP PDO

In PHP, how do you make the PDO not issue FATAL error so that it is possible to identify and handle the error that occurred? Example: Table: tb_pedidos: id fk_products qtd 1 5 5 2 7 2 3 2 13 Table: tb_products id description 5 Manga 7 Grap...
asked by 10.01.2017 / 21:20
2
answers

How to insert all array values and avoid $ query-execute () at every execution of foreach?

How to insert all array values and avoid $query->execute() with each foreach execution? $_POST = json_decode(file_get_contents('php://input'), true); $sql = "INSERT INTO teste(nome, email) VALUES (:nome, :email)"; try{ $query=...
asked by 30.12.2016 / 16:36
1
answer

Which correct way to do UPDATE

Friends this error ( SQLSTATE[HY093]: Invalid parameter number: parameter was not defined ), what is the correct way to apply UPDATE according to the code below? DB fields id_seguradora nome_seguradora cnpj_seguradora tel_segurado...
asked by 14.01.2017 / 15:53
1
answer

PHP Error returning function

I have the following class with the methods: <? class minhaClasse extends database { public function funcao ($iduser) { $date = array($iduser, '1'); $sql = "SELECT * FROM 'tabela' WHERE 'iduser' = ? AND 'princ' = ? ";...
asked by 16.12.2015 / 13:45
1
answer

Infinite Loop, object orientation

Stack Overflow . Stack Overflow I have a function to list all tickets for the user who is logged in: public function list_ticket() { try { $session = $_SESSION[SESSION_PREFIX . 'email_username']; $sql =...
asked by 04.02.2016 / 19:39
1
answer

How to connect PHP with SQLServer via PDO

I'm using the following code: try { $con = new PDO("sqlsrv:Server=172.20.21.193,9090;Database=sgt","deb","123123"); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die ("Erro na co...
asked by 07.07.2015 / 19:31
1
answer

How to present the error coming from MySQL?

I made the code below, and it works perfectly, but if MySQL returns an error, how will I know? I have no idea, can anyone help me? The message should return in alert , however I was able to create alert of Sucesso , howe...
asked by 30.07.2015 / 03:21
1
answer

Charset Mysql and PHP

My table in mysql has UTF-8 formatting and all accents appear correctly, but when I make the request with PHP and display the data they do not appear in UTF-8 format. p.s: My page already has the goal for utf-8. Do you know what might be c...
asked by 05.08.2015 / 16:25
1
answer

Error making a dynamic insert in PHP

The code that is causing the error: public function Inserir($tabela,$sql){ ksort($sql); $Campos_nome= implode('', '', array_keys($sql)); $Campos_valor= ': '. implode(', :', array_keys($sql)); $novo=$this->prepare("INSERT...
asked by 28.05.2014 / 11:18
2
answers

Is it possible to manipulate SESSION variables to perform SQL Injection?

I am not a cyber attack specialist and I have a small question about the safety of my projects. Basically one of the ways I'm warned of SQL injections is by creating a " treatString () " function, for example, and all data coming in externally I...
asked by 24.07.2018 / 17:28