Not inserting to table???

You do realize that the problem is in chapterpdo5.php right?Its not in the code you are trying to alter.
That part works great. But the problem is in the insert query I posted in a previous response in this thread.

Inserting into 1 column works but inserting into 2 columns does not work. If you would revise the code of the insert query i posted before, it would help me lots. thanks

ya but you are not getting the crdentials to insert right

that is where the credentials start right

I rewrote chapterpdo5.php to this and it still won’t insert:
[php]

<?php session_start(); try { $conn = new PDO("mysql:dbname=xxx;host=xxx", "xxx", "xxx" ); $sql = $conn->prepare("INSERT INTO Messages (From, Message) VALUES (?, ?)"); $sql->execute(array($_POST['message'], "Hello")); $conn = null; $_SESSION["messagesuccess"] = "Message Sent" . $userid . $_SESSION["id"] . $_POST['message']; } catch(PDOException $e) { echo $e->getMessage(); $conn = null; } ?>

[/php]

There is no isset() function anymore and this above code still doesnt insert. Whats wrong? thanks

I took out mostly everything out of the script exept for the insert query part:

[php]

<?php session_start(); try { $conn = new PDO("mysql:dbname=db440754197;host=db440754197.db.1and1.com", "dbo440754197", "dontbackbite" ); $sql = $conn->prepare("INSERT INTO Messages (Message) VALUES (?)"); $sql->execute(array($_POST['message'])); $conn = null; $_SESSION["messagesuccess"] = "Message Sent" . $userid . $_SESSION["id"] . $_POST['message']; } catch(PDOException $e) { echo $e->getMessage(); $conn = null; } ?>

[/php]
and unfortunately it still doesnt work…

Sponsor our Newsletter | Privacy Policy | Terms of Service