Monthly Archives: April 2010
Debug back-trace in php
The debug back-trace is one of the most basic forms of PHP debugging. It generates data about the current state of the php web application in the form of associative arrays containing debug information. Everytime a function call is made … Continue reading
ERROR 1099 (HY000): Table ‘TABLENAME′ was locked with a READ lock and can’t be up dated
This error occurs when you try to insert data into a table that has been locked for reading only. Lock table: mysql> LOCK TABLES TABLEproducts READ; Query OK, 0 rows affected (0.00 sec) Trying to insert into TABLEproducts creates the … Continue reading
Display subfolders from directory using php
Example to display subfolders from directory using php: <?php echo "<h2>subdirs in dir</h2><ul>"; $basedir = basename( __FILE__ ); $dirtoscan = ($basedir . ‘/somedir/’); $albumlisting = scandir($dirtoscan); foreach ($albumlisting as $item) { $dirinfo = pathinfo($item); print_r($dirinfo); if (is_dir("$item")) { echo "<li><a … Continue reading
Add whitespace to each line of a string in paragraph using php
Example to add whitespace to each line of a string in paragraph using php. <?php //Prepends whitespace to each line of a string function white_space( $string, $whitespace ) { //Create an array from the string, each key having one line … Continue reading
Store email and username in mysql database using php
<?php //opens connnection to mysql server $dbc = mysql_connect(’localhost’,'root’,”); if (!dbc){ die(’Not Connected:’ . mysql_error()); } //select a database $db_selected = mysql_select_db("rivals",$dbc); if(!$db_selected) { die("can’t connect :" . mysql_error()); } $query = "UPDATE `database` SET email=’something’ WHERE … Continue reading
Creating event handlers in Javascript
We can create event handlers in two ways in javascript. We can call built in functions as the handler or we can call custom user defined functions as event handlers. Built-in functions: onClick="window.open(‘somefile.html’, ‘newWin’)"; User-defined functions: onChange="if (!checkVal(this.value, 1, 10)) … Continue reading
Javascript event handlers
Event Handler Elements Actions onAbort Images When image loading has been interrupted. onBlur Windows, frames, all form objects When focus moves out of this object except hidden; e.g., when the cursor leaves a text box. onChange Input, select, and text … Continue reading
Events in Javascript
Events are a part of almost all Web pages and they make the pages interactive and dynamic. Events are actions initiated by the user. Examples of events are submitting a form, mouse over a link or image. Event handling is … Continue reading
Confirm dialog box in Javascript
The confirm dialog box is used to analyze a user’s response to a question. The confirm dialog box will have an OK button and a Cancel button. If the user presses the OK button, true is returned; otherwise false is … Continue reading
Prompt box in Javascript
The prompt box is used to display a dialog box to take user input in the form of a text box. The prompt dialog box takes two arguments: a string of text that is normally displayed as a question to … Continue reading
ERROR 1142 (42000): SHOW VIEW command denied to user ‘test’@’localhost’ for table ‘system’
This error(ERROR 1142 (42000): SHOW VIEW command denied to user ‘test’@’localhost’ for table ‘system’) occurs when users donot have sufficient privileges to view the syntax of a view definition. The view could have been created using the SQL SECURITY INVOKER … Continue reading
ERROR 1356 (HY000): View ‘viewname’ references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
This MySql (error ERROR 1356 (HY000): View ‘viewname’ references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them) occurs when a user tries to read data from a view that has been protected using … Continue reading
SQL SECURITY INVOKER clause in MySql
The SQL SECURITY INVOKER clause is used to control access to data, generally in a view. Using the SQL SECURITY INVOKER clause will enforce rules that the user must have permissions to also see the underlying data. Creating view using … Continue reading
ERROR 1142 (42000): ANY command denied to user
This error is generally experienced when you try to create a view on tables where the user does not have permissions.For example, the user has permissions to create views only in a specific schema. A normal user trying to run … Continue reading
CREATE VIEW privilege in MySql
In the MySql security model, the ability to create views requires a greater privilege than normally provided to create tables. Create user and grant privileges: CREATE USER test@localhost IDENTIFIED BY ‘test123’; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE ON products.* TO test@localhost; Running the following … Continue reading
Display executed query in codeigniter
To display the last executed query in codeigniter we can use the last_query() function. Example to display query: <?php echo ‘<i>’; print_r($this->db->last_query()); echo ‘</i>’; ?>
Find date difference in MySQL
We can use MySQL datediff function to find the number of days between two dates. Prior to MySQL 4.1: SELECT TO_DAYS(’2010-11-08′) – TO_DAYS(’2010-07-26′); Output: 105 MySQL 4.1.1+: SELECT DATEDIFF(’2010-11-08′,’2010-07-26′); Output: 105
Find difference in dates in mysql
We can use the TIMEDIFF and TIME_TO_SEC functions to find the time difference in seconds. SELECT TIME_TO_SEC(TIMEDIFF(’2010-01-09 10:24:46′,’2010-01-09 10:23:46′));
Set assembly version for c# application assembly
The AssemblyVersion attribute is used to set the assembly version for csharp application assembly. The general format of the assembly version is [major version].[minor version].[build number].[revision] We can replace the build number and the revision with an asterisk in the … Continue reading