-3

I have downloaded a contact form form the web. On one part (class.phpmailer.php) on line 470 it uses:

$toArr = split(',', $to);

Of course this is depreciated. I have searched the web for answers (and read the php syntax), and it says use explode() or preg_split().

I have tried both of these, but when I submit the contact form nothing happens. The data stays but the captcha changes. I also put:

$toArr = split('!,!', $to);

Again, the form would not submit.

Could somebody please tell me how to fix this ?

EDIT: The error was nothing to do with explode/preg_split - it was a missing html tag I believe.

lcolli98
  • 169
  • 1
  • 2
  • 18
  • Did you try `$toArr = explode(',', $to)`? – Explosion Pills Apr 01 '13 at 20:32
  • Use `explode` .. `split` is depreciated – Baba Apr 01 '13 at 20:32
  • 2
    @Baba OP already knows this. – Kermit Apr 01 '13 at 20:32
  • @ExplosionPills yes I did. It didn't work, the same problem with the submit button. – lcolli98 Apr 01 '13 at 20:34
  • 3
    Show your actual coding attempt regarding `explode`. – mario Apr 01 '13 at 20:35
  • 2
    @lukecolli98 are you sure that's the only issue? Maybe you're getting another error that you don't see – Explosion Pills Apr 01 '13 at 20:35
  • Can you clarify what you mean by "when I submit the contact form nothing happens"? The form doesn't submit/send anything to the server? It does submit, but there is no response from the action page? Or the action page looks correct, but it doesn't do what you expect it to? For that matter, what are you expecting it to do? I'm assuming you want it to send an email... can you clarify the exact goal or link to the source you downloaded? – Patrick M Apr 01 '13 at 20:36
  • is this an ajax form? so please check the console for error messages. – herrjeh42 Apr 01 '13 at 20:39
  • $toArr = explode (',', $to); DIDN'T WORK $toArr = preg_split (',', $to); GOT ERROR: preg_split(): No ending delimiter ',' – lcolli98 Apr 01 '13 at 20:44
  • Form from http://www.html-form-guide.com/contact-form/creating-a-contact-form.html – lcolli98 Apr 01 '13 at 20:45
  • I'm pretty sure your "form not submitting" problem or whatever it is is completely unrelated to using `explode` instead of `split`. – Mike Apr 01 '13 at 20:48
  • Maybe it is. What happens is: I fill in all fields and captcha. When I press submit the form stays on the page with all the fields still full of the data I entered, but the captcha goes blank. This happens ONLY when I use explode () but when I use preg_split () I get the delimiter error. – lcolli98 Apr 01 '13 at 20:51
  • You get a delimiter error because you aren't providing a valid regular expression pattern. – Mike Apr 01 '13 at 21:26
  • Ok, so what should the preg_split code be ? – lcolli98 Apr 02 '13 at 10:57

3 Answers3

6

You can use explode without problems:

$toArr = explode ( ',', $to );

Or you can use: preg_split() or str_split() or

Tomás Juárez
  • 1,389
  • 2
  • 16
  • 44
2

split() is indeed deprecated. You should instead use

$toArr = explode (',', $to);

This should work without problems.

user13955
  • 840
  • 1
  • 9
  • 23
  • 2
    Most amazing answer ever seen, looking at what the OP said :P (and no I did not -1 you) –  Apr 01 '13 at 20:34
  • Yep, didn't work. I mentioned above about the problem, this caused the same sumbit problem. – lcolli98 Apr 01 '13 at 20:39
  • $toArr = explode (',', $to); DIDN'T WORK $toArr = preg_split (',', $to); GOT ERROR: preg_split(): No ending delimiter ',' – lcolli98 Apr 01 '13 at 20:41
0
$toArr = explode(",", $to);

or

$toArr = explode(',', $to); 

should work, depending on what you want to do. See http://php.net/manual/en/function.explode.php for more information.

The fact that the form doesn't not submit when using explode shouldn't be related to the explode function, and a bug in the form itself is much more likely, but it's impossible to help you just with this bit of code. Please share more of the form code.