Skip to main content

Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #203453
    Ambee
    Participant

    Hi, i want to send email to my 600 clients through php email. but the loop works till 20 contacts, after that it show 500 internal server error. I am using http://hostforlife.eu server. Here is the script:
    “`<?php
    for($x=1;$x<=600;$x++)
    {
    $con = mysqli_connect("host","database","password");
    if (!$con){die('Could not connect: ' . mysqli_error($con));}
    mysqli_select_db($con,"database");
    $sql="SELECT email FROM emails Where id = ".$x;
    $result = mysqli_query($con,$sql);
    $row = mysqli_fetch_array($result);
    $to = $row['email'];
    if ($to == "NULL")
    {

    }
    else
    {
    echo $row['email'];
    mysqli_close($con);
    // mail($to,"subject","message");
    sleep(2);
    }
    }
    ?>
    “`

    #203459
    Ilan Firsov
    Participant

    Why the sleep()?
    Your script probably times-out, try setting set_time_limit(0) at the top of the file.
    Also with any 500 error you want to check the server logs – they usually note what happened.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.