Facebook   Twitter    e-mail newsletter    YouTube    RSS Feed    Android App    iPhone and iPad App     BlackBerry App    

PHP Functions

  1. jan12345
    Thought it would be worth starting a discussion for php, It is sometimes frustrating even for a trained and qualified person to make sense of code, especially if the code your working on was written by someone else. This could be a place were you can share functions that helped you get by a bug of some sort.

    Below is a simple function that would ensure that certain characters for example: single quotes (') inserted into a input type "text" field will not screw up your MySQL syntax when the inserted text get stored in the DB regardless of the php configuration of the production server.

    function mysql_prep( $value ) {
    $magic_quotes_active = get_magic_quotes_gpc();
    $new_enough_php = function_exists( "mysql_real_escape_string" );
    if ( $new_enough_php ) {
    if ( $magic_quotes_active ) {
    $value = stripslashes( $value );
    }
    } else {
    if ( !$magic_quotes_active ) {
    $value = addslashes( $value );
    }
    }
    return $value;
    }

    Test it out and see!
  2. ibrahimali
    ibrahimali
    WORLD PRAYERS FOR UNITY, PEACE, HEALTH AND WEALTH SOLUTIONS
    Now 400 million research papers are available for peace
    solutions, but there is no result for it, unless the messages
    Posted in the website http://www.goldenduas.com are researched by researchers all over the world. Otherwise the world cannot have peace and
    Unity for some reasons or the other.
    Our website http://www.goldenduas.com contains more information not only
    to avoid all kinds of natural calamities in the world but also to
    improve economic growths in business, education, employment, jobs,
    health, wealth, security, faith, climate changes (heavy snow, rain, heat
    etc),and to cause unity and peace all over the world. Our service all
    over the world is a non-profitable service to all mankind and animals.
    Your Success
    U.IBRAHIM ALI.
  3. mushishi
    You can just use PDO with prepared statements instead of escaping, maybe use javascript to prompt the user to enter valid info.
Results 1 to 3 of 3