Missing argument 1 for Illuminate\Support\Manager::createDriver() while sending mail in laravel - email

my .env file is:
MAIL_DRIVER=mail
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=587
MAIL_USERNAME=sabin.maharjan456#gmail.com
MAIL_PASSWORD=****************************
Mailer.php
<?php namespace App\Http\Controllers;
class Mailer{
public function sendTo($email, $subject, $view, $data = array())
{
\Mail::queue($view, $data, function($message) use($email, $subject)
{
$message->to($email)->subject($subject);
});
return "Mail has been sent";
}
public function welcome($formData)
{
$subject = "User Message was arrived !";
$data['name'] = $formData['name'];
$data['email'] = $formData['email'];
$data['mobile'] = $formData['mobile'];
$data['subject'] = $formData['subject'];
$data['bodymessage'] = $formData['message'];
$view = 'emails.welcome';
return $this->sendTo(['sabin.maharjan456#gmail.com'],$subject,$view,$data);
}
}
contoller:
public function postContactFormRequest(CreateContactFormRequest $request,Mailer $mailer)
{
$formData = $request->all();
$this->mailer->welcome($formData);
}
view file:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
</head>
<body>
<h2>User Message</h2>
<p><b>Email Address:</b> {{ $email }}</p>
<h4>User Name : {{ $name }}</h4>
<p> Phone Number :{{ $mobile}}</p>
<p>Message :{{ $bodymessage }} </p>
</body>
</html>
this is my file:
i get a continious error while trying to send email.
Missing argument 1 for Illuminate\Support\Manager::createDriver(), called in /home/robustit/public_html/nic-website/vendor/laravel/framework/src/Illuminate/Support/Manager.php on line 89 and defined

I have had issues with this until now.
What you want is to check your .env file and make sure your database parameters are right, but also you want these:
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
For some reason I got these to have empty fields. And then it worked for me!

Related

Zend : Error Occurs when create html file from zend phtml file for multiple employee

//controller function
function sendBulkMailAction(){
$template = "estimated-festival-bill-single.phtml";
foreach ($employeeArr as $profile_id => $employeeValue) {
$someData = array(); //here include some salary data
$model = new ViewModel($someData);
$model->setTemplate($template);
$htmlContent = "<!DOCTYPE html>\n\r<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\r<head>
<meta charset=\"utf-8\">
</head>
<body>"
. $this->getServiceLocator()->get('viewrenderer')->render($model)
. "</body>
</html>";
//create html file
//create pdf link from html by wkhtmlToPdf
//send this link via email to employee
}
}
//estimated-festival-bill-single.phtml
//simple code
<div> Employee Name</div>
<br>
<div><?php echo _get_salary_html(); ?></div>
<?php
function _get_salary_html(){
return "Salary Data";
}
?>
error show
Fatal error: Cannot redeclare _get_salary_html() (previously declared in G:\xampp\htdocs\ums\module\Hrm\view\hrm\salary-reports\estimated-salary-bill-single.phtml:9) in G:\xampp\htdocs\ums\module\Hrm\view\hrm\salary-reports\estimated-salary-bill-single.phtml on line 10
hints: when single employee its ok but for multiple employee show error
Because you are re-declaring function unknowingly. Add a condition around the function like below.
if (!function_exists('_get_salary_html')) {
function _get_salary_html() {
........
}
}

PHP: syntax error, unexpected 'echo' (t_echo)

A user accesses the Calculation.html first and enters two numbers following message. Then, select the operation from the drop-down box. When the user clicks the button, the web page displays the correct result by sending the data to the PHP file for evaluating the result. I have the PHP code here and whenever I run the code I keep getting an error.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Calculation Result</title>
</head>
<body>
<?php # handle_form.php
$num1 = $_REQUEST['number1'];
$num2 = $_REQUEST['number2'];
$operator = $_REQUEST['operator'];
if ($operator == 'add') {
echo $result = $num1+$num2;
}
esleif( $operator == 'subtract') {
echo $result = $num1-$num2;
}
esleif( $operator == 'multiply') {
echo $result = $num1*$num2;
}
esle( $operator == 'divide') {
echo $result = $num1/$num2;
}
echo "<p> The result is $result<p>";
?>
</body>
</html>

