বুধবার, ৩১ ডিসেম্বর, ২০১৪

File Upload by angular and php


We are going to upload file by angular and php

Step 1: First of all we need to add a few file in our header section.


<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/1.6.1/angular-file-upload-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/1.6.1/angular-file-upload.js"></script>


Step 2: and then add the following html in your body section.


<div ng-app="_cars_app">
  <div ng-controller="MyCtrl">
  <input type="text" ng-model="test"/>
<input type="file" ng-model="fname" name="image" id="image" ng-file-select="onFileSelect($files)">
   <br/>
 <span class="errorMsg">---{{ message }}----</span>
</div>
</div>

Step 3: Write js code before the html. Basically this code is used for upload request

<script>
//inject angular file upload directives and service.
//inject angular file upload directives and service.
angular.module('_cars_app', ['angularFileUpload']);

var MyCtrl = ['$scope', '$upload', function($scope, $upload) {
  $scope.onFileSelect = function($files) {
   var file = $files[0];

   console.log(file.type.indexOf('image'));

   if (file.type.indexOf('image') == -1) {
        $scope.error = 'image extension not allowed, please choose a JPEG or PNG file.'          
   }
   if (file.size > 2097152){
        $scope.error ='File size cannot exceed 2 MB';
   }
 
   //console.log($scope.fname);
   $scope.upload = $upload.upload({
       url: "upload.php",
       data: {fname: $scope.fname},
       method: 'POST',
       file: file
     }).success(function(data, status, headers, config) {
        $scope.message = data;
     }).error(function(data, status) {
           $scope.message = data;
     });
    }
}];
</script>


Step 4:
Create a file which called upload.php and peste the following code inside the file.

<?php

$fname = $_POST["fname"];

    if(isset($_FILES['file'])){
        //The error validation could be done on the javascript client side.
        $errors= array();      
        $file_name = time(). $_FILES['file']['name'];
        print time(). $file_name;
        $file_size =$_FILES['file']['size'];
        $file_tmp =$_FILES['file']['tmp_name'];
        $file_type=$_FILES['file']['type'];
        $file_ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
        $extensions = array("jpeg","jpg","png");      
        if(in_array($file_ext,$extensions )=== false){
         $errors[]="file extension not allowed, please choose a JPEG or PNG file.";
        }
        if($file_size > 2097152){
        $errors[]='File size cannot exceed 2 MB';
        }            
        if(empty($errors)==true){
            move_uploaded_file($file_tmp,"images/".$file_name);
           // echo $fname . " uploaded file: " . "images/" . $file_name;
        }else{
            print_r($errors);
        }
    }


?>


Step -5: Let's review your code.

<!DOCTYPE html>
<html>

<head>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.10/angular-route.min.js"></script>
<script src="js/angular-file-upload-shim.min.js"></script>
<script src="js/angular-file-upload.js"></script>
<script>
//inject angular file upload directives and service.
//inject angular file upload directives and service.
angular.module('_cars_app', ['angularFileUpload']);

var MyCtrl = ['$scope', '$upload', function($scope, $upload) {
  $scope.onFileSelect = function($files) {
   var file = $files[0];

   console.log(file.type.indexOf('image'));

   if (file.type.indexOf('image') == -1) {
        $scope.error = 'image extension not allowed, please choose a JPEG or PNG file.'          
   }
   if (file.size > 2097152){
        $scope.error ='File size cannot exceed 2 MB';
   }
   alert(23);
   //console.log($scope.fname);
   $scope.upload = $upload.upload({
       url: "upload.php",
       data: {fname: $scope.fname},
       method: 'POST',
       file: file
     }).success(function(data, status, headers, config) {
        $scope.message = data;
     }).error(function(data, status) {
           $scope.message = data;
     });
    }
}];
</script>
</head>
<body>
<div ng-app="_cars_app">
  <div ng-controller="MyCtrl">
  <input type="text" ng-model="test"/>
<input type="file" ng-model="fname" name="image" id="image" ng-file-select="onFileSelect($files)">
   <br/>
 <span class="errorMsg">---{{ message }}----</span>
</div>
</div>
</body>
</html>



That's it. Thanks for reading this code.


