0

Are there differences in how Google App Engine handles PHP and MySQL? I am trying to port an extremely simple application from GoDaddy to Google App Engine and Google Cloud SQL. I've spent 2 days reading, trying, recoding and I cannot figure this out. Each time I trigger the PHP file instead of creating 1 record in 2 different tables as it should, it creates 2 records in each table with null values for some columns (that should absolutely not be allowed null values).

It worked flawlessly on GoDaddy, and has extraneous record creations on Google Cloud SQL?

<?php
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$servername = "ipinfo";
$dbconn = new PDO('mysql:unix_socket=/cloudsql/connectinfo',
'root',  // username
''       // password
);

$phone = $_REQUEST['From'];
$message = addslashes($_REQUEST['Body']);

$convoSQL = "SELECT id FROM smsConversation WHERE phone=$phone AND closed='0' order by timestamp desc;";
$info = $dbconn->query($convoSQL);
foreach ($info as $row) {
    $openConversation = $row['id'];
}
if($row == false){
$newConvoQuery = "INSERT INTO smsConversation (phone) values ('$phone');";
$dbconn->query($newConvoQuery);
$openConversation = $dbconn->lastInsertId();;
}
$sql = "INSERT INTO smsMessage (phone,message,conversation_id) values ('$phone','$message','$openConversation');";
$dbconn->exec($sql);
echo "<Response>";
echo '<Sms to="+mynumber">You have a new text from ' . $phone . ' saying ' .     $message . '</Sms>';
echo "</Response>";
  • How are you triggering the file? I guess you're hitting it twice unintentionally - a request for favicon.ico being mapped to it as well maybe? – Greg Mar 07 '15 at 20:01
  • Yes you need to show your app.yaml file. – Stuart Langley Mar 07 '15 at 20:14
  • Thank you! It was the favicon.ico file. http://stackoverflow.com/questions/887328/favicon-ico-not-found-error-in-app-engine I changed the yaml to include it, and uploaded one. Thank you very much for your help with my first Google App Engine App. – Tyler Whitesides Mar 07 '15 at 20:44

0 Answers0