Questions tagged as 'pdo'

2
answers

Error in connection with bank using PDO

Error message:    Error: SQLSTATE [HY000] [2002] php_network_getaddresses: getaddrinfo   failed: This host is not known. code $db_name = 'db_name'; $hostname = 'mysql.hostinger.com.br'; $username = 'username'; $pas...
asked by 23.09.2016 / 02:15
1
answer

Invalid Data Source PDO PHP MySQL

I'm having problems with the PDO connection to the mysql database. Database_connection.php : <?php class Database_connection { private $db_host = "local"; private $db_name = "root"; private $db_user = "user...
asked by 05.09.2016 / 15:34
2
answers

How to select a field with MAX () + 1 and use in an INSERT?

I have the following code: $Position = $this->conn->prepare("SELECT MAX(OrderTask)+1 as OrderNew FROM tasks"); $Position->execute(); $newPosition = $Position->fetchAll(PDO::FETCH_NUM); $newPosition =...
asked by 06.09.2016 / 15:55
3
answers

PDO Paging - Fatal error: Out of memory

I'm doing a paging, but it's generating a memory error. Is there any way to optimize or fix the crash? Or is it on the same server? Note : php.ini is set to 512 in memory. if (!(isset($_GET['pagenum']))) { $pagenum = 1; } els...
asked by 12.11.2015 / 19:28
3
answers

Generate single random value with php

I need to generate a random value with letters and numbers in PHP, always starting with the letter A and having numbers and letters mixed with the value. It is referring to the "control code" field contained in this script: <?php requir...
asked by 23.04.2015 / 18:05
1
answer

Array to string conversion in

I'm trying to do an INSERT on a table but it is returning the following error:    Notice: Array to string conversion in C: \ xampp \ htdocs \ MOClient 3.0 \ modules \ products \ funPrivate.php on line 25 Code <?php include "../../lib...
asked by 18.12.2015 / 12:29
2
answers

SELECT with PDO and variable

How can I do a SELECT in MYSQL with PDO next to it below: $buscarNoticiaTitulo = "noticias.titulo LIKE '%teste%'"; $sqlNoticias = $pdo->prepare('SELECT * FROM noticias WHERE :buscarNoticiaTitulo'); $sqlNoticias->execute(array("buscarNoti...
asked by 25.02.2016 / 19:30
2
answers

I have doubts if this would be the correct way to make a connection using the class PDO

I'm wondering if this form is actually correct to make a connection between php and mysql with the class PDO. The question is this: Every time I have a file that uses this connection it will create a new connection Class PDOUtil { public stat...
asked by 08.12.2014 / 23:36
1
answer

Fatal error error: Uncaught Error: Call to undefined function getList ()

I need to reuse this function so that it uses fetchAll but also use num_rows, the problem is that if I do return fetchAll or num_rows it works, but in that case I would have to create two functions just for one to use fetch and another rows, bec...
asked by 12.03.2017 / 22:23
1
answer

How to solve "Call to a member function prepare ()"?

I'm finding the following error in the script below:    Fatal error: Call to a member function prepare () on null in C: \ wamp \ www \ cursophp \ object_address \ pdo_statement \ users.php on line 20 Code: class Usuarios { private $d...
asked by 19.09.2017 / 21:00