মঙ্গলবার, ১৮ নভেম্বর, ২০১৪

Install skype on ubuntu 14.04 64bit

Hi everyone. Today we'r going to install skype on ubuntu14.04 64bit. Just follow the step below to install.

Step 1: Remove previous version.

sudo apt-get remove skype skype-bin:i386 skype:i386
sudo apt-get install sni-qt:i386

It is Important if you installed older version of Skype on your Ubuntu, Clear the old Skype folder before installing latest version. Then clear that by using:

rm -rf ~/.Skype

Step 2: Preparing to Installing Skype.

  • Users of 64-bit Ubuntu, should enable MultiArch if it isn't already enabled by running the command
    sudo dpkg --add-architecture i386
    
  • Update repositories and "updates" list:
    sudo apt-get update
    sudo apt-get install gdebi #(read Why you need to install gdebi...)
    

Step 3: Installing Skype

wget download.skype.com/linux/skype-ubuntu-precise_4.3.0.37-1_i386.deb
sudo gdebi skype-ubuntu-precise_4.3.0.37-1_i386.deb

Step 4: Link skype to user bin

LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu/ /usr/bin/skype


That's it. Enjoy your  skype. Thanks for your patient reading.

Why does Skype not start when I click the Skype Launcher?

If you installed skype on ubuntu, but can't be able to open it. Then you'r in right place to fix this problem. Just open your terminal and play this following command.


LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu/ /usr/bin/skype


That's it. 

বুধবার, ১৭ সেপ্টেম্বর, ২০১৪

Customize 404, 500, 503 error page on symfony

All of the error templates live inside TwigBundle. To override the templates, we simply rely on the standard method for overriding templates that live inside a bundle.

All of the error template you'll find on TwigBundle. To see the full list of default error templates, see the Resources/views/Exception directory of the TwigBundle. In a standard Symfony2 installation, the TwigBundle can be found at vendor/symfony/src/Symfony/Bundle/TwigBundle. Often, the easiest way to customize an error page is to copy it from the TwigBundle into app/Resources/TwigBundle/views/Exception and then modify it.


In your error500.html.twig page

<h1>Oops, you've found a dead link.</h1>
<h2>{{ exception.message|nl2br|format_file_from_text }}</h2>

Custom templates for 403, 404 and 500 errors, so i created error.html.twig (parent template) and error403.html.twig, error404.html.twig and error500.html.twig that extends from 'TwigBundle:Exception:error.html.twig' (overridden by your custom parent template).

শনিবার, ১৭ মে, ২০১৪

Take screenshot by canvas

We are going to take a screenshot from our current page by html5 canvas. So why we are waiting for. Let's start

1. At first we have to create our current page. Crate index.html page and copy the below stuff and paste it.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
  <head>
    <title> Take screenshot by html5 canvas</title>
  </head>
  <body>
    <p>This is a simple page. which we'll take a screenshot from it.</p>
  </body>
</html>

2. You have to download html2canvas.js file and include it into your head section

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
  <head>
    <title> Take screenshot by html5 canvas</title>
    <script type="text/javascript" src="html2canvas.js"></script>
  </head>
  <body>
    <p>This is a simple page. which we'll take a screenshot from it.</p>
  </body>
</html>

3. and finally add the below script.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
  <head>
    <title> Take screenshot by html5 canvas</title>
    <script type="text/javascript" src="html2canvas.js"></script>
    <script type="text/javascript">
        html2canvas(document.body, {
            onrendered: function(canvas) {
var imgString = canvas.toDataURL("image/png");
                 window.open(imgString);
            }
        });
    </script>
  </head>
  <body>
    <p>This is a simple page. which we'll take a screenshot from it.</p>
  </body>
</html>


Now you are free to browse and enjoy.

শনিবার, ১৫ মার্চ, ২০১৪

php to adv


