Tuesday, October 1, 2013

What is Data Logic Layer (DLL), Business Logic Layer (BLL) And User Interface (UI) ?



It is part of 3-tier or can be used in N-layer architecture. We will start architecture where it is used. Each name itself explain little bit what they exactly mean.
Basically 3-tier included all this, in Tier application we are dividing application into different modules (Layers) to reduce the complexity and more efficient code & easy to manage.


DLL (Database Logic Layer/
Data Access Layer): As name states, all the concept regarding the Database will go here. Your connectivity, Query, Manipulation, Execution of SQL Query and so on. Will take the same example where you are doing calculation and want to store the values or history in some database table. All the logic will go here. 
 
BLL (Business Logic Layer): As name states, all the concept what you do with Business will go here. Basically you can say if i am building Calculation application now all the Calculation logic can reside in this layer. You can have interface here and there implementation in this layer for simplicity.

UI (User Interface): User Interface is what user see, it will contain all the controls, Java Script which is user facing. You should not write any logic in User Interface area just your UI controls and so forth.

Are the 3 main layers to develop 3 tier architecture.

The UI
(User Interface) layer is the one which is our .aspx with code behind file. So what ever we create the .aspx pages, those comes under the UI (User Interface) layer of the architecture.

BLL
(Business Logic Layer)  or the Business Logic Layer is the one, where we can define the business logic, business object or lets say the properties and method which will interact to other layers through out the application.
So in BLL, we can define the public properties as well as the constraints or rules so that before sending the data to the database, we can check it and if it violates the rules, then get the error back to UI
(User Interface) layer. 

Hence no need to propagate the data to the DAL.
DAL is one the important layer where we define all the methods related to database transactions- Insert, update, Delete, select etc.
So all the stuff which we do at our code behind related to database, is the part of Data-acess layer.

Tuesday, July 30, 2013

Can't Run AMFPHP In PHP 5.3.8 It's So easy to RUN Dude...

I tried the AMFPHP environment PHP 5.3.0
http://localhost/amfphp/browser/
I got a message .....  That's Really Weird !!
Function eregi_replace () is deprecated .
C: \ xampp \ htdocs\ amfphp \ core \ shared \ util \ MethodTable.php on line 505
Error retrieving service info:

Now,
 I can do two things about this small problem :
  1. Change the settings in your php.ini file to disable the deprecated warnings.
  2. Replace the php code in that specific amfphp core file, using the new equivalent function.

Personally I suggest you do the second if 1st one works. 

Why are we waiting for.....? Go -- :)

  •   Change the php.ini file


Thursday, May 23, 2013

Write A Text File

For Writing a Text file we make three files in one folder.
  1. index.php [ which contain some HTML input container and a submit button]
  2. filewrite.php [ it is a server script page]
  3. file.txt [create a blank text file]


index.php 

------------------------------

<form action="filewrite.php" method="POST">
     Name:<input type="text" name="name"><br>
     Pass:<input type="text" name="pass"><br>
     Type:<input type="text" name="type"><br>
     <input type="submit" value="Submit"><br>
</form>

----------------------------------

filewrite.php

----------------------------------

<?php

$file = fopen("file.txt","a");// "a" means append 

fwrite($file,"name:".$_POST["name"]."\r\n"."type:".$_POST["type"]."\r\n"."pass:".$_POST["pass"]."\r\n");

fclose($file);

?>
---------------------------------

Run the index.php file then see what happen ..
it's too simple to write a text file.
Go and open your  " file.txt " .....

Keep Smile  :)

Monday, December 17, 2012

