Reason for the error

The parent and child processes all share the same database connection. When the first child process exits it will disconnect from the database, which means the same connection all processes are using will be disconnected, causing any further queries to fail.

The solution

The solution is to disconnect from the database before forking the sub processes and then establish a new connection in each process. The fourth parameter also should be passed to the mysql_connect function as "true" to ensure a new link is established; the default is to share an existing connection is the login details are the same.

//fork the process to work in a daemonized environment
file_put_contents($log, 'Status: starting up
$pid = pcntl_fork();
if($pid == -1){
  file_put_contents($log, 'Error: could not daemonize process
  return 1; //error
else if ($pid)
  return 0;
  $connect = sql_connect($db_host, $db_user, $db_pass, $db_name);
  //the main process
    $result = SendEmailValidation();
    file_put_contents($log, $result, FILE_APPEND);
  }//end while
}//end if

open php with vi

and type:

set fileformat=unix 

Save it

개행문자를 한줄로 바꾸는 법
textarea 혹은 다른 device에서 글을 받을때 개행문자(\n)가 포함 되었을 경우가 있다.
이럴때 한줄로 만드는 방법은 아래와 같다.

b_content 필드의 내용중 "\\n" 혹은 "\n"을 " " 로 바꾸는 것
$_title = str_replace("\\n"," ",$b_content);
$_title = str_replace("\n"," ",$b_content);

+ Recent posts