Forums

Give help. Get help.

  • # June 9, 2015 at 1:57 am

    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);
    }
    }
    ?>
    “`

    # June 9, 2015 at 2:33 am

    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)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag