Why does laravel queue ignore my timeout value? - php

why is my queue job timing out? I am using database as a driver I tried the following:
class PdfGenerator implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $userData;
protected $filename;
protected $path;
public $timeout = 1200;
/**
* Create a new job instance.
*
* #return void
*/
public function __construct($userData, $filename)
{
//
$this->userData = $userData;
$this->filename = $filename;
$this->path = \public_path('\\pdfs\\'.$this->filename.'.pdf');
}
/**
* Execute the job.
*
* #return void
*/
public function handle()
{
$pdf = App::make('snappy.pdf.wrapper');
$footer = \view('supporting.footer')->render();
$header = \view('supporting.header')->render();
//$userData = \collect([$this->userData[1]]);
$pdf->loadView('order_clean', ['users' => $this->userData])
->setOption('margin-top', '20mm')
->setOption('margin-bottom', '20mm')
->setOption('minimum-font-size', 25)
->setOption('header-html', $header)
->setOption('footer-html', $footer);
$pdf->save($this->path);
}
}
php artisan queue:work --timeout=1200
php artisan queue:listen --timeout=0
yet my queue job still fails due to timeout of 60s according to the logs because the symfony process timed out. I am not using supervisor yet, just trying out how the queue works from the console
edit:: controller code + blade code
controller code:
class OrderController extends Controller
{
public function renderPDF()
{
$user_data = $this->getUserData();
$filename = 'test '.\now()->timestamp;
//no timeouts here
//if not ran on queue and with set_time_limit, takes around 70s
//at current data size
$this->dispatch(new PdfGenerator($user_data,$filename));
//view returns successfully
return \view('test.test', ['filename'=>$filename]);
}
}
Blade file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Order Layout</title>
<style>
*{
font-family: cursive;
}
.wrapper {
display: block;
}
.invoice {
display: block;
width: 80%;
margin: 0 auto;
margin-top: 10px;
padding-top: 10px;
padding-bottom: 10px;
background: #d3d3d3;
page-break-inside: avoid !important;
padding-left: 20px;
}
.order-items {
padding-left: 100px;
}
.table {
width: 90%;
align-self: center;
border: 1px solid black;
orphans: 15;
}
.table>* {
text-align: center;
}
</style>
</head>
<body>
<main class="wrapper">
#foreach ($users as $user)
#php
$orders = $user->orders //just for renaming
#endphp
#foreach ($orders as $order)
<div class="invoice">
#php
$sum=0;
#endphp
<h2>{{$user->name}}: {{$order->id}}</h2>
<div class="order-items">
<table class="table" border="1">
<thead>
<tr>
<th>Product Name</th>
<th>Unit Price</th>
<th>Qty</th>
<th>subtotal</th>
</tr>
</thead>
<tbody>
#foreach ($order->products as $product)
<tr>
<th>
{{$product->name}}<br>
{{$product->name}}<br>
{{$product->name}}<br>
{{$product->name}}<br>
</th>
<td>{{$product->unit_price}}</td>
<td>{{$product->pivot->quantity}}</td>
#php
$sum+= $product->pivot->quantity*$product->unit_price
#endphp
<td>{{$product->pivot->quantity*$product->unit_price}}</td>
</tr>
#endforeach
</tbody>
<tfoot>
<tr>
<th colspan="3">Total:</th>
<td>{{$sum}}</td>
</tr>
</tfoot>
</table>
</div>
</div>
#endforeach
#endforeach
</main>
</body>
</html>

If you want to be able to set the timeouts you should make sure you have the pcntl PHP extension installed and enabled.
"The pcntl PHP extension must be installed in order to specify job timeouts."
Laravel 8.x Docs - Queues - Dispatching Jobs - Specifying Max Job Attempts / Timeout Values - Timeout

Related

MPDF - table border and cell boders are not showing with css but HTML is working