Escapes Special Characters in a String for use in an SQL statement

          Today I face a big problem in my recent project with this Quotes ( ' ).  I can't submit my data into database which have contain this Quotes ( ' )  . . . . .  :'(
When i Set my $value= ' my father's ';
with this ( ' ) than i face an error. That  is it -

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's 

Than What...?  What can I do ?

mysql_real_escape_string — Escapes special characters in a string for use in an SQL statement


mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.

This function must always (with few exceptions) be used to make data safe before sending a query to MySQL.

Example :
  1.  $description=$_POST['description'];
  2. $escaped_description=mysql_real_escape_string($description);

  3. $sql= "INSERT INTO TABLE_NAME (post_description)
  4. VALUES                            ('".$escaped_description."')";


This Works Perfectly .....  

  Note : This would allow anyone to log in without a valid password.

Thursday, December 13, 2012

WAMP and Skype Conflict

Recently I discover a conflict between Skype and WampServer that I thought I would Share.  Both of them  use port 80 which causes the conflict... :D . If you run Skype before running Wamp, then Apache will not run. If you go to a site on localhost or 127.0.0.1 , you will probably get a blank screen.
..What Happen..?
The solution is pretty simple. Just make sure you start all services on WAMP before you open Skype. If Skype is disconnected it will work fine. You can then connect Skype once Wamp is running....
--- Really too easy....

But..
A much better solution than starting WAMP before Skype is to follow the advice ---
So, Why not...?
In skype if you click "tools " then "options" and connection down the left, untick the box "use port 80 and 443 as alternative incoming ports"

That worked  nicely and haven't looked back  :)

Sunday, September 9, 2012

Upload a File Into Your hosted Folder


It's too easy to upload a file into your hosted Folder.
At first we need to create a HTML page a Upload.php page  and Create a Folder in the hosting place.

----------------------------------------------------------------------
index.html:
----------------------------------------------------------------------
<head>
      <title>
               Uploading A file
      </title>
</head>
<body>
<table align="center" border="1">
<form enctype="multipart/form-data" action="Upload.php" method="POST">
<tr>
<td>Choose a file to upload:</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000" /> <input name="uploadedfile" type="file"/></td>
</tr>
<tr>
  <td>If the File is Chosen than<br /> Click Upload Button </td>
  <td align="center"><input type="submit" value="Upload File" /></td>
</tr>
</form>
</table>

</body>
----------------------------------------------------------------------

Friday, August 3, 2012

Connect with the PHP MySQL Database



You must create a connection to the database, Than  you can access data in a database. In PHP, it is done with the function name  mysql_connect() .

// mysql_connect("servername","username","password");

Q.What is "servername"?
Ans= It is Optional. Specifies the server to connect to.And the Default value is "localhost".

Q.What is "username"?
Ans= It is Optional.Specifies the username to LOGIN with. The Default value is the name of the User that owns the server process.

Q.What is "password"?
Ans=  It is Optional. Specifies the password to LOGIN with. Default value is "  ". That means NULL.


------------------------------------------------------------------------------
Total code 
------------------------------------------------------------------------------

<?php

session_start();

$connect = mysql_connect("localhost","mint_php","MeHeDi");

//server="localhost" userName= "mint_php " pass=" MeHeDi "

if (!$connect)

  {

  die('Could not connect: ' . mysql_error());

  }
// Here you can write your code

?>
---------------------------------------------------------- 

Wednesday, April 18, 2012

Using Concatenation Operator

Now we are talking about Concatenation.
Concatenation operator (.) [dot] is use to put two string value together.
To concatenate two string value together, use the concatenation operator.      

++++++++++++++++++
<?php
$string1="Hello";
$string2="Welcome to Mint PHP !";
echo $string1. " " .$string2;
?>
++++++++++++++++++
Output:
___________

Hello Welcome to Mint PHP !
______________

There is another method, without using the   .= operator  by this we can join different variable into another variable.
Example:
++++++++++++++++


   <?php
$string1="Hello,";
$string2="World!";
$string3=$string1 . $string2; 
$string4=$string1 . ' and welcome to Mint PHP Blog ' .$string2;

echo $string3.' ' .$string4;

?>

++++++++++++++
Output:
_______

Hello,World! Hello, and welcome to Mint PHP Blog World!
_____________

Saturday, February 18, 2012

Outputting A String

Thank you for reading my Blog.
We have done in previous lesson use PHP " echo " .we can also use the "ptint" function as like as C programming.
You can place either a string variable or you can use quotes,like i do below, to create a string that the echo/print function will output.

**************************************
<body>
<?php
$myString="Hello ! Welcome to Mint PHP ";
echo $myString."<br/>";
echo 'I love PHP :)'."<br/>";
print "You can also use print as like as \"echo\".";
?>

Friday, February 17, 2012

Basic Knowledge About PHP

Do you know what is PHP ?
Here some basic things about PHP.
If you know the  C/C++, HTML,CSS & JavaScript than it will be more easier to understand PHP ?
  • PHP is a server-side scripting language, like ASP.
  • PHP stands for PHP: Hypertext Preprocessor.
  • PHP is an open source software.
  • it's free to download and use.
  • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.).
How Can you understand the PHP files ?
  • PHP files can contain text, HTML tags and scripts.
  • PHP files are returned to the browser as plain HTML.
  • PHP files have a file extension of ".php", ".php3", or ".phtml"
Example:index.php

Let's talk about MySQL:

Thursday, February 16, 2012

PHP - Variables

What do you know about PHP variables ?
A variable is a means of storing a value,such as text string "Hello World" or the integer value.
In PHP you define a variable with the following form :
    PHP Variable declaration:
  • $variable_name = "value";
    Example:
  • $myString = "Hello";
Note:
Keep it on your mind,
If you forget that dollar sign at the beginning, it will not work. this is a common mistake for new programmer!


Wednesday, February 15, 2012

PHP White Space


Important things, keep it on your mind.
White Space is ignored between PHP & HTML.
--------------------------------
<html>
<head>
      <title>White Space </title>
<body>
   <?php 
                        echo 'White';
echo 'Space';
echo 'Can not WORK';

?>
</body>
</html>

Tuesday, February 14, 2012

Simple Example of HTML & PHP Page


Here I give an example of one of the easiest  PHP & HTML page that you can create and still follow web standards.


PHP & HTML CODE :
------------------------------
<html>
<head>
      <title>My First PHP Page</title>
<body>
   <?php
                        echo 'Hello World';
?>
</body>
</html>