Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    copied php form to new server - now it gives error codes?

    I am helping a nonprofit move their website to a new host - but I know nothing about php, which is what they use for their forms. I copied ALL the files off their old server onto a test folder on the new server, but the two forms on the new server do not work. (They are still working on the old server.)

    Below are the error codes I get when I click submit. Am I missing something on the new server that needs to be there? Thank you!!


    Warning: join() [function.join]: Invalid arguments passed in /home/lugec/public_html/mmm/submitform.php on line 87

    Warning: join() [function.join]: Invalid arguments passed in /home/lugec/public_html/mmm/submitform.php on line 145

    Warning: join() [function.join]: Invalid arguments passed in /home/lugec/public_html/mmm/submitform.php on line 147

    Warning: Cannot modify header information - headers already sent by (output started at /home/lugec/public_html/mmm/submitform.php:87) in /home/lugec/public_html/mmm/submitform.php on line 172

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You're using the implode/join function improperly. The parameters expected are either a single array, or an array and glue (in either order, but I would definitely recommend using the $glue first and the $array second so it follows the same argument requirements as explode).
    The header error will likely clear up once you fix you're join errors, from the looks of it its whining about the error tossed by the join.
    This function hasn't changed in like 5 versions, and when it did it was to use an optional $glue. The only reason why it appears to have changes is that you've always had these errors but you're previous host suppressed them while you're new host does not.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Apr 2006
    Location
    Planet Earth
    Posts
    59
    Thanks
    1
    Thanked 8 Times in 8 Posts
    Can you post the code on those lines? Please.

    But, my wild guess is that in your old server you had Register Globals ON and on the new server probably running PHP 5 has Register Globals OFF. Therefore your code does not work any more.

  • #4
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you for such fast replies! Here is the code on those lines (all the same):

    PHP Code:
    $answer70 join(", "$_POST['answer70']);
    $question71 $_POST['question71'];
    $answer71 join(", "$_POST['answer71']);
    $question72 $_POST['question72']; 

    Yes my new server is running php 5.2.9 -- and it does have register_globals Off
    Last edited by Muttsmeows; 09-04-2009 at 02:21 AM. Reason: adding info

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Is answer70 been defined as an html input array?
    As in, something like this:
    Code:
    <select name="answer70[]" multiple="multiple">
        <option value="......
    </select>
    ?

    Implode/join requires an array for its second parameter.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    Yea you're definitely not passing an array through the function. To achieve what you want you could simply do:

    PHP Code:
    $newLine $_POST['answer1'] . ', ' $_POST['question2'] . ', '
    etcetcetc..

    Implode (the other name for join) takes an array and glues it together like a string.

    Take this example, referring to what Fou-Lu was talking about

    PHP Code:
    <form action = "<?php $_SERVER['php_self'?>" method = "post" >
    <input type="text" name="a[]" />
    <input type="text" name="a[]" />
    <input type="text" name="a[]" />
    <input type="text" name="a[]" />
    <input type="text" name="a[]" />
    <input type="submit" />
    </form>

    <?php
    print_r
    ($_POST['a']);
    ?>
    Here we are making $_POST into a multidimensional array, so the $_POST array, now holds a new enumerated array called 'a'

    So if you're doing some sort of Q & A form, then all your inputs for answers could be something like name="answers[]" and all your questions could be like name="questions[]" and then you'd have two arrays, for answers and questions.

    Then glue them like

    PHP Code:
    $newanswerString implode(', '$_POST['answers']);
    $newquestionString implode(', '$_POST['question']); 
    Very simble.
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • Users who have thanked Zangeel for this post:

    Muttsmeows (09-04-2009)

  • #7
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes, its an input array, for questions that allows multiple selections for the answer. For example, one of the questions looks like this:

    Code:
    <input type="hidden" name="question70" value="How will your new dog spend its days">
    	  <select name="answer70[]" size="4" multiple id="answer70">  
    	  <option value="Indoors">Indoors</option>
    	  <option value="Crated">Crated</option>
    	  <option value="Basement">Basement</option>
    		  </select>
    So how would I modify

    PHP Code:
    $newLine $_POST['answer1'] . ', ' $_POST['question2'] . ', '
    for that?

    You all are so great for helping, thank you!

  • #8
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you for pointing me in the right direction. I ended up switching to checkboxes, and using this:

    PHP Code:
    $answer70 implode(", "$_POST['answer70']);
    echo 
    $answer70
    That only left me with the one header error msg, which I found a fix for by moving the header line from the bottom up to the very top.

    I have a headache but I'm happy its all working now! THANK YOU!
    Last edited by Muttsmeows; 09-04-2009 at 09:08 AM.

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Wait, are you saying that join won't work but implode does? Curious. Very curious, considering join is just a synonym for implode.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #10
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Maybe it was adding the echo lines and/or switching to checkbox instead of an option? I'll try just switching to checkboxes first when I work on the 2nd form (without changing it to implode) and will let you know!

    -- ok first I tried adding the echo lines, that didn't fix it, then moved the header line to the top, still didn't work... but changed the word join to implode (without even changing to check boxes) and BINGO it worked!

    Would have been a two minute fix had I known what I was doing.... might never have figured it out if it wasn't for this forum and your help. Thanks!
    Last edited by Muttsmeows; 09-04-2009 at 09:21 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •