+ 1

Why it's not working?

<?php include_once("../conexao.php"); include_once("../check_session.php"); $username = $_SESSION["username"]; $profileimage = $username.'.png'; //var $conexao_pdo $sql1 = "SELECT * FROM user WHERE username = :usr"; //db column and value $stmt1 = $conexao_pdo->prepare($sql1); //where clause $stmt1->bindParam(':usr', $username); $stmt1->execute(); while ($linha = $stmt1->fetch(PDO::FETCH_OBJ)) { //echo $linha->name . ' - ' . $linha->email; $col_name = $linha->name; $col_surname = $linha->surname; $col_description = $linha->description; } $stringsize = strlen($_POST['profiledescription']); if(empty($_POST['loginname'])){$name = $col_name; } else { $name = $_POST['loginname']; } if(empty($_POST['loginsurname'])){$surname = $col_surname; } else { $surname = $_POST['loginsurname']; } if(!empty($_POST['profiledescription']&&($stringsize <= 150))){$description = $_POST['profiledescription']; } else { $description = $col_description; } //UPDATE PDO EXAMPLE $sql = "UPDATE user SET name = :name, surname = :surname, description = :description WHERE username = :username"; //db column and value $stmt = $conexao_pdo->prepare($sql); //where clause $stmt->bindParam(':username', $username); //add vars to db $stmt->bindParam(':name', $name); $stmt->bindParam(':surname', $surname); $stmt->bindParam(':description', $description); $stmt->execute(); //sucess echo "<span style='color: green;' class='fa fa-check fa-3x' aria-hidden='true'></span> "; ?>

19th Apr 2017, 2:02 AM
Otávio Barreto
Otávio Barreto - avatar
5 Réponses
+ 1
I solve the problem guys it was a nomenclature error by a single letter of a db column
21st Apr 2017, 3:16 AM
Otávio Barreto
Otávio Barreto - avatar
+ 4
May be transaction? Is autocommit in your setting.
19th Apr 2017, 2:49 PM
shaldem
shaldem - avatar
+ 2
Hm, and where is a connection to db? Whats error do you have?
19th Apr 2017, 4:49 AM
shaldem
shaldem - avatar
+ 1
Sorry sololearn don't allow post all code , I will edit to be more clean
19th Apr 2017, 1:59 AM
Otávio Barreto
Otávio Barreto - avatar
+ 1
i dont have any error, pdo is not saving into db. the conection is ok , the query is right i dont know why its not working.
19th Apr 2017, 2:41 PM
Otávio Barreto
Otávio Barreto - avatar