I am receiving vars from AS3 via php script and inserting into db. all the vars are being passed as you can see in the address bar .. ( which i would like to hide from public but dont know how) .. I then get the vars and insert to db table. all tables are set ok i think. I am catching the vars also for an echo. all vars working but “image_name” and its not translating to the $tmp_name for the echo either. Any ideas on this one ..
Here is the line in browser holding the vars.
http://xx.xxx.xx.xxx/wordpress/?page_id=81imageName=WhitetailJackalope%2Epng&imageURL=http%3A%2F%2Flocalhost%2Fxxx%2Fxxx%2FserverImages%2FwhiteTailJackalopeEgg%2Epng&imageID=40
here is the PHP
<?php
$tmp_id=$_GET['imageID'];
$tmp_url=$_GET['imageURL'];
$tmp_name=$_GET['imageName'];
mysql_connect("localhost", "xxx", "xxx") or die(mysql_error());
mysql_query ( "INSERT INTO wp_image_data (`image_id`, `image_url`, `user_name`, `image_name`, `stage`)
VALUES ('$tmp_id' , '$tmp_url' , '$current_user->user_login' , '$tmp_name' , 1)");
echo 'Testing: ' . $tmp_id . '<br/>'; //displays ok
echo 'Image: ' . $tmp_name . '<br/>'; //does not display or insert to table
echo 'Owner: ' . $current_user->user_login . '<br/>'; //displays ok
?>
The table in the db for the image_name is VARCHAR(100) utf8_ganeral_ci
Any ideas ?
I have restructured the php as advised with the PDO format which seems to be good for me. Thank you for that information 🙂
Here is the restructured code. It works fine except for the image_name which i need to figure how to restructure my url now in wordpress.
try {
$conn = new PDO("mysql:host=$hostdb; dbname=$namedb", $userdb, $passdb);
$conn->exec("SET CHARACTER SET utf8");
$sql = "INSERT INTO wp_image_data (image_id, image_url, user_name, image_name, stage)
VALUES ('$tmp_id', '$tmp_url', '{$current_user->user_login}', '$tmp_name', '1')";
$q = $conn->exec($sql);
$conn = null;
}
catch(PDOException $e) {
echo $e->getMessage();
}
echo 'Testing: ' . $tmp_id . '<br/>';
echo 'Image: ' . $tmp_name . '<br/>';
echo 'Owner: ' . $current_user->user_login . '<br/>';
Now to work on the url … YAY and while im doing that is there a way to hide the passed variables in the address bar ?
Your URL needs reconstructed to include an ampersand after the page_id value:
http://xx.xxx.xx.xxx/wordpress/?page_id=81&imageName=WhitetailJackalope%2Epng&imageURL=http%3A%2F%2Flocalhost%2Fxxx%2Fxxx%2FserverImages%2FwhiteTailJackalopeEgg%2Epng&imageID=40