All In One Script
MENU

What is the difference between public, private, and protected?

by 3:39:00 AM
undefined
What is the difference between public, private, and protected? When and why should I use public, private, and protected functions and variables inside a class? What is the difference between them? Examples: // Public public $variable; public function doSomething() { // ... } // Private private $variable; private function doSomething() { // ... } // Protected protected $variable; protected function doSomething() { // ... } Solution :  You use: public scope to make that variable/function available from anywhere, other classes and instances of the object. private scope when you

mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 to be resource or mysqli_result, boolean given

by 3:10:00 AM
undefined
mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 to be resource or mysqli_result, boolean given I am trying to select data from a MySQL table, but I get one of the following error messages:        mysql_fetch_array() expects parameter 1 to be resource, boolean given or        mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given This is my code: $username = $_POST['username']; $password = $_POST['password']; $result = mysql_query('SELECT * FROM Users WHERE UserName LIKE $username'); while($row = mysql_fetch_array($result)) { echo $row['FirstName']; } The same applies to

UTF-8 all the way through

by 3:00:00 AM
undefined
UTF-8 all the way through I'm setting up a new server, and want to support UTF-8 fully in my web application. I have tried in the past on existing servers and always seem to end up having to fall back to ISO-8859-1. Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL and PHP to do this - is there some standard checklist I can follow, or perhaps troubleshoot where the mismatches occur? This is

Why shouldn't I use mysql_* functions in PHP?

by 2:49:00 AM
undefined
Why shouldn't I use mysql_* functions in PHP? What are the technical reasons for why one shouldn't use mysql_* functions? (e.g. mysql_query(), mysql_connect() or mysql_real_escape_string())? Why should I use something else even if they work on my site? Answer: The MySQL extension: Is not under active development Is officially deprecated as of PHP 5.5 (released June 2013). Has been removed entirely as of PHP 7.0 (released December 2015) Lacks an OO interface Doesn't support: Non-blocking, asynchronous queries Prepared statements or parameterized queries Stored procedures Multiple Statements Transactions The "new" password authentication method (on by default in MySQL 5.6; required in

Instagram