Connect to Mysqli database using PHP5
Connect to Mysqli database using PHP5, this is simple article for connecting to Mysqli database using PHP5. Here i’ll use two methods for connecting with mysqli database. One is procedural and the other one is object oriented. For the first one i’m using is mysqli_connect. And the next one is Object Oriented. Just pass the database login credentials mysqli_connect function.
Connect to Mysqli database using PHP5 in procedural method
Here in mysqli_connect, i’m passing all the values
- Host Name
- User Name
- Password
- Database Name
[php] $link = mysqli_connect("myhost","myuser","mypassw","mybd") or die("Error " . mysqli_error($link)); [/php]
Connect to Mysqli database using PHP5 in Object Oriented
Provide database host, database user name, database password and finally database name.
[php] $mysqli = new mysqli("myhost", "myuser", "mypassw", "mybd"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } [/php]
This is simple article for Connecting to Mysqli database using PHP5
Leave a Reply
You must be logged in to post a comment.