Questions tagged as 'mysql'

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
1
answer

Adding MySQL + PHP Fields

I have the following code in which I need to add the value of a column (MySQL) and the result of this sum, subtract by any value, example: 5000 and the result of this operation be passed to the PHP page. p> My code: <?php $opcoes2...
asked by 06.09.2016 / 00:43
1
answer

How to print a string array on the screen?

How do I print this SQL query on the screen as a string? $current_user = wp_get_current_user(); $resultado = $wpdb->get_results( "SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$current_user->ID' AND meta_key = '_jm_candidat...
asked by 01.02.2017 / 18:29
2
answers

Error when trying to calculate in fields of the same table in update mysql

I have the following table: DROP TABLE IF EXISTS 'convenio'; CREATE TABLE 'convenio' ( 'codigo' int(8) DEFAULT NULL, 'cpf' varchar(11) NOT NULL DEFAULT '0', 'Nome' varchar(35) DEFAULT NULL, 'valor'...
asked by 24.01.2017 / 13:32
2
answers

Date being passed as NULL to the database

I have this structure: //Dia atual + i meses $data_pagamento = "DATE_ADD(CURRENT_TIMESTAMP,INTERVAL ".$i." MONTH)"; $sql = "INSERT INTO pagamento(fk_1, fk_2, fk_3, fk_4, fk_5, preco, data_do_pagamento) VALUES (?,?,?,?,?,?,?)"; $stmt = $db->...
asked by 17.10.2016 / 21:54
2
answers

Wordpress - How to include new fields in the user table?

I want to include the following fields in the register of registered users in my blog: IBGE, Municipality and UF. How do I include these fields and later access them on a specific page?     
asked by 19.10.2016 / 01:09
2
answers

Query MySql with PHP

I am making a query in MySql to return the quantity of requests that have not been delivered. To see the ones that have been delivered I do: $result = mysql_query("SELECT operacional FROM 'pedidos' WHERE 'status' = 'ENTREGA REALIZADA'");...
asked by 05.05.2017 / 16:26
2
answers

Make calculations based on PHP or MySQL averages

A friend created an Arduino project that monitors power consumption in Kw / h. It every 5 minutes inserts the consumption information in the MySQL database. Every 5 records I need to average them, and then take the average and multiply by 15....
asked by 29.03.2016 / 23:14
1
answer

Show occurrences as fields

I am making a query in the database, I would like to know if you can group elements and display them as if they were fields and within those fields the number of occurrences. ex: The table looks like this: nome_tarefa | data_criacao | sta...
asked by 08.03.2016 / 08:23