Developers Archive for February, 2007

/*!….*/ comment in mysql

/*!….*/ comment in mysql Wednesday, February 28th, 2007

/*!….*/ comment in mysql
MySQL Server parses and executes the code within /*! and ..*/ as it would any other SQL statement, but other SQL servers will ignore the extensions.

Syntax:
/*! MySQL-specific code */

Example :

CREATE /*! TEMPORARY */ TABLE table1 SELECT * FROM table2;
Mysql Create a temporary table table1. But other SQL servers create a normal table.

socket_connect

socket_connect Wednesday, February 28th, 2007

socket_connect

socket_connect

- It initiates a connection on a socket

Syntax:

int socket_connect ( resource socket, string address [, int port])

It initiates a connection using the socket descriptor socket, which must be a valid socket descriptor created with socket_create().

The address parameter is either an IP address in dotted-quad notation (e.g. 127.0.0.1), if the socket is of the AF_INET family; or the pathname of a Unix-domain socket, if the socket family is AF_UNIX.

The port parameter is only used when connecting to an AF_INET socket, and designates the port on the remote host to which a connection  should be made.

It returns zero on success, or a negative error code on failure. This code may be passed to socket_strerror() to get a textual explanation of the error.

Example:

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, $address, $port);

here, it connect a host with given $address and $port by using the resource $socket.

Str_pad function

Str_pad function Wednesday, February 28th, 2007

Syntax:

string str_pad ( string input, int pad_length [, string pad_string [, int pad_type]])

str_pad function is used to pad a string to specific length with another string.

Example:

<?php

$username = “sampleuser”;

echo str_pad($username,18,’*',STR_PAD_BOTH);

?>

In above example, First parameter $username is input string. Second parameter 18 is pad length. Third parameter * is the pad string which is optional. Default pad string is space. Fourth parameter STR_PAD_BOTH is pad type which will pad string on both sides. Default pad type is STR_PAD_RIGHT.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.