+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: Tutorial: PHP to MySQL

  1. #11
    Filips is offline Newbie
    Join Date
    Jul 2009
    Posts
    6
    Rep Power
    0

    Re: Tutorial: PHP to MySQL

    Hello Jordan

    I need your help.to get user IP and ISP (my plan is i will insert this to my mysql db)

    I use these codes, but none of this give the IP nor ISP name.I use IE8,Firefox,Safari.Google Chrome...same result.

    Now I am lost.Can you please me?

    Code:
    <?php

    echo 'This is all php test';

    $isp geoip_isp_by_name('there was a  example link here');
    if (
    $isp) {
        echo 
    'This host IP is from ISP: ' $isp;
    }

    ?>

    <?php
    $hostname 
    gethostbyaddr($_SERVER['REMOTE_ADDR']);

    echo 
    $hostname;
    ?>
    <?php
    $IP
    =$_SERVER['REMOTE_ADDR'];
    $HOSTgethostbyaddr($IP);

    echo 
    $IP;
    echo 
    $HOST;
    ?>

    <?php
    phpinfo
    ();
    ?>

    <?php
    $test 
    $_SERVER['REMOTE_ADDR'];
    echo 
    $test;
    ?>

    <?php 
    //Gets the IP address
    $ip getenv("REMOTE_ADDR") ; 
    Echo 
    "Your IP is " $ip
    ?>
    Last edited by Jordan; 08-13-2009 at 05:08 PM. Reason: Please use code tags

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #12
    Jordan Guest

    Re: Tutorial: PHP to MySQL

    This will give you the IP of the user:

    Code:
    $IP=$_SERVER['REMOTE_ADDR']; 
    If it isn't, perhaps there is something wrong with your PHP/Webserver setup.

  4. #13
    Filips is offline Newbie
    Join Date
    Jul 2009
    Posts
    6
    Rep Power
    0

    Re: Tutorial: PHP to MySQL

    Quote Originally Posted by Jordan View Post
    This will give you the IP of the user:

    Code:
    $IP=$_SERVER['REMOTE_ADDR']; 
    If it isn't, perhaps there is something wrong with your PHP/Webserver setup.
    --------------------

    Jordan thank you very very much---- yes it working.... it give me the IP address.Is there any way I can find the ISP name ?

    Once again thank you very much

    Filips

  5. #14
    Filips is offline Newbie
    Join Date
    Jul 2009
    Posts
    6
    Rep Power
    0

    Re: Tutorial: PHP to MySQL

    Jordan, thank you very very much.The code is working and it give me the ip address.
    Is there any way I can get the ISP name?

    Once again thank you

    Filips

  6. #15
    phillw's Avatar
    phillw is offline Learning Programmer
    Join Date
    Aug 2009
    Location
    Northwest England (UK)
    Posts
    82
    Blog Entries
    1
    Rep Power
    0

    Re: Tutorial: PHP to MySQL

    I'm guessing you want gethostbyaddr

    PHP: gethostbyaddr - Manual

    that section of the manual also has the other derivations of that family of commands.

    Regards,

    Phill.

  7. #16
    alilg's Avatar
    alilg is offline Learning Programmer
    Join Date
    Apr 2008
    Location
    LA
    Posts
    57
    Rep Power
    15

    Re: Tutorial: PHP to MySQL

    this function will slow down your website!
    don't try to run a gethostbyaddr for each one of your visitors! it response slow!

  8. #17
    alilg's Avatar
    alilg is offline Learning Programmer
    Join Date
    Apr 2008
    Location
    LA
    Posts
    57
    Rep Power
    15

    Re: Tutorial: PHP to MySQL

    Quote Originally Posted by Jordan View Post
    Code:
    // Close our connection
    mysql_close($link);

    ?> 
    how much mysql_close() is necessary to run after our queries?
    i never used of mysql_close in my codes

  9. #18
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: Tutorial: PHP to MySQL

    Quote Originally Posted by alilg View Post
    how much mysql_close() is necessary to run after our queries?
    i never used of mysql_close in my codes
    Well, PHP most often cleans this up by it self, but it is not good programming not to close your connections to the database. If it fails, your database can be flooded by open, dead connections, so it's safest to do this.
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

  10. #19
    ruskin012 is offline Newbie
    Join Date
    Aug 2009
    Posts
    8
    Rep Power
    0

    Re: Tutorial: PHP to MySQL

    Well explained. You are good teacher.
    But I want to know that what if we don't close the connection?

  11. #20
    phillw's Avatar
    phillw is offline Learning Programmer
    Join Date
    Aug 2009
    Location
    Northwest England (UK)
    Posts
    82
    Blog Entries
    1
    Rep Power
    0

    Re: Tutorial: PHP to MySQL

    As Orjan Says - you can end up with many 'dead' connections to your database. Worst case - Corruption of database, best case slowing of connections which can lead to not being able to connect to your database. Just as it is generally recommended to use mysql_real_escape_string to lessen the possibility of users inserting unwanted commands into your input strings.

    Just get used to doing it automatically, and those open connections cannot come back to haunt you !!

    Phill.

+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Use PDO for mysql or standar mysql functions?
    By lol33d in forum PHP Development
    Replies: 7
    Last Post: 05-07-2011, 08:41 PM
  2. Replies: 213
    Last Post: 04-14-2011, 07:57 PM
  3. Tutorial: Storing Images in MySQL with PHP
    By Jordan in forum PHP Tutorials
    Replies: 47
    Last Post: 01-04-2011, 08:37 PM
  4. Replies: 1
    Last Post: 10-20-2010, 12:38 AM
  5. [C#]MySQL] Host '****' is not allowed to connect to this MySQL server
    By ZaroX in forum Database & Database Programming
    Replies: 2
    Last Post: 02-16-2010, 08:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts