Jump to content

[SOLVED] Mysql / PHP Hanging after first run through


doa24uk

Recommended Posts

Hi guys,

 

Here's my script. The script is working as it should apart from the fact it's hanging on the first result. When I refresh the page (to re-run the script) it runs perfectly fine.

 

Why?? Could this code be optimised? Pretty sure it could!!

 

 


<?php
// CONNECT TO DB


// Select everything from DB
$result = mysql_query("SELECT * FROM table")
or die(mysql_error());  

// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {

//Define variables
$new = $row['linkurl'];
$url = $row['linkservice'];
$emailstatus = $row['emailstatus'];
$email = $row ['email'];
$origpage = $row['origpage'];



switch ($url){

        case "mysite.com":       
$file = file_get_contents($new);
$split = explode('Error',$file);
if (count($split) > 1 AND $emailstatus==N)
{

$headers = "From: ASite.com\r\n" .
    "X-Mailer: php";
$subject = "Email Subject";
$body = "Email body text";
mail($email, $subject, $body, $headers);

$result = mysql_query("UPDATE table SET emailstatus ='S', linkstatus ='D' WHERE linkurl='$new' AND email='$email'")
or die(mysql_error());
}
elseif (count($split) > 1 AND $emailstatus == Y) 
{
// Email already sent, update link status to be dead
$result = mysql_query("UPDATE table SET linkstatus ='D' WHERE linkurl='$new' AND userid='$userid'")
or die(mysql_error());

}
else {
// Link is live ... no action necessary
}
        break;
        
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.