Make a div clickable javascript

You can make a div or li tag clickable using javascript


use following code

<div onclick="window.location.href='cc.html'">

Export and import mysql database for webhosting

phpmyadmin provides good interface to upload and download database .








All webhosting sites provides phpmyadmin to upload databases.

Here is interface to export database.It is very simple you can select database or tables to export














You can export database in following formats

1.
2.
3.
4.
5.
6.
7.  
8. 
9. 
10 .
Most commonly database is exported as sql

You can also download database in zipped or gzip format


For importing database browse the databse and save to server through import interface


Pass variables from one page to another

Here is a simple method to Pass variables from one page to another

Here is the code in first page

<a href="page2.php?nam=sree">click here</a>


In your second page you can access variable name as


$name=$_GET['nam'];
echo $name;

This code will display sree

Download files with php script example

Simple code for downloading files

Place this code in a php file and make links to it. That links will be act as download link for the file .





<?php
$filename="left.txt";

$type=filetype($filename);

header("Content-type: $type");
header("Content-Disposition: attachment;filename=$filename");
header("Content-Transfer-Encoding: binary");
header('Pragma: no-cache');
header('Expires: 0');
// Send the file contents.
set_time_limit(0);
//readfile($file);


 ?>

Pass array in php from one php page to other

Here is a simple way to pass your array in post method.

In first page we are creating a form.In that form creating hidden 
controls with arrray value as shown below.

In second part (display.php) we can extract values from request 
variable. 
Here is the code 
 
///////////////////////////////////////////////////

echo '<form name="form" method="post" action="display.php">';


$i=0;

foreach($arr as $key => $value)
{
$i++;
echo '<input type="hidden" name="val['.$i.']" value="'.$value.'"/>';
}

echo '</form>';







////////////////Copde in display.php page ////////////////



foreach($_REQUEST['val'] as $key => $value)
{


echo $value;
}

//////////////////////////////////////

If you found some good method to pass array Share with us as comments 
with regards SREEHARI

Javascript vs jquery

Jquery is a collection of javascript classes .It is very easier than javascript.If you are new to client side scripting you can prefer jquery.

What are the advantages of using Jquery?

Jquery is simple to use.It avoids difficulties in using java script .

You can find simple examples of jquery from
www.w3schools.com


For more details, visit http://jquery.com

Display all get variables using foreach loop

Using following code we can display all get variable passing from a page
<?php

foreach($_GET as $k=>$v)
echo $v;
?>


Same way we can also display all post varibles with their keys

<?php

foreach($_POST as $k=>$v)
echo $v;
?>

My sql error - (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near)

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near


You can easily find error by identifying remaining part of error .The error in your mysql query is in the first character of the remaining error .

For example error in the following message must be near word "long"

Eg:- "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'long,buy,credit,bankrupt,discharged,forclosure,lforclosure,home_loan,payment,mpa' at line 1"

php error -(Parse error: syntax error, unexpected T_DNUMBER, expecting ',' or ';')

Parse error: syntax error, unexpected T_DNUMBER, expecting ',' or ';'

This error occur when a number comes when expecting a string .
For example the following code produces error because a string is concatenated with integer.


<?php
echo "example".1;
?>

php errors- (Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';')

2. Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';'

This error occurs when a semicolon missing

For example following code produces this error because of missing a semicolon in second line


<php
echo $s
?>

php errors- Parse error: syntax error, unexpected T_ECHO

Errors are very helpful to programmers .When you identifies cause of error next time that error will not be a challenge for you.
Here i am providing some common errors

1.Parse error: syntax error, unexpected T_ECHO

This error is due to some unidentified symbol or character in code

For example following code produces the above error because of "character x" in code

<?php
x
echo "error example";
?>