PHP MYSQL : Connection

Example code on how to connect PHP in MYSQL Server.

<?php

// variables
$user = "localhost";
$username = "root";
$password = "password";

// connect to database
$db = new mysqli($user,$username,$password);
$db->select_db('your_databse');
        if (mysqli_connect_errno()) {
                die( "Connection failed..." );
        }

?>

PHP MYSQL : Connection
PHP MYSQL : Insert
PHP MYSQL : Select
PHP MYSQL : Update
PHP MYSQL : Delete


1 comments:

lhex pineda said...

hello! i'm lhex, and i'm a programming student.. i'm now working with a thesis.. but i'm having a hard time figuring out what's wrong with my code..