preserveWhiteSpace = false; $doc = $xmlDoc->createProcessingInstruction("ADF", '"VERSION="1.0"'); $xmlDoc->appendChild($doc); //Create adf element $adf = $xmlDoc->createElement('adf'); $adf = $xmlDoc->appendChild($adf); $customer = $xmlDoc->createElement('customer'); $customer = $xmlDoc->appendChild($customer); $contact = $xmlDoc->createElement('contact'); $contact = $xmlDoc->appendChild($contact); //Name part 1 $nameEle = $xmlDoc->createElement('name'); $nameattr = $xmlDoc->createAttribute('part'); $nameattrVal = $xmlDoc->createTextNode('first'); $nameattr->appendChild($nameattrVal); $nameEle->appendChild($nameattr); $name1 = $xmlDoc->appendChild($nameEle); $nameNode = $contact->appendChild($name1); $nameTextNode = $xmlDoc->createTextNode('Masum'); $nameNode->appendChild($nameTextNode); //Name part 2 $nameEle2 = $xmlDoc->createElement('name'); $name2attr = $xmlDoc->createAttribute('part'); $name2attrVal = $xmlDoc->createTextNode('last'); $name2attr->appendChild($name2attrVal); $nameEle2->appendChild($name2attr); $name2 = $xmlDoc->appendChild($nameEle2); $name2Node = $contact->appendChild($name2); $name2TextNode = $xmlDoc->createTextNode('Billah'); $name2Node->appendChild($name2TextNode); //Email $email = $xmlDoc->createElement('email'); $email = $xmlDoc->appendChild($email); $emailNode = $contact->appendChild($email); $emailTextNode = $xmlDoc->createTextNode('email@gmail.com'); $emailNode->appendChild($emailTextNode); //Phone $phone = $xmlDoc->createElement('phone'); $phone = $xmlDoc->appendChild($phone); $phoneNode = $contact->appendChild($phone); $phoneTextNode = $xmlDoc->createTextNode('019733'); $phoneNode->appendChild($phoneTextNode); //Contact & Customer $contactNode = $customer->appendChild($contact); $adfNode = $adf->appendChild($customer); //Output $xmlDoc->formatOutput = true; echo "". $xmlDoc->saveXML() .""; $xml->save("mybooks.xml") or die("Error"); ?>

বুধবার, ১২ জুন, ২০১৩

<body onload="initializeMaps()">
<div style="background-color:#FFFFFF;" >

<script>
function initializeMaps() {

map = new google.maps.Map(document.getElementById("googleMap"), {
center: new google.maps.LatLng(0,0),
zoom:8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
});


addMarker('.$map["Latitude"].','.$map["Longatude"].',"<div>'.$map["City"].'</br>Instractor: Place Function</div>","./theme/default/images/lightgreen.png");

center = bounds.getCenter();

map.fitBounds(bounds);
}

var center = null;
var map = null;
var currentPopup;

var bounds = new google.maps.LatLngBounds();

function addMarker(lat, lng, info, icon_param) {
var icon = new google.maps.MarkerImage(
icon_param,
new google.maps.Size(40, 40),
new google.maps.Point(0, 0),
new google.maps.Point(16, 32)
);
var pt = new google.maps.LatLng(lat, lng);
bounds.extend(pt);
var marker = new google.maps.Marker({
position: pt,
icon: icon,
map: map
});

var popup = new google.maps.InfoWindow({
content: info,
maxWidth: 1000
});
google.maps.event.addListener(marker, "click", function() {
if (currentPopup != null) {
currentPopup.close();
currentPopup = null;
}
popup.open(map, marker);
currentPopup = popup;
});
google.maps.event.addListener(popup, "closeclick", function() {
map.panTo(center);
currentPopup = null;
});
}
</script>

<div id="googleMap" style="width:90%;height:340px;"></div>
</div><!--end of map-->
</body>
<body onload="initializeMaps()">
<div style="background-color:#FFFFFF;" >

<script>
function initializeMaps() {

map = new google.maps.Map(document.getElementById("googleMap"), {
center: new google.maps.LatLng(0,0),
zoom:8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
});


addMarker('.$map["Latitude"].','.$map["Longatude"].',"<div>'.$map["City"].'</br>Instractor: Place Function</div>","./theme/default/images/lightgreen.png");

center = bounds.getCenter();

map.fitBounds(bounds);
}

var center = null;
var map = null;
var currentPopup;

var bounds = new google.maps.LatLngBounds();

