<?php
$string_to_be_stripped = "Hi, I am a string and I need to be stripped...";
$new_string = ereg_replace("[^A-Za-z0-9]", "", $string_to_be_stripped );
function alphanumericAndSpace( $string )
{
return preg_replace('/[^a-zA-Z0-9\s]/', '', $string);
}
echo alphanumericAndSpace( $string_to_be_stripped);
?>
Secure file download in PHP, Security question PHP, PHP MYSQL Interview Question -Books download - PHP solutions guidelines queries update, phpmysqlquestion
Thursday, February 24, 2011
Tuesday, February 22, 2011
Search in all column in the table fields
<?php
$conn = @mysql_connect( 'localhost','root' ,'')
or die( mysql_errno().': '.mysql_error().NL );
$db=mysql_select_db('kiwi',$conn);
$result = mysql_query("SHOW COLUMNS FROM $table");
if (mysql_num_rows($result) > 0)
{
$i=0;
while ($row = mysql_fetch_array($result))
{
if($i==0)
{
echo $q="select * from $table where ".$row[0]."=".$condition;
}
else
{
$q.=" or ".$row[0]."=".$condition;
}
$i++;
}
}
echo 'a';
echo $q;
?>
$conn = @mysql_connect( 'localhost','root' ,'')
or die( mysql_errno().': '.mysql_error().NL );
$db=mysql_select_db('kiwi',$conn);
$result = mysql_query("SHOW COLUMNS FROM $table");
if (mysql_num_rows($result) > 0)
{
$i=0;
while ($row = mysql_fetch_array($result))
{
if($i==0)
{
echo $q="select * from $table where ".$row[0]."=".$condition;
}
else
{
$q.=" or ".$row[0]."=".$condition;
}
$i++;
}
}
echo 'a';
echo $q;
?>
Monday, February 14, 2011
Curl Example code php
You must enable CURL libraries on you system
CASE 1: Just retrieve the site content
<?php
$ch = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_URL,"http://www.bing.com/search?q=test&FORM=MSNH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
CASE 2: Retreive the site content by posting the value from FORM for eg. contact form and other
<?php
$a=$_POST["a"]; // Form posted value
$ch = curl_init() or die(curl_error());
$params="a=$a";
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_URL,"http://www.abc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
CASE 3: Retrieve date from HTTPS site
<?php
$a=$_POST["a"];
$ch = curl_init() or die(curl_error());
$params="a=$a";
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_URL,"http://www.abc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'username:password'); // IF required
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
CASE 1: Just retrieve the site content
<?php
$ch = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_URL,"http://www.bing.com/search?q=test&FORM=MSNH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
CASE 2: Retreive the site content by posting the value from FORM for eg. contact form and other
<?php
$a=$_POST["a"]; // Form posted value
$ch = curl_init() or die(curl_error());
$params="a=$a";
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_URL,"http://www.abc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
CASE 3: Retrieve date from HTTPS site
<?php
$a=$_POST["a"];
$ch = curl_init() or die(curl_error());
$params="a=$a";
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
curl_setopt($ch, CURLOPT_URL,"http://www.abc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, 'username:password'); // IF required
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$data1=curl_exec($ch) or die(curl_error());
echo "".$data1."";
echo curl_error($ch);
curl_close($ch);
?>
Subscribe to:
Posts (Atom)
How to solve mysql ERROR 1118 (42000) Row size too large
I had this issue with MYSQL 5.7 . The following worked althoug...
-
PHP has an SSH2 library which provides access to resources (shell, remote exec, tunneling, file transfer) on a remote ma...
-
Which pillar of the AWS Well-Architected Framework recommends maintaining infrastructure as code? Operational Excellence Which of the foll...
-
Introduction to PHP PDO (PHP Data Objects) 1. What is PDO 2. What Databases does PDO support 3. Where do I begin? 4. Connect to ...