I am using laravel framework. here in my code HTML table view is ok.But when i am converting the same to pdf using mpdf, the table is displaying without any borders. i am using css in same html. no external style sheets are included
my code is here
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<style>
td{
border-top: 1px dotted black;
border-bottom: 1px dotted black;
border-left: 1px dotted black;
border-right: 1px dotted black;
}
table {
margin-left: 5px;
border: 1px solid black;
}
td {
border: 1px solid black;
}
</style>
<title>Document</title>
</head>
<body>
<table class="pdf">
<thead>
<tr>
<th>Name</th>
<th>Phone</th>
<th>Password</th>
<th>Role ID</th>
</tr>
</thead>
<tbody style="font-size: 14px;">
#foreach ($users as $user)
<tr>
<td>{{ $user->name }}</td>
<td>{{ $user->mobile }}</td>
<td style="width: 20%;">{{ $user->password }}</td>
<td>{{ $user->department_id }}</td>
<td>{{ $user->i }}</td>
</tr>
#endforeach
</tbody>
</table>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.3/dist/umd/popper.min.js"
integrity="sha384-eMNCOe7tC1doHpGoWe/6oMVemdAVTMs2xqW4mwXrXsW0L84Iytr2wi5v2QjrP/xp" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.0/dist/js/bootstrap.min.js"
integrity="sha384-cn7l7gDp0eyniUwwAZgrzD06kc/tftFf19TOAs2zVinnD/C7E91j9yyk5//jjpt/" crossorigin="anonymous">
</script>
</body>
</html>
Here is my controller
<?php
namespace App\Http\Controllers;
use App\Models\User;
use Illuminate\Http\Request;
use Mpdf\Mpdf;
use Illuminate\Support\Facades\View;
// use phpDocumentor\Reflection\PseudoTypes\False_;
class PdfController extends Controller
{
public function index()
{
$users = User::all();
return view('pdf',compact('users'));
}
public function generate()
{
require_once base_path('vendor/autoload.php');
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
$custom_font_path = storage_path().'\fonts';
// dd($custom_font_path);
$mpdf = new \Mpdf\Mpdf([
'fontDir' => array_merge($fontDirs, [
$custom_font_path,
]),
'fontdata' => $fontData + [
'gayathri' => [
'R' => 'Gayathri-Regular.ttf',
'useOTL' => 0xFF,
]
],
'default_font' => 'gayathri'
]);
$mpdf->SetFont('dejavusanscondensed');
$mpdf->simpleTables=true;
// $mpdf->packTableData=true;
// $mpdf->keep_table_proportions=TRUE;
// $mpdf->shrink_tables_to_fit=1;
// $users = User::all();
// foreach($users as $user)
// {
// $mpdf->WriteHTML('<p style="font-size:28px;">'. $user->name .'</p> ');
// }
// calculate two numbers
$users = User::all();
$view = View::make('pdf', compact('users'));
$mpdf->WriteHTML($view);
$mpdf->Output();
}
}
In the generated pdf there is no borders but cell divisions and other layouts are ok, how to include borders for the entire table.( including cells, colums etc)
Don't use the style tag. Try to use stylesheet instead:
$stylesheet = file_get_contents('css/style.css');
//CSS
$mpdf->WriteHTML($stylesheet, \Mpdf\HTMLParserMode::HEADER_CSS);//This is css/style only and no body/html/text
//BODY
$mpdf->WriteHTML($html,\Mpdf\HTMLParserMode::HTML_BODY);//This is html content, without <head> information.
Check out this documentation.
Until now that I am dropping some lines here, there is still something wrong with MPDF when dealing with table borders.
When you style <td> and add border there, what you can see in the output is just border left and border right, and no border top and border down. For me, so as to bypass the problem, I styled both and to get all the borders working, that is top, bottom, right, and left. I just shared my solution in case someone would find it useful.
table td, table th, table tr {
border: 1px solid #c9c9c9 !important
}

Locale Get Ignored When Sending Mail with Queue

