Chapter 16 . PHP Development 481 In addition (Web hosting top)

Chapter 16 . PHP Development 481 In addition to the functions used in this section, another method is possible for processing the returned results. It looks like this: else { # User wants to simply lookup the hosts allowed # for given username. # Make sure the username is safe to # send to MySQL. $quoteduser = mysql_escape_string($user); $query = SELECT host,user FROM user WHERE user = $quoteduser ; $result = mysql_query($query) or die ( Cannot execute query 1 ); while ( $row = mysql_fetch_array($result) ) { echo User . $row[ user ] . is allowed to connect from: . $row[ host ] .

; } } The final section of the program is called when an @ symbol is included in the input that comes from the form: function priv($user,$inhost) { # This subroutine looks up the grants for the given # user/host pair. $query = SHOW GRANTS FOR $user $inhost ; $result = mysql_query($query); $i = 0; if (! $result) { print No such grant

n ; } else { while ($grant = mysql_fetch_array($result) ) { print $grant[$i]

; $i++; } } } ?> In the code snippet just given, notice that PHP calls the function with the name function (whereas Perl uses subto designate a user-defined function). The function also uses a different method for receiving the variables that are called with it.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Leave a Reply