Hit a Problem :/

Discussion in 'PHP' started by NateJ, May 25, 2009.

  1. #1
    Well, For some reason the below piece of scripture doesn't work.

    Can anyone see a fault within the piece?

    if so, please let me know.

    $add_item = $_POST['add_list'];
    $price = $_POST['price'];
    $anonymity = $_POST['anonymity'];
    
    $country_item = $_POST['country_item'];
    $location = $_POST['item_location'];
    
    if ($add_item && $country_item && $price){
    if ($country_item == "Race Track" || $country_item == "Slots"){
    $check_country = mysql_num_rows(mysql_query("SELECT * FROM casinos WHERE owner='$username' AND location='$location' AND casino='$country_item'"));
    if ($check_country == "0"){ echo "You don't own this item!"; }else{
    mysql_query("UPDATE casinos SET detail='1' WHERE owner='$username' AND location='$location' AND casino='$country_item'");
    $timeleft = time() + (3600 * 24 * 2);
    if ($anonymity == "Not Anonymous"){
    mysql_query("INSERT INTO `nate_global`.`trade_center` (`id` ,`item` ,`seller` ,`price` ,`time_left` ,`item_id` ,`anonymous` ,`type`) VALUES (
    '', '$country_item ($location)', '$username', '$price', '$timeleft', '$location', '0', '$country_item');");
    echo "You listed a $country_item for trade!";
    }elseif ($anonymity == "Anonymous"){
    mysql_query("INSERT INTO `nate_global`.`trade_center` (`id` ,`item` ,`seller` ,`price` ,`time_left` ,`item_id` ,`anonymous` ,`type`) VALUES (
    '', '$country_item ($location)', '$username', '$price', '$timeleft', '$location', '1', '$country_item');");
    echo "You listed a $country_item for trade!";
    }}}}
    PHP:
    When $country_item == "Slots" It works, but not when Race Track is the $country_item :confused:

    Any Help will be appreciated.

    Thanks,
    NateJ
     
    NateJ, May 25, 2009 IP
  2. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #2
    Is the POST information URL Encoded? If so, it will not equal "Race Track". The POST value would be "Race+Track". Debug the code to make sure.
     
    Social.Network, May 25, 2009 IP
  3. yoes_san

    yoes_san Peon

    Messages:
    443
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    1. Try putting "echo $country_item;" after you assigned its value to see whether it comes up as "Race Track"
    2. If it returns "You don't own this item!" message then it means you didn't have "Race Track" records in DB
     
    yoes_san, May 25, 2009 IP
  4. AbhishekS

    AbhishekS Peon

    Messages:
    309
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    When country_item is Race Track. Is add_item and price also set?
    and use isset and !empty for checking post inputs rather than a boolean check. Also clean your input.
     
    AbhishekS, May 25, 2009 IP
  5. NateJ

    NateJ Active Member

    Messages:
    240
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #5
    It didn't echo the $country_item, however, The "You Don't Own this item!" message did appear, But, There is records in the database with "Race Track"

    Also, There may be a fault here, but i doubt it.

    ------------------------------------------------------------
    It's come to my attention that Spaces within Option values don't work, so i've put   however...

    if ($country_item == "Race Track" || $country_item == "Slots"){

    Stops the rest of the script from executing, i've tried a few ways around this; one way being:

    if ($country_item == "Race Track" || $country_item == "Slots"){

    Which didn't work.

    Anyone got alternatives?
     
    NateJ, May 26, 2009 IP
  6. yoes_san

    yoes_san Peon

    Messages:
    443
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    try adding double quote to <option value="Race Track">Race Track</option>

    actually add it to all <option> for that matters. I guess "Bullet Factory" is not found too
     
    yoes_san, May 26, 2009 IP
    NateJ likes this.
  7. NateJ

    NateJ Active Member

    Messages:
    240
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #7
    That did the trick, Thanks. Rep Given.
     
    NateJ, May 26, 2009 IP
  8. Chikey.ru

    Chikey.ru Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    no! no!


    <option value=Race Track>Race Track</option></select></td>

    WHERE is double QUOES??
    be more carefull with W3C standarts!))
     
    Chikey.ru, May 26, 2009 IP