How to process the JSON data using .getJSON

My business functionality is to format JSON code returned from database and then use AJAX to process the JSON content and need to use only ".getJSON" instead of ".ajax"
The point where i was struck up is: how to sent the parameters using .getJSON to another page (customer.php) as i need to search for the customer data from database and return result in JSON formate.[The "data" parameter which holds key&value pair that needs to be sent to the server.]
Code from ajaxcall.php(where .getJSON is used)
<head>
<script>
$(document).ready(function(){
function search(){
var x=$("#srh").val();
if(x!=""){
$.getJSON({
url:'/customer.php',
data:{value:"x"},
success:function (data)
{
content= data;
$("#result").html(content[0].cust_id);
}
});
}
}
$("#button").click(function(){
search();
});
});
</script>
</head>
<body>
<input type="text" id="srh" placeholder="Enter the Name of the Customer"/>
<input type="button" id="button" value="search" />
<div id="result"></div>
</body>
Here, i need to pass the X parameter to customer.php using getJSON.The way i am passing is not working!
Code from customer.php(where i need to get search term (X parameter as input) $var=$_POST["value"]
and fetch the data from database using X parameter in where condition and return data in JSON content)
<?php
$conn = new mysqli("localhost", "xyz", "12345", "cust");
$var=$_GET['value'];
if (mysqli_connect_errno())
{ echo 'connect not possible to database: ' . mysqli_connect_error($conn); }
else
{
$query="SELECT cust_fname,cust_lname,cust_id,cust_addresa,cust_phone
from customer where UPPER(cust_lname) like UPPER('%" . $x. "%') ";
$result = mysqli_query($conn, $query);
if (!$result) { die("Not Found ! " . mysqli_error($conn)); }
else
{
$rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
$json = json_encode($rows);
}
mysqli_free_result($result);
mysqli_close($conn);
print $json;
}
} ?>
Appreciate your pointer on this! Thanks in Advance.

How to filter New WP Query by Custom Field Value?

I am creating new pages for each of my categories in wordpress. The post editor has a custom field that allows the selection of a sector type, this gets applied to the post on update. The custom field key is: sector, for custom field meta value options lets use SectorA, SectorB and SectorC. I am using a custom post type called projects.
I followed the advice at this link http://weblogtoolscollection.com/archives/2008/04/13/how-to-only-retrieve-posts-with-custom-fields/
How can I change the query line in the code below so that it filters the loop by a Sector name, lets use SectorA. I'll then reuse the code on each template page changing the value to SectorB and SectorC on the other pages.
I think this needs changing somehow:
$customPosts->query('showposts=5&sector=sectorA&post_type=projects' );
Currently it echos the sector value and description value successfully but is showing all the posts. So my attempt to limit it to sectorA using sector=sectorA doesn't seem to work?
This code is in functions.php:
function get_custom_field_posts_join($join) {
global $wpdb, $customFields;
return $join . " JOIN $wpdb->postmeta postmeta ON (postmeta.post_id = $wpdb->posts.ID and postmeta.meta_key in ($customFields)) ";
}
function get_custom_field_posts_group($group) {
global $wpdb;
$group .= " $wpdb->posts.ID ";
return $group;
}
And this code is on the Template Page:
<?php /* Begin Custom Field Posts */ ?>
<h2>Custom Posts</h2>
<ul>
<?php
global $customFields;
$customFields = "'sector', 'description'";
$customPosts = new WP_Query();
add_filter('posts_join', 'get_custom_field_posts_join');
add_filter('posts_groupby', 'get_custom_field_posts_group');
$customPosts->query('showposts=5&sector=sectorA&post_type=projects' );//Uses same parameters as query_posts
remove_filter('posts_join', 'get_custom_field_posts_join');
remove_filter('posts_groupby', 'get_custom_field_posts_group');
while ($customPosts->have_posts()) : $customPosts->the_post();
$sector = get_post_custom_values("sector");
$description= get_post_custom_values("description");?>
<li><?php echo $sector[0]; ?></li>
<li><?php echo $description[0]; ?></li><br />
<?php endwhile; ?>
</ul>
<?php /* End Custom Field Posts */ ?>
Thanks for your help
May be this what you want
function get_custom_field_posts_join($join) {
global $wpdb, $customSector;
return $join . " JOIN $wpdb->postmeta postmeta ON (postmeta.post_id = $wpdb->posts.ID and postmeta.meta_key = 'sector' and postmeta.value = '$customSector') ";
}
and modification of page
$customSector='sectorA';//<--- insert this
add_filter('posts_join', 'get_custom_field_posts_join');
Try using this code.
<?php
$sector = get_post_meta($post->ID, "sector", false);
if ($sector[0]=="") { ?>
<!-- If there are no custom fields, show nothing -->
<?php } else { ?>
<div class="sector">
<h3>Title</h3>
<?php foreach($sector as $sector) {
echo '<blockquote><p>'.$sector.'</p></blockquote>';
} ?>
</div>
<?php } ?>

