I'll explain this using a example,
Lets thing we have table called EMP and column called SALARY.
Now suppose there are numerical data and string data in the SALARY column. (ex: 12000, 25000, not available, null...)
For this kind of columns we can use following method to select only numerical data;
SELECT SALARY FROM EMP WHERE (SALARY+0)!=0;
Latest Entries »
Showing posts with label php. Show all posts
Showing posts with label php. Show all posts
Wednesday, July 28, 2010
Monday, January 18, 2010
How to send HTTP request using PHP?
There is a predefined php class called HttpRequest. By using this class we can create object for handle HTTP requests. There are list of function to handle it. Refer PHP manual and get some idea about this class.
In WAMP before use this objects you need to make some changes in php.ini file. Add following line into the php.ini file (somewhere near in the extension).
"extension=php_http.dll"
Example
======
user HttpRequest object to handle get method http request
$r= new HttpRequest('www.example.com?valueone=1&valuetwo=2', HttpRequest::METH_GET);
$r->send();
echo $r->getResponseBody();
Sunday, December 20, 2009
Simple php sample code for privent SQL injection attacts
if(isset($_POST["un"]) && isset($_POST["pw"])){
mysql_connect("localhost","root","");
mysql_select_db("my_db");
$username = mysql_real_escape_string($_POST["un"]);
$password = mysql_real_escape_string($_POST["pw"]);
$sql = "SELECT * FROM user WHERE id = '$username' AND name = '$password';";
$result = mysql_query($sql);
if($result){
if(mysql_num_rows($result)>0){
echo "you loged in....";
}
}
}
?>
Tuesday, December 1, 2009
How to execute php files without loading it
This method will execute the file_handle.php file and return the html result. So we can simply use this to database updates using this (use get method for pass inputs).
echo "Start";
$result = file("http://localhost/testing/file_handle.php");
echo "end";
?>
Friday, October 23, 2009
Php function for search from a file
If you have the start and end points, you can get the content of that two points. (as a example if the start and end point are and then u can get the content of these tags using this function. eg: content )
","",$contents);
$t = my_strip("abc","xyz",$contents);
echo $t;
?>
aaa.txt
=====
ntbfjkb n jABCjergnv
fvb j njrbn ntbfjkb n jegnb ef
g45yyyXYZtrgjrgbXYZk oi iABCyji oni jij
output
=====
jergnv fvb j njrbn ntbfjkb n jegnb ef g45yyy
","",$contents);
$t = my_strip("abc","xyz",$contents);
echo $t;
?>
aaa.txt
=====
ntbfjkb n jABCjergnv
fvb j njrbn ntbfjkb n jegnb ef
g45yyyXYZtrgjrgbXYZk oi iABCyji oni jij
output
=====
jergnv fvb j njrbn ntbfjkb n jegnb ef g45yyy
Tuesday, September 29, 2009
sample code for undestand php file handling functions
$comment = $_POST["txtcomment"];
if ($comment!=""){
$date=date('l dS \of F Y h:i:s A');
$massage = $date.": ".$comment."\n";
$file=fopen("comment.txt","a+") or exit("Unable to open file!");
fwrite($file,$massage) or die("Could not write to file");
fclose($file);
echo "Massage sent!";
}
?>
This will write the massage to the comment.txt file.
Subscribe to:
Posts (Atom)
About Me
Facebook Badge
Followers
Blog Archive
Labels
- asterisk (1)
- autorun (1)
- c sharp (1)
- c# (1)
- c# and mysql (1)
- centOS (1)
- class diagram (1)
- cmd (1)
- compare databases (2)
- compare object orienterd databases (1)
- database (2)
- databases (2)
- datetime (1)
- DBMS (1)
- DBMS market (1)
- different detabases (1)
- different object oriented databases (1)
- enable javascript (1)
- ER diagram (2)
- hidden files (1)
- http (1)
- IP PBX (1)
- isNumaric() (1)
- javascript (3)
- jquery. prototype (1)
- linux (2)
- magic (1)
- mail validation (1)
- ms office (1)
- mysql (3)
- object oriented databases (1)
- OODB (1)
- open-source (1)
- opensource (1)
- php (6)
- php file handling function (2)
- report writting (1)
- shell script (1)
- sql (2)
- sql injection (1)
- stored procedure (1)
- target market of DBMSs (1)
- UML (2)
- UML diagrams (2)
- usecase (1)
- virus (1)
- widows (1)
- windows (1)
- windows xp autorun (2)
- word (1)