Advertisement
Guest User

XML convert

a guest
Jun 30th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2. $database_handle = mysql_connect('localhost', 'user', 'pass');
  3. if (!database_handle) {
  4. echo "Could not connect";
  5. }
  6.  
  7. $db_selected = mysql_select_db('connect_shout', $link);
  8. if (!$db_selected) {
  9. die ('Can\'t use foo : ' . mysql_error());
  10. }
  11. $target_path = "./";
  12. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  13. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  14. $x = simplexml_load_string(file_get_contents($target_path));
  15. $source = (string)$x->data->attributes()->source;
  16. $reply = (string)$x->data->attributes()->reply_to;
  17. $message = (string)$x->message;
  18. $sql = "INSERT INTO `shout_data` VALUES(NULL,'$source','$reply','$message');";
  19. mysql_query($sql) or die("There was an error uploading the file, please try again!");
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement