Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2. $username = "root";
  3. $password = "";
  4. $hostname = "localhost";
  5.  
  6. $user = $_GET['userid'];
  7.  
  8. //mb_internal_encoding("ISO-8859-1");
  9. //$string = "0123456789";
  10. //$mystring = mb_substr($string,0,mb_strlen($string));
  11. //echo $mystring;
  12.  
  13. //connection to the database
  14. $dbhandle = new PDO('mysql:host=localhost;dbname=book4book;', $username, $password,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
  15.  
  16. $sql = $dbhandle->prepare("select * from bookstogive where book_user_id = $user");
  17. //echo "\nPDO::errorInfo():\n";
  18. //print_r($dbhandle->errorInfo());
  19. $sql->execute();
  20. $results= $sql->fetchAll(PDO::FETCH_ASSOC);
  21. $json=json_encode($results);
  22.  
  23. //echo mb_substr($json,0,mb_strlen($json));;
  24. $iso88591_1 = utf8_decode($json);
  25. $iso88591_2 = iconv('UTF-8', 'ISO-8859-1', $json);
  26. $iso88591_2 = mb_convert_encoding($json, 'ISO-8859-1', 'UTF-8');
  27. echo $iso88591_2;
  28.  
  29. $sql->closeCursor();
  30. $sql = null;
  31. //$result = mysql_query($sql) or trigger_error(mysql_error()." in ".$sql);
  32.  
  33. //asdasdasd
  34. //close the connection
  35. $dbh = null;
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement