Guest User

Untitled

a guest
Oct 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. require_once('connection.php');
  5. $con = getConnection();
  6.  
  7. $sql = "SELECT CONN, USER, PWD FROM USUARIO WHERE EMAIL = ?";
  8. $stmt = $con->prepare($sql);
  9. $stmt->bindValue(1, $_SESSION['email']);
  10. $stmt->execute();
  11.  
  12. while ($row = $stmt->fetch(PDO::FETCH_ASSOC))
  13. {
  14. $dsnUser = $row["CONN"];
  15. $userUser = $row["USER"];
  16. $pwdUser = $row["PWD"];
  17. }
  18.  
  19. function getConnectionUsr(){
  20. try {
  21. $conn = new PDO("'".$dsnUser."'", $userUser, $pwdUser);
  22. return $conn;
  23. }
  24. catch(PDOException $Exception) {
  25. echo $Exception->getMessage();
  26. return null;
  27. }
  28. }
  29.  
  30. function closeConnectionUsr() {
  31. return null;
  32. }
  33. ?>
  34.  
  35. <?php
  36.  
  37. require_once("connUser.php");
  38.  
  39. $con = getConnectionUsr();
  40.  
  41. if (isset($_REQUEST['cod-sql']))
  42. {
  43. $codAplly = $_REQUEST["cod-sql"];
  44.  
  45. $sql = $codAplly;
  46. $stmt = $con->prepare($sql);
  47.  
  48. try {
  49. $stmt->execute();
  50. header ("location: ../../criacao.php");
  51. }
  52. catch(PDOException $e)
  53. {
  54. echo "Deu ruim!!";
  55. }
  56. finally
  57. {
  58. $con = closeConnectionUsr();
  59. }
  60. }
  61. else{
  62. echo ">:(";
  63. }
  64. ?>
  65.  
  66. invalid data source name
  67. Fatal error: Call to a member function prepare() on null
Add Comment
Please, Sign In to add comment