Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. <html>
  2.  <head>
  3.   <title>PasdfaHP Test</title>
  4.  </head>
  5.  <body>
  6.  
  7. <?php
  8. $link = mysql_connect('localhost:/tmp/mysql.sock', 'root', 'secret');
  9. if (!$link) {
  10.     die('Could not connect: ' . mysql_error());
  11. }
  12. echo 'Connected successfully';
  13.  
  14.  
  15. // make users the current db
  16. $db_selected = mysql_select_db('testdb', $link);
  17. if (!$db_selected) {
  18.     die ('\nCan\'t use users : ' . mysql_error());
  19. }
  20.  
  21. $id = '0001';
  22.  
  23. $query = sprintf("SELECT name FROM users WHERE id='%s'",mysql_real_escape_string($id));
  24.  
  25. $result = mysql_query($query);
  26.  
  27. while ($row = mysql_fetch_assoc($result)) {
  28.     echo $row['name'];
  29. }
  30.  
  31. mysql_free_result($result);
  32.  
  33. mysql_close($link);
  34. ?>
  35.  
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement