Topic: Connecting from MYSQL Database to MYSQLi(OOP, Procedural) and PDO using PHP (Read 654 times)

02-20-18 02:28 PM
  • Posts: 2
  • Thanked: 1
  • Reputation: 0
magandang araw mga boss. Share q lg ang ibat-ibang ways sa pag connect ng MYSQL database to PHP in different ways tolad ng MYSQLi OO at Procedural, and PDO Version.

Using MYSQLi Procedural:
Code: [You are not allowed to view links. Register or Login]
<?php
$server 
"localhost";
$username "root";
$password "";
 
// Create connection
$conn mysqli_connect($server$username$password);
 
// Check connection
if (!$conn) {
die(
"Connecting to database failed: " mysqli_connect_error());
}
echo 
"Connected successfully";
?>

using MYSQLi OOP:
Code: [You are not allowed to view links. Register or Login]
<?php
$server 
"localhost";
$username "root";
$password "";
 
// Create connection
$conn = new mysqli($server$username$password);
 
// Check connection
if ($conn->connect_error) {
die(
"Connecting to database failed: " $conn->connect_error);
}
echo 
"Connected successfully";
?>

Using PDO:
Code: [You are not allowed to view links. Register or Login]
<?php
$server 
"localhost";
$username "root";
$password "";
 
// Create connection
$conn mysqli_connect($server$username$password);
 
// Check connection
if (!$conn) {
die(
"Connecting to database failed: " mysqli_connect_error());
}
echo 
"Connected successfully";
?>

Sana my ma totonan kayu. Kng my katanungan wag mahiyang magtanong kng my right med ba kau. hahahaha
For more FREE Source Code and Tutorials available from a different platform. please feel free to visit my Website: [You are not allowed to view links. Register or Login].
We also offer FREE Source code of different kinds of software in any programming languages such as VB.NEt, Visual B

02-23-18 11:45 AM
skynet
Full Member
  • Posts: 455
  • Thanked: 85
  • Reputation: 1
Thank you dito sir, malaking tulong po ito, keep sharing :)
Visit Me [You are not allowed to view links. Register or Login]
vb6, c#, vb.net Software Developer
PM me your projects

10-01-18 04:00 PM
xinrlt
Semi-Newbie
  • Posts: 36
  • Thanked: 1
  • Reputation: 0