Advertisement
Guest User

aafssdgdfgdd

a guest
Oct 23rd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. PHP JS cheat sheet
  2.  
  3. =========== JS:
  4. var input = document.getElementById("inputVal").value;
  5. document.getElementById("").innerHTML = " " + String(input) ;
  6.  
  7. ========= PHP
  8. include("");
  9. session_start();
  10. isset($_POST[''])
  11. unsset($_POST[''])
  12. $_SESSION['']
  13. $GLOBALS['']
  14.  
  15. $_SESSION[''] = base64_encode(openssl_random_pseudo_bytes(32));
  16.  
  17. ============= PHP mysqli
  18. == db login var:
  19. $dbIP =
  20. $dbName =
  21. $dbuser=
  22. $dbpass=
  23.  
  24. == How query look like:
  25. $mysqli = new mysqli($GLOBALS['dbIP'],$GLOBALS['dbuser'], $GLOBALS['dbpass'], $GLOBALS['dbName']);
  26. $query = "";
  27. $mysqli->query($query);
  28. $mysqli->close();
  29.  
  30.  
  31. == while using update/insert/delete statment:
  32. $mysqli->affected_rows > 0
  33.  
  34. == while using select:
  35. $query = "";
  36. $mysqli->query($query);
  37. $result->num_rows
  38.  
  39. == While getting the first row match:
  40. (string)$result->fetch_row()[0];
  41.  
  42. == print the hole answer:
  43. if($result = $mysqli->query($query)){
  44. while ($row = $result->fetch_assoc()) {
  45. printf ("(%s) %s </br>", $row["username"], $row["comment"] );
  46. }
  47. }
  48.  
  49. ========================= Mysql managmanet:
  50. == user managment
  51. connecting to mysql:
  52. mysql -u <username> -p
  53.  
  54. list all users in mysql server:
  55. select User FROM mysql.user;
  56.  
  57. CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
  58. GRANT ALL PRIVILEGES ON <DB name>.<table name> TO
  59. '<user name>'@'localhost';
  60. DROP USER ‘demo’@‘localhost’;
  61.  
  62. apply permission:
  63. FLUSH PRIVILEGES;
  64.  
  65.  
  66. ============ DB managment:
  67. show databases;
  68. show tables;
  69. create database <DB name> ;
  70. use <DB name>
  71. create table users ( <column name> varchar(lenth) );
  72. insert into users (<column name1>,<column name2> ) values (<data to column1>,<data to column2>);
  73. delete from <table name> where <column name> = ‘some value’ ;
  74. DROP database <database name> ;
  75. DROP table <table name> ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement