Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PHP JS cheat sheet
- =========== JS:
- var input = document.getElementById("inputVal").value;
- document.getElementById("").innerHTML = " " + String(input) ;
- ========= PHP
- include("");
- session_start();
- isset($_POST[''])
- unsset($_POST[''])
- $_SESSION['']
- $GLOBALS['']
- $_SESSION[''] = base64_encode(openssl_random_pseudo_bytes(32));
- ============= PHP mysqli
- == db login var:
- $dbIP =
- $dbName =
- $dbuser=
- $dbpass=
- == How query look like:
- $mysqli = new mysqli($GLOBALS['dbIP'],$GLOBALS['dbuser'], $GLOBALS['dbpass'], $GLOBALS['dbName']);
- $query = "";
- $mysqli->query($query);
- $mysqli->close();
- == while using update/insert/delete statment:
- $mysqli->affected_rows > 0
- == while using select:
- $query = "";
- $mysqli->query($query);
- $result->num_rows
- == While getting the first row match:
- (string)$result->fetch_row()[0];
- == print the hole answer:
- if($result = $mysqli->query($query)){
- while ($row = $result->fetch_assoc()) {
- printf ("(%s) %s </br>", $row["username"], $row["comment"] );
- }
- }
- ========================= Mysql managmanet:
- == user managment
- connecting to mysql:
- mysql -u <username> -p
- list all users in mysql server:
- select User FROM mysql.user;
- CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
- GRANT ALL PRIVILEGES ON <DB name>.<table name> TO
- '<user name>'@'localhost';
- DROP USER ‘demo’@‘localhost’;
- apply permission:
- FLUSH PRIVILEGES;
- ============ DB managment:
- show databases;
- show tables;
- create database <DB name> ;
- use <DB name>
- create table users ( <column name> varchar(lenth) );
- insert into users (<column name1>,<column name2> ) values (<data to column1>,<data to column2>);
- delete from <table name> where <column name> = ‘some value’ ;
- DROP database <database name> ;
- DROP table <table name> ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement