Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. Notice: Undefined variable: conn in C:wampwwwphpfunctions.php on line 9
  2. Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:wampwwwphpfunctions.php on line 9
  3. Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:wampwwwphpfunctions.php on line 10
  4.  
  5. <?php
  6. session_start();
  7.  
  8. require_once 'connect.php';
  9. include 'functions.php';
  10.  
  11. getData();
  12. ?>
  13.  
  14. <?php
  15. $servername = "localhost";
  16. $username = "username";
  17. $password = "password";
  18.  
  19. $conn = mysqli_connect("$servername","$username","$password") or die ("could not connect to mysql");
  20.  
  21. mysqli_select_db($conn,"php") or die ("Database not found.");
  22.  
  23. function kill(){
  24. mysqli_close($conn);
  25. header('Location:/login');
  26. }
  27. ?>
  28.  
  29. <?php
  30.  
  31. require_once 'connect.php';
  32.  
  33. function getData() {
  34. if(isset($_SESSION['username'])){
  35. $username = $_SESSION['username'];
  36. $query = "SELECT first_name FROM users WHERE user_name = '$username'";
  37. $result = mysqli_query($conn, $query);
  38. $userdata=mysqli_fetch_array($result);
  39. echo $userdata["first_name"];
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement