• PHP, Tutorials

    Posted on October 13th, 2009

    Written by Behrouz Pooladrag

    Tags

    , , , , ,

    Smart Sample Post PHP vars without form (cURL)

    Smart Sample Post PHP vars without form (cURL)

    Smart Sample Post PHP vars without form (cURL)
    You have to have cURL enabled.
    Take a look:
    <?php
    $email = $_POST['email'];
    $ch = curl_init(‘http://www.aweber.com/scripts/addlead.pl’);
    curl_setopt ($ch, CURLOPT_POST, 1);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, “from=”.$email.”&name=somename
    &meta_web_form_id=1829234431&meta_split_id=&unit=rm101-sign-up
    &redirect=http://www.aweber.com/form/thankyou_vo.html&
    meta_redirect_onlist=&meta_adtracking=&meta_message=1
    &meta_required=from&meta_forward_vars=0″);
    curl_exec ($ch);
    curl_close ($ch);
    ?>
    oops , Finish

  • PHP, Tutorials

    Posted on October 11th, 2009

    Written by Behrouz Pooladrag

    Tags

    ,

    Basic Using the PHP Include Command

    Basic Using the PHP Include Command

    This tutorial will teach you the very basics on how to use a PHP #include command. The #include command is used to insert the content of an external HTML page into an existing PHP page. For example, the header and footer of this page you are reading right now are actually external files which are [...]

  • PHP, Tutorials

    Posted on October 9th, 2009

    Written by Behrouz Pooladrag

    Tags

    , ,

    Convert MYSQL to JSON by PHP

    Convert MYSQL to JSON by PHP

    I did not find any function to convert the result of a MySQL query directly into JSON notation, so I made my own function.

    function mysql2json($mysql_result,$name){
    $json="{\n\"$name\": [\n";
    $field_names = array();
    $fields = mysql_num_fields($mysql_result);
    for($x=0;$x&lt; $fields;$x++){
    $field_name = mysql_fetch_field($mysql_result, $x);
    if($field_name){
    $field_names[$x]=$field_name-&gt;name;
    }
    }
    $rows = mysql_num_rows($mysql_result);
    for($x=0;$x&lt; $rows;$x++){
    $row = mysql_fetch_array($mysql_result);
    $json.="{\n";
    for($y=0;$y&lt;count($field_names);$y++) {
    $json.="\"$field_names[$y]\" :    \"$row[$y]\"";
    if($y==count($field_names)-1){
    $json.="\n";
    }
    else{
    $json.=",\n";
    }
    }
    if($x==$rows-1){
    $json.="\n}\n";
    }
    else{
    $json.="\n},\n";
    }
    }
    $json.="]\n};";
    return($json);
    }
    The first parameter is the result of the query, without any parsing, just the [...]

  • PHP, Tutorials

    Posted on October 9th, 2009

    Written by Behrouz Pooladrag

    Tags

    , ,

    Connection speed with php

    Connection speed with php

    One of the hardest script you can find in internet is the one that determines connection speed of a surfer visiting our site.
    From today it’s not anymore a problem (even if nobody had nightmares before…) because we will make a php script in order to fill such lack.
    Let’s start coding…

    <?php
    $kb=512;
    echo “streaming $kb Kb…<!-”;
    flush();
    $time = explode(” [...]