function addMarker(lat, lng, info, icon_param) {
var icon = new google.maps.MarkerImage(
icon_param,
new google.maps.Size(40, 40),
new google.maps.Point(0, 0),
new google.maps.Point(16, 32)
);
var pt = new google.maps.LatLng(lat, lng);
bounds.extend(pt);
var marker = new google.maps.Marker({
position: pt,
icon: icon,
map: map
});

var popup = new google.maps.InfoWindow({
content: info,
maxWidth: 1000
});
google.maps.event.addListener(marker, "click", function() {
if (currentPopup != null) {
currentPopup.close();
currentPopup = null;
}
popup.open(map, marker);
currentPopup = popup;
});
google.maps.event.addListener(popup, "closeclick", function() {
map.panTo(center);
currentPopup = null;
});
}
</script>

<div id="googleMap" style="width:90%;height:340px;"></div>
</div><!--end of map-->
</body>

মঙ্গলবার, ২৮ মে, ২০১৩

<?php
class loginregistration{
public function login(){
?>
<div class="content">
<form method="post" action="">
Name:
<input type="text" name="" /><br/>
Password:
<input type="password" name=""/><br/>
</form>
</div>
<?php
}
public function registration(){
?>
<div class="content">
<form method="post" action="">
Name:
<input type="text" name="" /><br/>
Email:
<input type="text" name=""/><br/>
Contact:
<input type="text" name=""/><br/>
</form>
</div>
<?php
}
}

class page{
public function home(){
?>
<div class="content">
<p>This is a home page</p>
</div>
<?php
}
public function contact(){
?>
<div class="content">
<p>This is a contact page</p>
</div>
<?php
}
public function about(){
?>
<div class="content">
<p>This is a about page</p>
</div>
<?php
}
public function blog(){
?>
<div class="content">
<p>This is a Blog page</p>
</div>
<?php
}
}
class menues{
public function menu(){
?>
<ul>
<li><a href="t.php">Home</a></li>
<li><a href="t.php?page=contact">Contact</a></li>
<li><a href="t.php?page=about">About</a></li>
<li><a href="t.php?page=blog">Blog</a></li>
</ul>
<p><a href="t.php?page=login">Login</a></p>
<p><a href="t.php?page=registration">Registration</a></p>
<?php
}
}
?>
<html>
<head>
<style type="text/css">
.content {height:200px; background-color:E1E1E1;}
</style>
</head>
<body>
<?php
//For Menu
$menu = new menues;
$menu -> menu();
//For Login
$login = new loginregistration;
// if(isset($_GET['type'])=="login"){
// $login->login();
// }else if($_GET['type']=="registration"){
// $login->registration();
// }

//For Page
$page = new page;
if(!isset($_GET['page'])){
$page->home();
}else if($_GET['page']=="contact"){
$page->contact();
}else if($_GET['page']=="about"){
$page->about();
}else if($_GET['page']=="blog"){
$page->blog();
}else if($_GET['page']=="login"){
$login->login();
}else if($_GET['page']=="registration"){
$login->registration();
}else{
$page->home();
}
?>
</body>
</html>

মঙ্গলবার, ১৪ মে, ২০১৩

jquery backend form design by tab


<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Accordion - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<style type="text/css">
#ulid {
background-color:red;
}
#ulid li{
background-color:green;
color:white;
}
</style>
 <script>
$(document).ready(function() {
$(function() {
$( "#CreatingQuotation" ).tabs();
$( "#CreatingQuotation" ).tabs( "option", "disabled", [ 1, 2, 3 ] );
});

$("#clickid").click(function() {
if($("#inputfield").val() === ''){
$("#inputfield").css("border", "1px solid red");
}else{
$("#CreatingQuotation").tabs( "enable", 1 );
$("#CreatingQuotation").tabs( "option", "active", 1 );
document.getElementById("number").innerHTML=3;
$( "#formid" )[0].reset();
}
});
$("#preview").click(function() {
$("#CreatingQuotation").tabs( "option", "active", 0 );

});
});
</script>
 
