http_build_query
//extract data from the post
extract($_POST);
//set POST variables
$url = 'http://domain.com/get-post.php';
$fields = array(
'lname'=>urlencode($last_name),
'fname'=>urlencode($first_name),
'title'=>urlencode($title),
'company'=>urlencode($institution),
'age'=>urlencode($age),
'email'=>urlencode($email),
'phone'=>urlencode($phone)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
< ?php
// from MySQL to UNIX timestamp
function convert_datetime($str)
{
list($date, $time) = explode(' ', $str);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
return $timestamp;
}
?>
iconv( “windows-1250″,”UTF-8″,$vsebina);
$country = trim(strip_tags(file_get_contents('http://www.melissadata.com/lookups/iplocation.asp?ipaddress='.$ip)));
$start = strpos($stringData,"State or Region");
$stop = strpos($stringData,"Country");
$country = substr($stringData,$start+39,$stop - $start-17);
< ?php
include 'config.php';
include 'opendb.php';
$query = 'SELECT * FROM news WHERE id="'.mysql_real_escape_string($_GET['id']).'"';
$result = mysql_query($query);
echo mysql_result($result, 2); // outputs third employee's name
while($row = mysql_fetch_assoc($result))
{
echo "Name :{$row['name']} <br>" .
"Subject : {$row['subject']} <br />" .
"Message : {$row['message']} <br /><br />";
}
UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value
include 'closedb.php';
?>
In da, končno sem našel odlični “barvalnik” programske kode, prav takšnega, kot sem si ga zamislil!
Code Highlighter plugin
Demo:
< ?php
$user="xxxxxx";
$password="yyyyyy";
$database="my_database";
@mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
@mysql_query("SET NAMES utf8"); //reši nekatere probleme pri šumnikih
?>