I need help here…
For years I have been cobbling scripts together and making this or that with PHP and MySQL but this is like a once a year kinda thing and recently I have been judged for using the old mysql_ commands in my scripts. I am now trying to use the new PDO method and I am going bald with the concept. Just when something works it fails and miserably at that!! I could make this script in 15 minutes and implement it on my server too, if I was using the old methods. But to be able to learn I have updated my server to php7 and now I am going to learn this new method if it kills me. Alas here if where I need the help and I apologize in advance for my stupidity and lack of knowledge. I will try as I can to grasp all that is taught.
This script is going to be behind a secured directory in apache2 using .htaccess it receives sms messages from Twilio as they are sent to my numbers and then is supposed to just load the messages into MySQL well it doesnt work. I have been trying for the last week now and I am no further than I was a week ago.
[php]
$dbhost = “localhost”;
$dbname = “";
$dbusername = "*”;
$dbpassword = “******”;
$charset = “utf8”;
$link = new PDO(“mysql:host=$dbhost;dbname=$dbname;charset=$charset”, $dbusername, $dbpassword);
$statement = $link->prepare(“INSERT INTO sms_messages(MessageSid, SmsSid, AccountSid, MessagingServiceSid, From, To, Body, NumMedia, FromCity, FromState, FromZip, FromCountry, ToCity, ToState, ToZip, ToCountry)
VALUES(:MessageSid, :SmsSid, :AccountSid, :MessagingServiceSid, :From, :To, :Body, :NumMedia, :FromCity, :FromState, :FromZip, :FromCountry, :ToCity, :ToState, :ToZip, :ToCountry)”);
$statement->execute(array(
“MessageSid” => $_POST[“MessageSid”],
“SmsSid” => $_POST[“SmsSid”],
“AccountSid” => $_POST[“AccountSid”],
“MessagingServiceSid” => $_POST[“MessagingServiceSid”],
“From” => $_POST[“From”],
“To” => $_POST[“To”],
“Body” => “”.$body."",
“NumMedia” => $_POST[“NumMedia”],
“FromCity” => $_POST[“FromCity”],
“FromState” => $_POST[“FromState”],
“FromZip” => $_POST[“FromZip”],
“FromCountry” => $_POST[“FromCountry”],
“ToCity” => $_POST[“ToCity”],
“ToSate” => $_POST[“ToSate”],
“ToZip” => $_POST[“ToZip”],
“ToCountry” => $_POST[“ToCountry”]
));
$link = “”;
header(“content-type: text/xml”);
echo “<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n”;
?>
Send away the messages go into a black hole of darkness and cannot be seen!
[/php]
This is about the 100th iteration of this little guy. The back end when it receives the text from someone it POST to this php script.