I'm looking for an answer. Laravel Framework 5.5.44
and I have a queue that will send an email whenever someone place new order on my website. I used event and listener to accomplish this. My queue successfully sent the email but my locale code does not working. Below is my code :
NewOrderListener.php
public function handle($event)
{
try {
dump('new order registered (listernerrr)');
// dump($event->order);
$email = $event->order['email'];
// $logo_settings_details = Settings::get_logo_settings_details();
// // dump($logo_settings_details);
// $event->order->prepend('logo_settings_details', DB::table('gr_logo_settings')->get());
// array_push($event->order, DB::table('gr_logo_settings')->get());
$event->order['logo_settings_details'] = DB::table('gr_logo_settings')->get();
// $data = [
// 'logo_settings_details' => DB::table('gr_logo_settings')->get(),
// ];
// dd($data);
$get_images = DB::table('gr_no_images')->select('banner_image','restaurant_store_image','restaurant_item_image','product_image','logo_image','landing_image','shop_logo_image','category_image')->first();
if(empty($get_images) === false)
{
$no_item = $get_images->restaurant_item_image;
$event->order['no_item'] = $no_item;
}
$this->general_setting = DB::table('gr_general_setting')->get();
if(count($this->general_setting) > 0){
foreach($this->general_setting as $s){
$event->order['FOOTERNAME'] = $s->footer_text;
}
}
else {
$event->order['FOOTERNAME'] = 'ePickMeUp';
}
// dd($event->order);
Mail::send('email.order_mail_customer', $event->order, function($message) use($email)
{
dump($email);
// $sub_data = (Lang::has(Session::get('front_lang_file').'.FRONT_ORDER_SUCCSESS')) ? trans(Session::get('front_lang_file').'.FRONT_ORDER_SUCCSESS') : trans($this->FRONT_LANGUAGE.'.FRONT_ORDER_SUCCSESS');
// dump($sub_data);
$message->to('googleadmin#gmail.com')->subject('SUCCESSFUL ORDER 😍');
dump('email sent');
});
} catch (\Exception $e) {
// Log Error
// Log::error($e->getMessage());
// Sent Error To Slack
// Dump Error
dump($e->getMessage());
}
}
order_mail_customer.blade.php
<td style="border-top: 5px solid #f7d501;">
<table style="padding:10px;width:100%;">
<tr>
<td align="center">
#php $path = url('').'/public/images/noimage/default_image_logo.jpg'; #endphp
#if(count($logo_settings_details) > 0)
#php
foreach($logo_settings_details as $logo_set_val){ }
#endphp
#if($logo_set_val->admin_logo != '')
#php $filename = public_path('images/logo/').$logo_set_val->admin_logo; #endphp
#if(file_exists($filename))
#php $path = url('').'/public/images/logo/'.$logo_set_val->admin_logo; #endphp
#endif
#endif
#endif
<img src="{{$path}}" alt="#lang(Session::get('front_lang_file').'.ADMIN_LOGO')" class="img-responsive logo" width="100">
</td>
</tr>
</table>
</td>
</tr>
#if($self_pickup==1)
<tr>
<td>
<table style="width:100%;background:url('{{url('public/images/order_image.jpg')}}')no-repeat; padding:56px 20px;">
<tr>
<td colspan="1" style="text-align:center; font-family:cursive; font-size:35px; padding-bottom: 20px; color: #fff;">
#lang(Session::get('front_lang_file').'.FRONT_THANK_ORDER')
</td>
</tr>
<tr>
<td style="text-align:center; font-family:sans-serif; font-size:17px; padding-bottom: 20px; color: #fff; line-height: 25px;">
#lang(Session::get('front_lang_file').'.API_ORDER_PLACED')
</td>
</tr>
<tr>
<td style="text-align:center; font-family:sans-serif; font-size:17px; padding-bottom: 20px; color: #fff; line-height: 25px;">
#lang(Session::get('front_lang_file').'.ADMIN_TRANSACTION_ID') : {{$transaction_id}}
</td>
</tr>
</table>
</td>
</tr>
Why all those #lang(Session::get('front_lang_file') not getting called on queue? Hopefully, someone could help me to solve this problem. Thanks in advance.
Because Queue Job run in process which is diffirent from session process, so, you can't access session ( locale in this case ) . You need pass session as argument for constructor of Job. smth like :
NewOrderListener::dispatch(Event $event, Session $session)

