Jump to content

AyKay47

Members
  • Posts

    3,281
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by AyKay47

  1. You need to turn off notices or define the variable before using it. I recommend turning notices off in production seen as variable initialisation is not required in PHP.

     

    Edit: Just looked at the code gain, make sure you haven't copy and pasted the variables testing the functions, you wont need them.

     

    This post makes little sense, and is downright wrong. Having the proper error reporting is imperative during the developmental stages, and since the OP has not specified what stage the site is in, I assume it's in development. Variable initialization is technically not required, but it should be exercised as good convention. Learning and exercising good practices from the beginning is very important in molding a "good programmer".

     

    OP, the errors you are being thrown are self explanatory. If you still cannot solve the issue after reviewing the code, post the updated code and we will be more than happy to help you further.

  2. Bubblychaz, I encourage you to study the code that you have been given so that you may find some of these errors yourself instead of asking as soon as you are thrown an error.

     

    Make sure that you have error_reporting() set to -1 and display_errors() set to 1 or 'on'. That way PHP will let you know when and where something goes wrong so you can debug the code yourself.

  3. As barand has stated, we need more information pertaining to your issue in order to give you an adequate answer.

    However I do notice some things right off the bat:

     

    You are using the concatenation operator .= on $random_vid which does not yet exist. This will trigger an E_USER_NOTICE error.

    Why do you pick 2 random numbers when you are only using one?

  4. Ok Thanks. So I would do something like:

     

    if (!preg_match("$images/", $_FILES['Image']['type']) )

    { die(" Please only use image files"); }

     

    replaced with

    if (strpos($_FILE['Image']['type'], 'images/') !== 0) { die(" Please only use image files"); }

     

    ? Or Am I misunderstanding?

     

    You are correct.

    However as a note, only use the die() function during development and not for production. Not very user friendly.

  5. I am on my way out the door, but I have come up with a possible solution to your issue. It is not pretty and I'm sure there is a much easier way to go about this, but this code will hopefully steer you in the right direction until someone else posts a better solution.

     

    $text = 'Lot Description|Flat|Yes;Lot Description|Adjoins Greenbelt|Yes;Lot Description|Wooded Lot|Yes;Lot Description|Irregular|Yes;Outside Features|Deck|Yes;Outside Features|Other - See Remarks|Yes;Outside Features|Utility Shed|Yes';
    $arr = explode(';', $text);
    $lotArr = array();
    foreach($arr as $val)
    {
    if(strpos($val, 'Lot Description') !== FALSE)
    {
    $i = str_replace('Lot Description|', '', $val);
    if(!isset($lotArr['Lot Description']))
     $lotArr['Lot Description'] = array();
    $lotArr['Lot Description'][] = $i;
    }
    if(strpos($val, 'Outside Features') !== FALSE)
    {
     $i = str_replace('Outside Features|', '', $val);
     if(!isset($lotArr['Outside Features']))
       $lotArr['Outside Features'] = array();
     $lotArr['Outside Features'][] = $i;
     }
    }
    
    foreach($lotArr['Lot Description'] as $key => $val)
    {
     if(strpos($val, '|Yes') !== FALSE)
       $lotArr['Lot Description'][$key] = str_replace('|Yes', '', $val);
    }
    foreach($lotArr['Outside Features'] as $key => $val)
    {
     if(strpos($val, '|Yes') !== FALSE)
       $lotArr['Outside Features'][$key] = str_replace('|Yes', '', $val);
    }
    print_r($lotArr);

     

    Results:

     

    Array
    (
    [Lot Description] => Array
    (
    [0] => Flat
    [1] => Adjoins Greenbelt
    [2] => Wooded Lot
    [3] => Irregular
    )
    
    
    [Outside Features] => Array
    (
    [0] => Deck
    [1] => Other - See Remarks
    [2] => Utility Shed
    )
    
    
    )
    

     

    As you can see, it splits the lot description properties and the outside features properties into two arrays. The above code assumes a number of things that need to be clarified. But again, this was done rather quickly and hopefully it will give you an idea.

  6. A side note, relying on a submit button value being passed with the form upon submission is unreliable. There are certain situations in certain browsers where the submit button value will not be passed when the form is submitted.

     

    I recommend either using

    $_SERVER['REQUEST_METHOD'] == 'POST'

    or a hidden input to check whether a form has been submitted.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.