Everything posted by Wife
-
OMG This is crazy but it's for real
You can not run from the fact they are coming.
-
OMG This is crazy but it's for real
- PHP PDO Tutorial v2
No hell no. Beautiful syntax isn't always the best..- PHP PDO Tutorial for safe database queries - IN-DEPTH
Uh? PDO wraps strings automaticly.- PHP PDO Tutorial for safe database queries - IN-DEPTH
Formatting somehow messed up when correcting an error with phone.- PHP PDO Tutorial v2
Because I know the code itself works. There might be typos or such things like that. It's not that an tutorial is supposed to be something where your kind can ctrl-ca and ctrl-v- when you've had such a primo night that you're happy enough to sleep at 9pm
A sign. A sign of they are coming.- PHP PDO Tutorial v2
Hello, Okay, so in this tutorial we will be creating a dynamic PHP Script, that changes database values when the correct user agent is requesting your server, and creating another PHP file for fetching that data from the database. No fancy design here, if you are after that - stop reading. Part 1. What is User Agent? User agent is a software application 'agent' that performs tasks behalf of a user. We can use user agent for our PHP script only allowing requests from a certain user agent. Useful in cases for example dynamic signatures and other tasks that we want to apply automation on. Example of User Agent usage $ua_name = "FacialSlave"; //The name of expected user agent $ua = $_SERVER['HTTP_USER_AGENT']; if(!preg_match('/'.$ua_name.'/', ua)) { //Returns false if incorrect HTTP_REQUEST echo '<h1>Invalid user agent.</h1>'; } else if(isset($_GET['variable'])) { //If above returns true let's execute our statement defined somewhere. $statement->execute(); } Note! You need also to define the user agent from the other end of your application, in this we would be creating a dynamic script leaderboard, so you need to define the user agent from your Java files also, like this private static final String USER_AGENT = "FacialSlave"; Part 1.5 The Java side for this app The Java side not exactly what this guide is about, I'm just going to briefly talk this through. //Variables private static final String URL = "http://localhost/pdo_updateDatabase.php?"; private static final String USER_AGENT = "FacialSlave"; //Actual code public static void httpAgent(String var_str, int var_int) { String urlStr = URL + "variableOne=" + var_str + "&var_int=" + var_int; StringBulder http = new StringBuilder(); URL url; try { url = new URL(urlStr); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.addRequestProperty("User-Agent", USER_AGENT); BufferedReader brd = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; while((line = brd.readLine()) != null) { result.append(line); } brd.close(); } catch (Exception err) { } } Part 2. SET Query for updating data in database SET changes already existing data in database to new given values require 'pdo_dbConnection.php'; //UA CHECK ... Now if the user agent is correct, let's start executing our qery else if(isset($_GET['variableOne'] && $_GET['var_int'])) { //Query, where we set value of variableOne from Table where integerValue equals to given integer $query = 'UPDATE Table SET variableOne = :variableOne WHERE integerValue = :var_int'; //Preparing the query above $statement = $connection->prepare("$query"); //Executing statement as array, where we define placeholders for the query $statement->execute(array( ':variableOne' => $_GET['variableOne], ':var_int' => $_GET['var_int'] )); echo 'Updated successfully.'; } Part 2.5 Fetching data from our database Fetching data can be done in multiple ways, this is just one example of it. require 'pdo_dbConnection.php'; $query = 'SELECT * FROM Table'; //Query, * is a wildcard for selecting ALL fields from table. //Using * is not recommended in production environment. $statement = $connection->prepare($query); //And again, preparing the query for connection. $statement->execute(); //Executing statement. //Fetching data foreach($statement as $row) { echo ' <table style="width=250px"> <tr> <th>My Script</th> </tr> <tr> <td>Variable One: '.$row['variableOne'].'</td> <td>Variable Two: '.$row['variableTwo'].'</td> </tr> </table> '; } I have NOT tested the code above, just wrote it. If you face any errors with my code, please let me know and I will take a look at it. Because I do make often alot of easy typos etc.- Just a quick remainder
.. they are coming, what will you do?- PHP PDO Tutorial for safe database queries - IN-DEPTH
You are very welcome. I just corrected a mistake where I was trying to call the getMessage function from connection variable, where I was supposed to get it from the PDOException variable error.. Thanks- PHP PDO Tutorial for safe database queries - IN-DEPTH
Thanks. Appreciate this.- PHP PDO Tutorial for safe database queries - IN-DEPTH
Hello, So, because I am already being hated by many people I decided to give you something a little bit more productive this time. 1. The Basics What is PDO? PDO stands for PHP Data Objects which simply is a object based database library. One of the biggest advantages of PDO apart from it being very secure and light weight (when used correctly, of course) is the fact that it is a abstract level library for database methods and works pretty much widely on every well known database server. The library consists from bunch of classes containing methods and functions for database queries. Example of usage $statement = $connection->prepare($query);$statement->execute(); In PDO, when you are passing variables to query, they are defined AFTER preparing the query, while/or before executing it.Example of variables in PDO query $query = 'SELECT * FROM users WHERE username = :username'; //We use 'placeholders' :username is a placeholder$statement = $connection->prepare($query);$statement->execute(array(':username' => $username)); So, this way the variable - which can be assigned from HTTP_REQUEST or via static methods, is never passed directly to the query and helps us prevent error based SQL injection. Fetching data, data types //Fetching data as an array$result = $statement->fetch(PDO::FETCH_ASSOC);print_r($result);//Alternative, for looping all the results found for statementforeach($statement as $row) {echo '$row['data'];} //So here the result of $statement->execute is assigned as $row and data can be accessed using $row['datafield']; $row['datafield2'];//etc, based on your database table names.//Fetching data as object (I have to include this as we are talking about DATA OBJECTS$result = $statement->fetch(PDO::FETCH_OBJ);echo $result->username;echo $result->othervalue;//Ok so this is the object oriented method, where fetch returns an object where property names are assigned from result. It is also possible to return all the remaining values from data set by using fetchAll(); method. Usage defined above.You can see a complete list of PHP datatypes online. Establishing a database connection //Okay, this should be pretty straight forward. The connection is handled inside try{} and catch(){} blocks.try {//Variables for username and password$username = 'db_user';$password = 'db_password';//This creates a new PDO object for variable $connection. Connection details are//mysql:host, dbname, $username, $password$connection = new PDO('mysql:host=localhost;dbname=database_name', $username, $password);//Let's set the attribute errormode to pdo error mode exception for our catch() block.$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);} catch (PDOException $error) {//getMessage() us any possible errors with connecting, die(); is for killing the connection.$error->getMessage();$connection->die();} Part 2. Coming tomorrow, and then we will be actually creating something, a dynamic database SET query using USER_AGENT and then outputting the data.- TWC Club
Sir, let me remind you that we will provide you with each and everything (mostly everything) legal documents. We are a legit business.- TWC Club
- The Real TWC Club
Hello Mr. Orange, First I would like to say that I really appreciate that you took your personal time and effort as the acting leader of your organization "The Real TWC club". We are also actively looking for partners from all non-profit organizations that share the same interests we do. It is very important for us to unite, and spread the word and awareness about them coming. Looking forward to your reply, and have a nice psychosis. Thank you, Mr. Facial Acting secretary, The International They Will Come What Will You Do Organization 35455, Foil st. North Psychosis, United States of Legal Drugs (also illegal) info@titwcwwydo.org- TWC Club
They Will Come is now The International They Will Come What Will You Do -organization.- The Real TWC Club
It's seems like during the 3 days of my stay here, ez11 has already developed a trust issue towards me, so that kind of counts me in to your club. But I am still the manager and acting chairsman at the International They Will Come What Will You Do non-profit organization.- TWC Club
Absolutely sir, and I also work as a Certified Microsoft Technician, and my name is Bob Johnson, how may I help you? Your computer is it a dekstop or a laptop? There appears to be some Wiruses on your PC that are trying to hack your ip.- TWC Club
Can someone design a logo for our club. They logo should say They Will Come or TWC.- TWC Club
What is that? How can I get something that is in future form of time? They Will come- TWC Club
This is the official thread for the They Will Come -club If you want to join, please sign this page by posting anything. We are ready when They come and we will laugh to all non-believers.- I cry everytime
- What are you going to do when they come?
Let's go.- What are you going to do when they come?
Okay, since it's clear that they actually are coming I decided to make a thread, where we can have serious discussion about them, and share tips and tops about what to do, when they come. I know they are coming, because they told me so in a message they sent to my foil hat with antenna extension. I've also prepared by building a dugout in nearby forest. I am going to fight them off as long as I can, until the last dying breath. The question that lies here is what are you going to do when they come?- Post your desktop
- PHP PDO Tutorial v2
Account
Navigation
Search
Configure browser push notifications
Chrome (Android)
- Tap the lock icon next to the address bar.
- Tap Permissions → Notifications.
- Adjust your preference.
Chrome (Desktop)
- Click the padlock icon in the address bar.
- Select Site settings.
- Find Notifications and adjust your preference.
Safari (iOS 16.4+)
- Ensure the site is installed via Add to Home Screen.
- Open Settings App → Notifications.
- Find your app name and adjust your preference.
Safari (macOS)
- Go to Safari → Preferences.
- Click the Websites tab.
- Select Notifications in the sidebar.
- Find this website and adjust your preference.
Edge (Android)
- Tap the lock icon next to the address bar.
- Tap Permissions.
- Find Notifications and adjust your preference.
Edge (Desktop)
- Click the padlock icon in the address bar.
- Click Permissions for this site.
- Find Notifications and adjust your preference.
Firefox (Android)
- Go to Settings → Site permissions.
- Tap Notifications.
- Find this site in the list and adjust your preference.
Firefox (Desktop)
- Open Firefox Settings.
- Search for Notifications.
- Find this site in the list and adjust your preference.