Updates from December, 2009 Toggle Comment Threads | Keyboard Shortcuts

  • saif 6:28 pm on December 20, 2009 Permalink | Reply
    Tags: insert string with quote, mysql   

    insert string with single quote(‘) or double quote(“) in mysql 

    In developing web application, we write insert query for inserting data into database. Hence i use mysql query and PHP functions for inserting string with single quote(‘) or double quote.

    let we know two useful PHP function :

    1.  addslashes — Quote string with slashes. Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote ('), double quote ("), backslash (\) and NUL (the NULL byte).

    <?php
    $str
    = "Is your name O'reilly?";
    // Outputs: Is your name O\'reilly?
    echo addslashes($str);
    ?>

    2. stripslashes —  Un-quote string quoted with addslashes(). Returns a string with backslashes stripped off. (\' becomes ' and so on.) Double backslashes (\\) are made into a single backslash (\).

    <?php
    $str
    = "Is your name O\'reilly?";

    // Outputs: Is your name O’reilly?
    echo stripslashes($str);
    ?>

    Now come to the point…..if we insert string into database with single or double quote like this :
    <?php
    $str = “Is your name O’reilly?”;
    $query = “INSERT INTO tbl (description) VALUES ( ‘$str’)”;
    ?>
    This will occur error.

    but if we use addslashes($str) function like below and then insert into database, then no error will be occurred.
    <?php
    $str = “Is your name O’reilly?”;
    $desc_str = addslashes($str);
    $query = “INSERT INTO tbl (description) VALUES ( ‘$desc_str’)”;
    ?>

    similarly we can use stripslashes($str) to print that table field value like this :
    <?php
    echo stripslashes($str);
    ?>

    cheers 🙂

     
  • saif 6:04 pm on December 17, 2009 Permalink | Reply
    Tags: important prayer for muslims   

    আমাদের জীবনের জন্য দরকারী দোআ সমূহ 

    বাবা-মা এর প্রতি :

    বাবা-মা এর প্রতি

    যানবাহনে আরোহনের দোআ :

    যানবাহনে আরোহনের দোআ

    যানবাহনে আরোহনের দোআ

    জাহান্নাম থেকে মুক্তি পাবার দোআ :

    জাহান্নাম থেকে মুক্তি পাবার দোআ

    জাহান্নাম থেকে মুক্তি পাবার দোআ

    ঘর থেকে বের হবার দোআ :

    ঘর থেকে বের হবার দোআ

    ঘর থেকে বের হবার দোআ

    খাওয়া শুরু করার দোআ :

    খাওয়া শুরু করার দোআ

    ঘুমাতে যাবার আগে দোআ :

    ঘুমাতে যাবার আগে দোআ

     
    • Kazi Mohammad Ekram 9:13 am on February 10, 2010 Permalink | Reply

      Nice Start buddy. Thanks for sharing such doas. It’s really helpful and useful in our daily life. Wish you all the best.

  • saif 11:15 am on December 13, 2009 Permalink | Reply
    Tags: user IP   

    Get users IP by Getenv() PHP Function 

    Definition: Getenv () is used to get the value of an environmental variable. It is written as Getenv (varname) .

    Below are some examples of environmental variables you can use. If you are interested, you can see a full list by running phpinfo ().

    Also Known As: Get Environment Variable

    Examples:

    Get users IP by getenv() function. This is useful, when you want to know the users IP of your site during registration. By this you can know about users that, from where they are signing up or related information.

    You can also track users during login that, every time users are logging in and you know from which area or IP they are access your site. So see the simple use of this function:

    <?php
    //Gets the IP address
    $ip = getenv(“REMOTE_ADDR”) ;
    Echo “Your IP is ” . $ip;
    ?>

    <?php
    //Gets the document root
    $root = getenv(“DOCUMENT_ROOT”) ;
    Echo $root;
    ?>

    <?php
    //Gets the server admin’s email
    $ad = getenv(“SERVER_ADMIN”) ;
    Echo $ad;
    ?>

    Happy’s coding 🙂

    Definition: Getenv () is used to get the value of an environmental variable. It is written as Getenv (varname) ;

     
  • saif 9:13 am on December 12, 2009 Permalink | Reply
    Tags: Dynamic row color, Javascript   

    Alter Dynamic Table Row Background Colors Using JavaScript 

    Many web applications that present tabular data use alternating background colors of table rows to increase the readability of that data. This could be more attractive and nice looking for visitors.

    I wanted the table to be dynamic. We can use PHP for doing this, but hence I’m showing it in JavaScript.

    Getting Started

    Let’s start with an ordinary html table. Whether the table contains head/foot elements doesn’t matter in this case:

    <table id="theTable">
    <tr><td>0 - some txt</td></tr>
    <tr><td>1 - some txt</td></tr>
    <tr><td>2 - some txt</td></tr>
    <tr><td>3 - some txt</td></tr>
    <tr><td>4 - some txt</td></tr>
    </table>

    we use a style element through which we have defined two classes for background colors:

    <style>
    .odd{background-color: white;}
    .even{background-color: gray;}
    </style>

    The style is flexible: it could just as well define something else, such as that every second row should display in italics. The complete function looks like this:

    function alternate(id){
    if(document.getElementsByTagName){
    var table = document.getElementById(id);
    var rows = table.getElementsByTagName("tr");
    for(i = 0; i < rows.length; i++){
    //manipulate rows
    if(i % 2 == 0){
    rows[i].className = "even";
    }else{
    rows[i].className = "odd";
    }
    }
    }
    }

    The above function should be called from the onload event of the body tag:

    <html>

    <body onload="alternate('thetable')">
    <table id="thetable">
    <tr><td>…</td></tr>
    </table>

    The result could look something like this:

    row color img

    row color example

    Hope this may help the beginners who are developing web applications. 🙂

    Happy’s coding.

    Many web applications that present tabular data use alternating background colors of table rows to increase the readability of that data. This could be more attractive and nice looking for visitors.

    I wanted the table to be dynamic. We can use PHP for doing this, but hence I’m showing it in JavaScript.

    Getting Started
    Let’s start with an ordinary html table. Whether the table contains head/foot elements doesn’t matter in this case:

    <table id="theTable">
    <tr><td>0 - some txt</td></tr>
    <tr><td>1 - some txt</td></tr>
    <tr><td>2 - some txt</td></tr>
    <tr><td>3 - some txt</td></tr>
    <tr><td>4 - some txt</td></tr>
    </table>

    we use a style element through which we have defined two classes for background colors:

    <style>
    .odd{background-color: white;}
    .even{background-color: gray;}
    </style>

    The style is flexible: it could just as well define something else, such as that every second row should display in italics. The complete function looks like this:

    function alternate(id){
    if(document.getElementsByTagName){
    var table = document.getElementById(id);
    var rows = table.getElementsByTagName("tr");
    for(i = 0; i < rows.length; i++){
    //manipulate rows
    if(i % 2 == 0){
    rows[i].className = "even";
    }else{
    rows[i].className = "odd";
    }
    }
    }
    }

    The above function should be called from the onload event of the body tag:

    <html>

    <body onload="alternate('thetable')">
    <table id="thetable">
    <tr><td>…</td></tr>
    </table>

    The result could look something like this:
    1457_rowcolor1

    Hope this will may help the beginners who are developing web applications. J

    Happy’s coding.

     
    • Mahbub 10:38 am on February 8, 2010 Permalink | Reply

      I remember when i used to do this way 6-7 years back. Now with jQuery this is a piece of Cake.

      It’ll look like

      $(“#thetable tr:even”).addClass(“even”);
      $(“#thetable tr:odd”).addClass(“odd”);

      • saif 12:09 pm on February 8, 2010 Permalink | Reply

        @mahbub bhai, thanx for sharing. I just wrote it in js way and for beginners, Yours one is also useful and pretty. 😉

  • saif 5:42 pm on December 10, 2009 Permalink | Reply
    Tags:   

    Set favicon in different browser 

    we have seen most of the site has favicon which describe the additional information about the site , Addition in the scene it could be logo,company Profile, company production,web site application, and so many .

    now how can u do this ?
    its very simple to do , just u need to add some line’s of code and be ready with small icon image, u can also add animated image in fevicon

    add this part in between <head> </head> Section. Please try to use relative icon type like  type=”image/ico” for .ico image.

    <link rel=”shortcut icon” type=”image/ico”  href=”images/favicon.ico”>

    now some time this code will not work on most of the Browser like IE old version
    in this case u can add this line

    <link rel=”shortcut icon” href=”images/favicon.ico” type=”image/vnd.microsoft.icon” *gt;

    we can use this also for IE:

    <!--[if IE]>
        <link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
    <![endif]-->

    Finally ConvertICO can help to convert png image to ico image.

    Hope this will help the beginners who just started their journey in web development.

    Happy’s coding 🙂

     
  • saif 5:20 pm on December 10, 2009 Permalink | Reply  

    PHP == Progress Happiness Prosperity 

    I discovered a new meanings of PHP. In general, we know PHP stands for ‘Hypertext Pre processor’. but i think PHP stands for ‘Progress Happiness Prosperity’ for PHP developer guys who love PHP, who work in PHP, stay with PHP.

    It may like a funny abbreviation, but i think it’s a alternate meanings of PHP. Bcoz i love PHP.

    Happy’s coding!!

    🙂

     
  • saif 5:00 pm on December 10, 2009 Permalink | Reply  

    Finally I added me on wordpress world 

    I’m happy now that i just added my blog on wordpress. 🙂

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
%d bloggers like this: