Archive for Uncategorized

php mysql_affected_rows function

mysql_affected_rows

php mysql_affected_rows function

mysql_affected_rows Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query.

<?php
$link = mysql_connect(‘localhost’, ‘username’, ‘password’);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db(‘mydb’);

// This will return the number of records deleted
mysql_query(‘DELETE FROM table WHERE fldid < 100’);
print “Records Deleted By Above Query: “. mysql_affected_rows();
// Output will be like this : Records Deleted By Above Query: 10
?>

Comments (2)

php mysql_close function

mysql_close

php mysql_close function

<?php
$link = mysql_connect(‘localhost’, ‘mysql_username’, ‘mysql_password’); // This line will open a mysql database connection
mysql_close($link); // this function will colse the above mysql connection
?>

Leave a Comment

php mysql_connect function

mysql_connect

php mysql_connect function

mysql_connect — Open a connection to a MySQL Server

This php function is used to connect to mysql database , mysql_connect function required three main parameters host name , database username and database password.

<?php

mysql_connect( ‘localhost’, ‘dbuser’, ‘dbpass’) or die(‘Could not connect to mysql server.’ );

?>

Returns a MySQL link identifier on success, or FALSE on failure.

php help is the biggest php resource

Comments (2)

php preg_split function

preg_split

php preg_split function
This function Returns an array

<?php
$string = ‘php help programming’;
$array = preg_split(‘/ /’, $string, -1, PREG_SPLIT_OFFSET_CAPTURE);
print_r($array);
?>

Output :
Array
(
[0] => Array
(
[0] => php
[1] => 0
)

[1] => Array
(
[0] => help
[1] => 4
)

[2] => Array
(
[0] => programming
[1] => 9
)

)

best php help blog

Comments (6)

php preg_replace function

preg_replace

php preg_replace function

Perform a regular expression search and replace

<?php

$what_to_replace = array(“/a/”,”/b/”,”/c/”);

$replace_with = array(“dog”,”cat”,”rat”);

print preg_replace($what_to_replace, $replace_with, “1a2b3b”);

// Out put of this function will be 1dog2cat3rat

?>

Comments (2)

php – count_chars function

count_chars()

This function in php is used to count the number to characters in any string.
here is the example of php count_chars function

<?
$data = “Best college in Australia, Colleges in Sydney“;

foreach (count_chars($data, 1) as $i => $val) {
echo “There were $val instance(s) of \”” , chr($i) , “\” in the string.\n”;
}
?>

Output will be:
There were 6 instance(s) of ” ” in the string.
There were 1 instance(s) of “,” in the string.
There were 1 instance(s) of “A” in the string.
There were 1 instance(s) of “B” in the string.
There were 1 instance(s) of “C” in the string.
There were 1 instance(s) of “S” in the string.
There were 2 instance(s) of “a” in the string.
There were 1 instance(s) of “c” in the string.
There were 1 instance(s) of “d” in the string.
There were 6 instance(s) of “e” in the string.
There were 2 instance(s) of “g” in the string.
There were 3 instance(s) of “i” in the string.
There were 5 instance(s) of “l” in the string.
There were 3 instance(s) of “n” in the string.
There were 2 instance(s) of “o” in the string.
There were 1 instance(s) of “r” in the string.
There were 3 instance(s) of “s” in the string.
There were 2 instance(s) of “t” in the string.
There were 1 instance(s) of “u” in the string.
There were 2 instance(s) of “y” in the string.

Leave a Comment

Older Posts »