1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

PHP Puzzle

Discussion in 'Programming & Webmastering' started by Moose, Dec 9, 2009.

  1. Moose

    Moose New Member

    Joined:
    Sep 1, 2007
    Messages:
    306 (0.12/day)
    Thanks Received:
    26
    Location:
    UK
    I basically want it to NOT
    PHP:
    "UPDATE content SET logo = '$logo'"
    if $logo is blank, so im thinking put in an *if* but I dont know how to say logo is not ""
    So I want
    PHP:
    if ($logo does not ""){
    after the $db_found bit.
    Heres the part of the code in question:
    PHP:
    if ($_SERVER['REQUEST_METHOD'] == 'POST'){
        
    $logo $_POST['logo'];

    $username "root";
    $password "Password";
    $database "moose";
    $server ":/home/moose/private/mysql/socket";

    $db_handle mysql_connect($server$username$password);
    $db_found mysql_select_db($database$db_handle);

    if (
    $db_found) {
    $SQL "UPDATE content SET logo = '$logo'";

    mysql_query($SQL);

    mysql_close($db_handle);
    }

    }
     
  2. Jizzler

    Jizzler

    Joined:
    Aug 10, 2007
    Messages:
    3,418 (1.31/day)
    Thanks Received:
    637
    Location:
    Geneva, FL, USA
    Does not equal is "!="

    Can put it up front, so that if it's empty, cycles aren't wasted creating a connection.

    PHP:
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['logo'] != '') {
     
    Moose says thanks.
  3. Moose

    Moose New Member

    Joined:
    Sep 1, 2007
    Messages:
    306 (0.12/day)
    Thanks Received:
    26
    Location:
    UK
    Aha thanks for that that helps with the rest of the script too!
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)

Share This Page