</head>
<body>
<p id="number">1</p>
<div id="CreatingQuotation">
<ul id="ulid">
<li id="p1"><a href="#tabs1">Contact Info</a></li>
<li id="p2"><a href="#tabs2">Education</a></li>
<li id="p3"><a href="#tabs3">Professional Experience</a></li>
<li id="p4"><a href="#tabs4">Additional Skills</a></li>
</ul>

<div id="tabs1">
<form id="formid">
<input type="text" id="inputfield"/>
<input type="button" id="clickid" value="Test" />
</form>
</div>
<div id="tabs2">
Tabs 2
<p id="preview">Preview</p>
</div>
<div id="tabs3">
Tabs 3
</div>
<div id="tabs4">
Tabs 4
</div>
</div><!--end of tabs-->
</body>
</html>

বৃহস্পতিবার, ২ মে, ২০১৩


<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>jQuery UI Accordion - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<style type="text/css">
body {font-family:Arial;}
h2 {font-size:1.6em;}
.newsItem {
border:solid 1px red;
padding:10px;  
}
.newsTeaser{
border:solid 5px green;
padding:10px;  
}

.collapsible{
display:none;
border:solid 5px blue;
padding:10px;

}
.more {cursor:pointer;}
</style>
  <script>
$(document).ready(function() {
$(".more").click(function() {
$(".collapsible").hide();
$(this).parent().parent().find(".collapsible").show();
});
});
  </script>
 
</head>
<body>
<?php
for($i=1;$i<=3;$i++){
$demo='

<div>
    <h2>Title</h2>
    <div id="newsTeaser">
  <button class="btn more">more</button>
    </div>
<div style="clear:both;"></div>
<div class="btn collapsible" style="display:none;">
    <table>
        <p>Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...Full body goes here...</p>
<p class="less">less</p>
</table>
    </div>
</div>


';
echo $demo;
}
?>
</body>
</html>

শনিবার, ২৭ এপ্রিল, ২০১৩

Jquery TAB


In this tutorial you can make more page by jquery tab.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>

<style type="text/css">
ul.ul_requests { text-decoration:none;}
ul.ul_requests li {display:inline; margin-right:20px;}
ul.ul_requests li a { color:Green; text-decoration:none;}
ul.ul_requests li a:hover { color:red; text-decoration:none;}

html ul.ul_requests li.active, html ul.ul_requests li.active a:hover  {
background: red;
border:none;
color:white;
}
</style>
<script  src="js/jquery.js"></script>
<script>
$(document).ready(function() {
//Hide all content
$(".tab_content_bid").hide();
//Activate first tab
$("ul.ul_requests li:first").addClass("active").show();
//Show first tab content
$(".tab_content_bid:first").show();

//On Click Event
$("ul.ul_requests li").click(function() {
//Remove any "active" class
$("ul.ul_requests li").removeClass("active");

//Add "active" class to selected tab
$(this).addClass("active");

//Hide all tab content
$(".tab_content_bid").hide();

//Find the rel attribute value to identify the active tab + content
var activeTab = $(this).find("a").attr("href");

//Fade in the active content
$(activeTab).fadeIn();
return false;
});
});
</script>
</head>
<body>
<ul class="ul_requests">
<li><a href="#tabrequesta">Cover Letter</a></li>
<li><a href="#tabrequestb">Attachment</a></li>
</ul>
<div class="tab_container_request">
<div id="tabrequesta" class="tab_content_bid" style="margin-top:0px; padding:0px;">
<p>This is a first Tab
</div>
<div style="clear:both"></div>

<div id="tabrequestb" class="tab_content_bid">
<h2>About</h2>
<p>This is a about page</p>
</div>
</div>
</body>
</html>

বুধবার, ৫ ডিসেম্বর, ২০১২

php এবং mysql এর ধারাবাহিক পর্ব(ডাটাবেজ এর জন্য টেবিল বানানো।)। ৩য় দিন।

এখানে একটা বিষয় বলে রাখি। আমাদের আগের পার্টগুলি ঠিকভাবে শেষ না হলে টেবিল বানানো যাবে না। টাই আগে কোন সমস্যা থাকলে তা কমেন্টস করে জানাবেন।