How to send email notification in Laravel and MailTrap

I am trying to send an HTML template to MailTrap using this method
public function send($result_id)
{
$result = Result::whereHas('user', function ($query) {
$query->whereId(auth()->id());
})->findOrFail($result_id);
\Mail::to('test#eam.com')->send(new ResultMail);
return view('client.result', compact('result'))->withStatus('Your test result has been sent successfully!');
}
with the result.blade.file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test No. {{ $result->id }}</title>
<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css" />
<style type="text/css">
html {
margin: 0;
}
body {
background-color: #FFFFFF;
font-size: 10px;
margin: 36pt;
}
</style>
</head>
<body>
<p class="mt-5">Total points: {{ $result->total_points }} points</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Question Text</th>
<th>Points</th>
</tr>
</thead>
<tbody>
#foreach($result->questions as $question)
<tr>
<td>{{ $question->question_text }}</td>
<td>{{ $question->pivot->points }}</td>
</tr>
#endforeach
</tbody>
</table>
</body>
</html>
but I'm get an error
Undefined variable: result (View: C:\Users\USER\Documents\Laravel-Test-Result-PDF-master\Laravel-Test-Result-PDF-master\resources\views\client\result.blade.php)
Well, as far as I know, you need to have Mailable class and from the mailable class, you need to return the view and pass the data there.
You'r mailable class should
class ResultMail extends Mailable
{
use Queueable, SerializesModels;
public $result;
/**
* Create a new message instance.
*
*/
public function __construct($result)
{
$this->result = $result;
}
/**
* Build the message.
*
* #return $this
*/
public function build()
{
return $this->view('client.result');
}
}
Should be something like this.And then you need to pass the data to ResultMail
\Mail::to('test#eam.com')->send(new ResultMail($result));

Laravel barryvaddh - dompdf undefined property error

In my education resources controller system, we have to prepare progress reports for student.To get these reports as a pdf I used Laravel dom-pdf.
code of pdfGeneratorController
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Subject;
use PDF;
class pdfGenerator extends Controller
{
public function reportPdf()
{
$users = DB::table('users')->get();
$subjects = DB::table('subjects')->get();
$pdf = PDF::loadview('reports', ['users' => $users],['subjects' => $subjects]);
// $pdf = PDF::loadview('reports', ['subjects' => $subjects]);
return $pdf->download('report.pdf');
}
public function report()
{
// $users = DB::table('users')->get();
$users = DB::table('users')
->join('subjects','users.id','=','subjects.user_id')
->join('marks','subjects.user_id','=','subjects.user_id')
->select('users.*','subjects.subject','marks.marks')
->get();
//$subject = Subject::all();
// return $subject;
return view('reports', ['users' => $users]);
}
}
codes of reports.blade.php
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<h1><a href="{{url('/pdfs')}}" > Download pdf</a></h1>
<table>
<caption>Student Details</caption>
<tr>
<td>Name</td>
<td> lname </td>
<td>subject</td>
<td>marks</td>
</tr>
#foreach($users as $user)
<tr>
<td>{{ $user->name}}</td>
<td>{{ $user->lname}}</td>
<td>{{ $user->subject}}</td>
<td>{{ $user->marks}}</td>
#endforeach
</tr>
</table>
</body>
</html>
When I click reports link it shows all the relevant data webpage. but when i click print pdf link it gives a error.the error of this time is ErrorException
Undefined property: stdClass::$subjects (View: E:\nimnayawebsite\resources\views\reports.blade.php)
You are passing two array with comma separated value, pass it making one array.
Change this line-
$pdf = PDF::loadview('reports', ['users' => $users],['subjects' => $subjects]);
To this-
$pdf = PDF::loadview('reports', ['users' => $users,'subjects' => $subjects]);
You're trying yo use $user->subject in the view. Since report() method works for you with the same view, change this:
$users = DB::table('users')->get();
$subjects = DB::table('subjects')->get();
To:
$users = DB::table('users')
->join('subjects','users.id','=','subjects.user_id')
->join('marks','subjects.user_id','=','subjects.user_id')
->select('users.*','subjects.subject','marks.marks')
->get();

