How to open multiple buffers in JEdit like in GEdit or Mousepad

Many of us use a text editor to edit program code. The simplest and clean edit is GEdit on the Gnome desktop. However, if you are not on the Gnome desktop, you may miss it. You can use JEdit which is much more powerful, however, by default, it does not open multiple programs alongside each … Continue reading How to open multiple buffers in JEdit like in GEdit or Mousepad

Sessions in PHP

php1.php <?php session_start(); session_register(“count”); $count++; ?> php2.php <?php session_start(); $vu = HTTP_SESSION_VARS(“count”); echo “n$vun”; session_destroy(); ?> You have to put session_start() at start of every program that is within that session. HTTP_SESSION_VARS() will read value of session variable within brackets. When using $count variable in a function, you must specify: global $count; else the variable … Continue reading Sessions in PHP

PHP: Read MySQL Database with cookie validation

list ($username, $pwd) = split(“ “, $validation); if (empty($username) || empty($pwd)) die (“You are not authorized user”); $connection = @mysql_connect($host, $username, $pwd) or die (“Could not connect to database”); $db = mysql_select_db(“address”, $connection) or die (“Could not select database”); $sql = “select * from table”; $res = mysql_query($sql); if (! $res) die (“Could not read … Continue reading PHP: Read MySQL Database with cookie validation

PHP: Connect to a database in MySQL

$link = mysql_connect($host, $user, $password); if ($link && mysql_select_db($db)) {} $sql = “select * from table”; $res = mysql_query($sql); if (! $res) die (“Could not run query”); $no_recs = mysql_num_rows($res); i = 0; while ($row = mysql_fetch_array($res)) { $i++; $first = $row[“FirstName”]; $last = $row[“LastName”]; } mysql_free_result($res); mysql_close($link);

PHP: Read data from a delimited file

$fin = fopen(“address.txt”, “rb”); $row = 0; while ($data = fgetcsv($fin, 2000, “,”); { $mm = count($data); $row++; $categories = $data[1]; $FirstName = $data[2];...... $sql = “insert into address (categories, FirstName) values (”$categories”, ”$FirstName”); $result = mysql_query($sql); $error_string = mysql_error(); $no_recs = mysql_affected_rows(); } fclose($fin); mysql_free_result($result); mysql_close($connection);

PHP: Put all fields metadata in array

$connection = mysql_connect($host, $user, $password); $db = mysql_select_db(“address”, $connection); $fieldname = array(); $result = mysql_list_fields(“address”, “address”); $no_fields = mysql_num_fields($result); for ($i = 0; $i < $no_fields; $i++) $fieldname[$i] = mysql_field_name($result, $i); mysql_free_result($result); mysql_list_fields(“$db”, “$table”); mysql_num_fields($result); mysql_field_name($result, $i); mysql_field_type($result, $i);