$("#product").autocomplete({
source: "url",
minLength: 2,
select: function( event, ui ) {
$(this).val("");
return false;
});
C#, PHP, MySQL, JAVA, VB.NET, VBScript
'script' : 'uploadify/uploadify.php?name=imagename'//don't worry about the extension
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
if(isset($_GET['name'])){ $targetFile = str_replace('//','/',$targetPath) . $_GET['name']. substr($_FILES['Filedata']['name'],-4); } else{ $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']; }
function includeifexists($filename, $dir = ".", $level = 0, $found = false){
if (!$found){
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (filetype($dir."/".$file)=="dir") {
if($file!="." && $file!=".."){
if($file=="." || $file==".."){
} else{
$found = includeifexists($filename, $dir."/".$file, $level+1, $found);
}
}
}
else {
if($file==$filename){
include($dir."/".$file);
$found = true;
return $found;
}
}
}
closedir($dh);
}
}
}
return $found;
}
Step 1: Set connection string
string connectionString = "user id=" + your_user_id + ";" +
"password=" + your_password + ";" +
"server=" + server + ";" +
"Trusted_Connection=" + "yes" + ";" +
"database=" + database_name + "; " +
"connection timeout=" + "30" ;
'''the server name is your comuputer name\\SQL Server name
'''e.g. abccomputer\\SQLEXPRESS
Step 2: Connect using the connection string and open the connection
SqlConnection connection;
connection = new SqlConnection(connectionString);
connection.Open();
Step 3: Execute SqlCommand and Read output
string query = "SELECT * FROM Table1;";
SqlCommand sqlCommand1 = new SqlCommand(query, connection);
SqlDataReader dataReader = mSqlCommand.ExecuteReader();
Step 4: Read the output
string result = "";while (dataReader.Read())
{
result += mSqlDataReader["column1"];
result += mSqlDataReader["column2"];
result += mSqlDataReader["column3"];
result += Environment.NewLine;
}
MessageBox.Show(result);
Step 5: Close the connection
connection.Close();
Don't forget to add this line "using System.Data.SqlClient;" at the top of your program
\<\?php
//Step 1: connecting to database server
$connection = mysql_connect("localhost","root","");
//("server","user","password")
//Step 2: selecting a database
$sel_database = mysql_select_db("database_name"); //("name of the database that you want to connect to")
//Setp 3: doing the query
$query = "SELECT * FROM table1";
$result = mysql_query($query,$connection);
//Step 4: presenting retrieved data
while ($row = mysql_fetch_array($result)){
foreach($row as $value){
echo $value."\t";
}
echo "
";
}
//Step 5: closing the connection
mysql_close($connection);
?>
function isEmail($email){
$regex = "/\w+@\w+.\w+/";
return preg_match($regex, $email);
}
function isURL($url){
$regex = "/(https?ftpfile):\/\/.\w+.\w\w+/";
return preg_match($regex, $url);
}
function isIp($ip){
$block = "(25[012345]2[01234]\d[01]?\d\d?)";
$regex = "/^($block\.$block\.$block\.$block)$/";
return preg_match($regex, $ip);
}
function isMac($mac, $separator){
$mac = strtoupper($mac);
$block = "([A-F][A-F][A-F][0-9][0-9][A-F][0-9][0-9])";
$regex = "/^($block$separator$block$separator$block$separator$block$separator$block$separator$block)$/";
return preg_match($regex, $mac);
}
function isPrivateIp($ip){
// 10.0.0.0 – 10.255.255.255
// 172.16.0.0 – 172.31.255.255
// 192.168.0.0 – 192.168.255.255
$block = "(25[012345]2[01234]\d[01]?\d\d?)";
$rangeA = "/^(10)\.($block)\.($block)\.($block)$/";
$rangeB = "/^(172)\.(3[01]2[0-9]1[6-9])\.($block)\.($block)$/";
$rangeC = "/^(192)\.(168)\.($block)\.($block)$/";
$regex = "/^($block\.$block\.$block\.$block)$/";
if (preg_match($rangeA, $ip))
return true;
else if (preg_match($rangeB, $ip))
return true;
else if (preg_match($rangeC, $ip))
return true;
else if (preg_match($regex, $ip))
return false;
else
return false;
}
function getPrivateIpClass($ip){
// 10.0.0.0 – 10.255.255.255
// 172.16.0.0 – 172.31.255.255
// 192.168.0.0 – 192.168.255.255
$block = "(25[012345]2[01234]\d[01]?\d\d?)";
$rangeA = "/^(10)\.($block)\.($block)\.($block)$/";
$rangeB = "/^(172)\.(3[01]2[0-9]1[6-9])\.($block)\.($block)$/";
$rangeC = "/^(192)\.(168)\.($block)\.($block)$/";
$regex = "/^($block\.$block\.$block\.$block)$/";
if (preg_match($rangeA, $ip))
return "A";
else if (preg_match($rangeB, $ip))
return "B";
else if (preg_match($rangeC, $ip))
return "C";
else if (preg_match($regex, $ip))
return $ip." is not a private IP.";
else
return $ip." is not a valid IP.";
}
Example:
(C# : phpEchoReader.cs)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;namespace phpEchoReader {
class Program {
static void Main(string[] args) {
WebRequest req;
WebResponse response;
Stream output;
StreamReader reader;
req =
WebRequest.Create("http://localhost/index.php");
req.Method = "POST";
response = req.GetResponse();
output = response.GetResponseStream();
reader = new StreamReader(output);
while (!reader.EndOfStream)
{
Console.WriteLine(reader.ReadLine());
}
Console.WriteLine("Press any key too continue...");
Console.ReadLine();
}
}
}
(php code: index.php)
for ($i = 0; $i <>
echo $i."\n";
?>
Output: