• Skip to secondary menu
  • Skip to main content
  • Skip to primary sidebar
  • Home
  • Projects
  • Products
  • Themes
  • Tools
  • Request for Quote

Vengala Vinay

Having 9+ Years of Experience in Software Development

  • Home
  • WordPress
  • PHP
  • Codeigniter
  • Magento
  • Selenium
  • Server
Home » Connect to Mysqli database using PHP5

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

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

A little about the Author

Having 9+ Years of Experience in Software Development.
Expertised in Php Development, WordPress Custom Theme Development (From scratch using underscores or Genesis Framework or using any blank theme or Premium Theme), Custom Plugin Development. Hands on Experience on 3rd Party Php Extension like Chilkat, nSoftware.

Recent Posts

  • How to add share via email functionality after each item’s content using filters
  • How to modify the site generator meta tag using filters
  • How to use WordPress path utility functions to load external files and images
  • How to use hooks and add output content to page head
  • How to create a basic plugin in WordPress?

Copyright © 2025 · Vinay Vengala