Facebook iFrame APP not working in IE, works on every other browser

So im getting a blank page when loading this page within an iFrame on Internet explorer, every other browser works fine..
I have also tried using p3p headers as other people have suggested, but to no avail.
<?php
require ("connect.php");
require ("config.php");
require ("fb_config.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Login handler</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="css/login.css" type="text/css">
</head>
<body>
<?//=$user?>
<?php
if($user == 0) {
echo "You are not logged into facebook. Nice try.";
}else{
$query = "SELECT id,fb_id,login_ip,login_count,activated,sitestate FROM login WHERE fb_id='".mysql_real_escape_string($user)."'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
if (mysql_num_rows($result) == 0) {
$sql = "INSERT INTO login SET id = '', fb_id ='" .mysql_real_escape_string($user). "', name = '" .rand(10000000000000000,99999999999999999999). "', signup =NOW() , password = '" .mysql_real_escape_string($pass). "', state = '0', mail = '" .mysql_real_escape_string($_POST['mail']). "',location='".mysql_real_escape_string($randomlocation)."',location_start='".mysql_real_escape_string($randomlocation)."', signup_ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',ref='".mysql_real_escape_string($_POST['ref'])."', activation_id = '" .mysql_real_escape_string($activation_link). "',activated='2', killprotection = '$twodayprot',gender='" .mysql_real_escape_string($_POST["gender"]). "'";
$res = mysql_query($sql);
}
//if($row['fb_id'] != $user){
//echo "Your facebook ID: $user is NOT in the MW DB.";
//exit();
//}else{
if(empty($row['login_ip'])){
$row['login_ip'] = $_SERVER['REMOTE_ADDR'];
}else{
$ip_information = explode("-", $row['login_ip']);
if (in_array($_SERVER['REMOTE_ADDR'], $ip_information)) {
$row['login_ip'] = $row['login_ip'];
}else{
$row['login_ip'] = $row['login_ip']."-".$_SERVER['REMOTE_ADDR'];
}
}
$update_login = mysql_query("UPDATE login SET login_count=login_count+'1' WHERE name='".mysql_real_escape_string($_POST['username'])."'")
or die(mysql_error());
$_SESSION['user_id'] = $row['id'];
$result = mysql_query("UPDATE login SET userip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."',login_ip='".mysql_real_escape_string($row['login_ip'])."',login_count='0' WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'")
or die(mysql_error());
if ($row['sitestate'] == 0){
header("location: home.php");
} elseif ($row['sitestate'] == 2) {
header("location: killed.php?id={$row['id']}&encrypted={$row['password']}");
} else {
header("location: banned.php?id={$row['id']}&encrypted={$row['password']}");
}
}// id check.
?>
</body>
</html>
You're probably missing p3p headers causing your browser not to accept cookies from Facebook on your site.
See http://www.hanselman.com/blog/TheImportanceOfP3PAndACompactPrivacyPolicy.aspx
or http://www.admon.org/how-to-implement-p3p-http-headers-for-cross-site-cookies/ for more information.
Try removing the line that references your external css file and see if your page loads?
I just solved a similar problem I had. I had the correct p3p headers set up and I narrowed the problem down to css.
The problematic css style was a position:relative; on the html,body element - removing this fixed the problem of Facebook showing my iframe as a blank page.
If removing all the CSS displays something on your page, then you may need to add your CSS step-by-step to find out the culprit as some other kind of css sytle may break the page.