Also as your question has already been answered I'll give you a helping hand. There is a better alternative to mysqli being dpo, it's mainly better as it supports a variety of DBMS's but it is just better all-round comparatively to mysqli and in my opinion is more secure. Here is some code to connect to a database. So you should note that this same code would work with other databases so there is no need to change your code if there is a need to change to another DBMS/RDMS
define('DB_URL', 'mysql:host=$hostname;dbname=$dbname');
define('DB_USERNAME', $username);
define('DB_PASSWORD', $password);
$db = new PDO(DB_URL, DB_USERNAME, DB_PASSWORD);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
Also just a little helping hand for you:
function dp($something, $exit=true)
{
print('<pre>');
print_r($something);
print('</pre>');
if($exit){
exit;
}
}
that will help ALOT with debugging, whenever you need to know the value of a variable within your php, just put
dp($variable, false)
The false is optional, if you add it, then it will continue to load the page, if you leave it out the function will defult to true and it will not load the rest of the page after the dp.
Hope that helps some :)
Joel