Php Error Message " Uncaught exception 'Exception' with message 'Query Failed:Array"

I tried to render a table from MS-SQL Database to Webpage and i get this error.
I'm still new in PHP. Please help
Useraccess.php
<?php
$path = dirname(__FILE__);
require_once(dirname(__FILE__)."/simpleusers/config.inc.php");
$SimpleUsers = new SimpleUsers();
$users = $SimpleUsers->getUsers();
class SimpleUsers
{
private $mysqli , $stmt;
private $conn;
private $sessionName = "SimpleUsers";
public $logged_in = false;
public $userdata;
public $uPassword;
public $salt;
public function getUsers()
{
$sql = "SELECT DISTINCT userId, uUsername, uActivity, uCreated FROM users ORDER BY uUsername ASC";
$stmt = sqlsrv_query($this->conn, $sql);
if( $stmt == false){
throw new Exception("Query Failed:".sqlsrv_errors());
}
$stmt->execute();
$stmt->store_result();
if( $stmt->num_rows == 0){
return array();
}
$users = array();
$i = 0;
while( $stmt->fetch() )
{
$users[$i]["userId"] = $userId;
$users[$i]["uUsername"] = $username;
$users[$i]["uActivity"] = $activity;
$users[$i]["uCreated"] = $created;
$i++;
}
}
}
?>
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
* { margin: 0px; padding: 0px; }
body
{
padding: 30px;
font-family: Calibri, Verdana, "Sans Serif";
font-size: 12px;
}
table
{
width: 800px;
margin: 0px auto;
}
th, td
{
padding: 3px;
}
.right
{
text-align: right;
}
h1
{
color: #FF0000;
border-bottom: 2px solid #000000;
margin-bottom: 15px;
}
p { margin: 10px 0px; }
p.faded { color: #A0A0A0; }
</style>
</head>
<body>
<h1>User administration</h1>
<table cellpadding="0" cellspacing="0" border="1">
<thead>
<tr>
<th>Username</th>
<th>Last activity</th>
<th>Created</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" class="right">
Create new user | Logout
</td>
</tr>
</tfoot>
<tbody>
<?php foreach
( $users as $user ): ?>
<tr>
<td><?php echo $user["uUsername"]; ?></td>
<td class="right"><?php echo $user["uActivity"]; ?></td>
<td class="right"><?php echo $user["uCreated"]; ?></td>
<td class="right">Delete | User info | Change password</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
config.inc.php
<?php
$GLOBALS["serverName"] = "DESKTOP-KRF6KT7\SQLEXPRESS";
$GLOBALS["database"] = "SimpleUsers";
$GLOBALS["uid"] = "sa";
$GLOBALS["pwd"] = "twinz0000";
$GLOBALS["connectionInfo"] = array(
"Database"=>$GLOBALS["database"],
"UID"=>$GLOBALS["uid"],
"PWD"=>$GLOBALS["pwd"])
?>
Error Displayed
Warning: sqlsrv_query() expects parameter 1 to be resource, null given in C:\Users\Adam\Desktop\SimpleUsers MSSQL\Useraccess.php on line 26
Notice: Array to string conversion in C:\Users\Adam\Desktop\SimpleUsers MSSQL\Useraccess.php on line 29
Fatal error: Uncaught exception 'Exception' with message 'Query Failed:Array' in C:\Users\Adam\Desktop\SimpleUsers MSSQL\Useraccess.php:29 Stack trace: #0 C:\Users\Adam\Desktop\SimpleUsers MSSQL\Useraccess.php(8): SimpleUsers->getUsers() #1 {main} thrown in C:\Users\Adam\Desktop\SimpleUsers MSSQL\Useraccess.php on line 29
Your conn class property is not set.
Before you call $stmt = sqlsrv_query($this->conn, $sql); you must set it up in sqlsrv_connect.
Try adding construct:
public function __construct()
{
$this->conn = sqlsrv_connect($GLOBALS["serverName"], $GLOBALS["connectionInfo"]);
}
Useraccess.php
<?php
$path = dirname(__FILE__);
require_once(dirname(__FILE__)."/simpleusers/config.inc.php");
$SimpleUsers = new SimpleUsers();
$users = $SimpleUsers->getUsers();
class SimpleUsers
{
private $mysqli , $stmt;
private $conn;
private $sessionName = "SimpleUsers";
public $logged_in = false;
public $userdata;
public $uPassword;
public $salt;
public $conn=$GLOBALS["conn"] ;
public function getUsers()
{
$sql = "SELECT DISTINCT userId, uUsername, uActivity, uCreated FROM users ORDER BY uUsername ASC";
$stmt = sqlsrv_query($this->conn, $sql);
if( $stmt == false){
throw new Exception("Query Failed:".sqlsrv_errors());
}
$stmt->execute();
$stmt->store_result();
if( $stmt->num_rows == 0){
return array();
}
$users = array();
$i = 0;
while( $stmt->fetch() )
{
$users[$i]["userId"] = $userId;
$users[$i]["uUsername"] = $username;
$users[$i]["uActivity"] = $activity;
$users[$i]["uCreated"] = $created;
$i++;
}
}
}
?>
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
* { margin: 0px; padding: 0px; }
body
{
padding: 30px;
font-family: Calibri, Verdana, "Sans Serif";
font-size: 12px;
}
table
{
width: 800px;
margin: 0px auto;
}
th, td
{
padding: 3px;
}
.right
{
text-align: right;
}
h1
{
color: #FF0000;
border-bottom: 2px solid #000000;
margin-bottom: 15px;
}
p { margin: 10px 0px; }
p.faded { color: #A0A0A0; }
</style>
</head>
<body>
<h1>User administration</h1>
<table cellpadding="0" cellspacing="0" border="1">
<thead>
<tr>
<th>Username</th>
<th>Last activity</th>
<th>Created</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4" class="right">
Create new user | Logout
</td>
</tr>
</tfoot>
<tbody>
<?php foreach
( $users as $user ): ?>
<tr>
<td><?php echo $user["uUsername"]; ?></td>
<td class="right"><?php echo $user["uActivity"]; ?></td>
<td class="right"><?php echo $user["uCreated"]; ?></td>
<td class="right">Delete | User info | Change password</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
config.inc.php
<?php
$GLOBALS["serverName"] = "DESKTOP-KRF6KT7\SQLEXPRESS";
$GLOBALS["database"] = "SimpleUsers";
$GLOBALS["uid"] = "sa";
$GLOBALS["pwd"] = "twinz0000";
$GLOBALS["connectionInfo"] = array(
"Database"=>$GLOBALS["database"],
"UID"=>$GLOBALS["uid"],
"PWD"=>$GLOBALS["pwd"]);
$GLOBALS["conn"] = sqlsrv_connect($GLOBALS["serverName"], $GLOBALS["connectionInfo"] );
?>
Hope it will help.
I have these two items in my php.ini file enabled:
extension=php_pdo_sqlsrv_53_ts.dll
extension=php_sqlsrv_53_ts.dll
Which is what I had before. Using Wamp Server. PHP 5.3.13 all the same as before. What else am I missing that is not allowing this to connect to the SQL server.
After connection file code.
<?php
$GLOBALS["serverName"] = "localhost";
$GLOBALS["database"] = "SimpleUsers";
$GLOBALS["uid"] = "root";
$GLOBALS["pwd"] = "";
$GLOBALS["connectionInfo"] = array(
"Database"=>$GLOBALS["database"],
"UID"=>$GLOBALS["uid"],
"PWD"=>$GLOBALS["pwd"]);
$conn = sqlsrv_connect($GLOBALS["serverName"], $GLOBALS["connectionInfo"]);
?>

Categories