কিভাবে php mysql coonection দিবেন

php mysql coonection দিতে হলে নিচের নিয়ম দেখুন : –
১.আলাদা html/php page খুলুন ।
২. তারপর নিচের code লিখুন।
৩.

<?php // start of php tag
$host = “localhost”; // local pc server host name
$user =”root”; // local pc user name normally root
$pass= “”; // if server password then put here
$db= “database name”;// database name goes here

// connection start here

$connection = mysql_connect(“$host,”user”,”$pass”) or die(“Unable to connect database”);

// select of database

mysql_select_db(“$db”) or die(“No database selected or there is no database in this name”);

?> // end of php tag

save করুন connection.php দিয়ে। এভাবে অাপনি mysql database connection দিতে পারেন । সুবিধা হল বেশি page এ connection দরকার হলে সমস্যা হয় না ।

একটা দিয়ে একাধিক page এ link করে দিলে হয়ে যায় বারবার code লিখতে হবে না। এভাবে link করতে হয়
// link in another page of mysql_database connection

<?php // start of php tag
include “connection.php”; // if the page is in different name include that name
?> // end of php tag
আশা করছি সবার কাজে লাগবে।
ধন্যবাদ ।

Leave a Comment