<?php  //আমরা আগের মত কানেকশন পেইজ টাকে এখানে প্রবেশ করালাম। require_once "connect_to_mysql.php"; // Create an sql command structure for creating a table $tableCreate = "CREATE TABLE members ( 
                id int(11) NOT NULL auto_increment, 
                username varchar(255) NOT NULL, 
                email varchar(255) NOT NULL, 
                password varchar(255) NOT NULL, 
                website varchar(255) NULL, 
                account_type enum('a','b','c') NOT NULL default 'a', 
                PRIMARY KEY (id), 
                UNIQUE KEY email (email) 
                )"
; // This line uses the mysql_query() function to create the table now $queryResult = mysql_query($tableCreate); // Create a conditional to see if the query executed successfully or not if ($queryResult === TRUE) { 
        print 
"<br /><br />Success in TABLE creation! Happy Coding!"; 
} else { 
        print 
"<br /><br />No TABLE created. Check"; 
} 
// close mysql connection mysql_close(); ?>

সোমবার, ৩ ডিসেম্বর, ২০১২

php এবং mysql এর ধারাবাহিক পর্ব(ডাটাবেজ কানেকশন বন্ধ করা।)। ২য় দিন।

গত কাল আমরা কি করে ডাটাবেস কানেক্ট করতে হয়, তা জেনেছি। আজকে ওপেন করার পড়ে কি করে বন্ধ করতে হয় তা শিখব।
<?php  //আমরা ১ম কানেকশন পেজটাকে আমাদের নতুন পেজ এ নিয়ে আসলাম। require_once "connect_to_mysql.php"; 
//এখানে আমরা আমাদের কোডের কাজ করব। এবং শেষ হলে নিচের mysql_close দিয়ে কানেকশন বন্ধ করব 

mysql_close();
//তাহলে আমাদের বন্ধ করার কাজ শেষ।  

?>

php এবং mysql এর ধারাবাহিক পর্ব। 


১ম দিন।

  এটা আমার প্রথম ব্লগ, ভুল হলে অবশ্যই আমাকে কমেন্টস করে জানাবেন।
<?php  

১ম এ আমার কাজ হল আমার নাম, পাসওয়াড সবকিছু ভেরিয়াবেল এর মধ্যে নিয়া আসা। আমার হোস্ট হল localhost ।  

বিঃ দ্রঃ $সাইন দিয়া ভেরিয়েবেল লেখা হয়।

$db_host = "লোকালহোস্ট";
 এখানে আমার ইউজার নাম রাখতে হবে।

$db_username = "রুট";   
এখানে আমার লোকালহোস্ট এর পাসওয়াড দিতে হবে।  
$db_pass = "আমার পাসওয়াড নাই"; 
আর এটা আমার ডাটাবেস এর নাম। 

$db_name = "টেস্ট";
এখন মান গুলোকে mysql_connect কিওয়াড দিয়া কানেক্ট করা হবে। তারপর mysql_select_bd দিয়া ডাতাবেশ চিনহিত করতে হবে।  


mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql"); mysql_select_db("$db_name") or die ("no database");               

?>

এবার পেজ টাকে connect_to_mysql.php নামে সেভ করুন।
<?php 
$db_host = "localhost";  

$db_username = "root";  
$db_pass = "";  
$db_name = "test";
mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql"); mysql_select_db("$db_name") or die ("no database");               

?>


 এবার নিচের কোড দিয়ে আমরা কানেকশন ঠিক আছে কিনা চেক করব।
<?php   require বা include দিয়া অন্য পেজ নতুন পেজ এ নিয়া আসে।  require "connect_to_mysql.php"; 
echo ba print dia output বা স্ক্রীন এ লেখা দেখায়। এখানে উপরের পেজ এর সবকিছু ঠিক থাকলে নিচের কোড ব্রাউজার এ ভিসিট করলে দেখাবে। আর ঠিক না থাকলে ওটা দেখাবে না।
echo 
"<h1>Success in database connection! Happy Coding!</h1>";    ?>
  mysql_quicktest.php নামে সেভ করুন।
<?php   require "connect_to_mysql.php"; 
echo 
"<h1>Success in database connection! Happy Coding!</h1>";   ?>