i've a little problem with the UPDATE statement. I've read some topics on stackoverflow and others websites but i can't figure out why I'm not able to update my row.
Actually i'm trying to build a little version of Reddit (just for practice) and this script has to change data inside a row (classic edit post page). Thats my code:
$topic_id = $_GET['id'];
if(isset($_POST["submit"])){
try {
include ('../script/db_connect.php');
$conn = new PDO("mysql:host=$db_servername;dbname=$db_name", $db_user, $db_pass);
$stmt = $conn->prepare("UPDATE topic SET title = :title, text = :text, category = :category WHERE id = :topic_id");
$utitle = $_POST["title"];
$utext = $_POST["myTextArea"];
$category = $_POST["xxx"];
$stmt->bindParam(':title', $utitle);
$stmt->bindParam(':text', $utext);
$stmt->bindParam(':category', $category);
$stmt->execute();
if($stmt){
$conn = null;
header("Location: ../index.php");
}
}
catch(PDOException $e){
echo "Error: " . $e->getMessage();
}
}
I don't have any errors so must be something with the update statement but i can't find what's the problem.
EDIT: Marked as duplicate by "Your Common Sense", what? Can you show me why and how this post is a "duplicate"?
I just cant figure out how resolve my problem and you just marked that as duplicate instead of help, ok.