whenever I want to login my page, this error came, but I added my mongodb database with my project, what's the issue?
I just want login my page with my mongodb database, where i mentioned everything
via Chebli Mohamed
We were talking about Laravel 5 on its release, we are pleased today to welcome Laravel 5.1
whenever I want to login my page, this error came, but I added my mongodb database with my project, what's the issue?
I just want login my page with my mongodb database, where i mentioned everything
The pest package of laravel can push that package on live site what is best practice can i push it or not can anyone help me on that.
I install the pest laravel automation testing package on local setup of automation testing and logical testing can i push that package to live site what are the pros and cons.
I'm trying to compare array getting from two different inputs and compare it in controller if both value same then pass TRUE if Not pass FALSE.
I tried below method but I was getting error and error pointing to below code
if ($request->ANSWER[$i] === $request->OPTION[$i])
{
$data->ANSWER_STATUS = "1";
} else {
$data->ANSWER_STATUS = "0";
}
Error Code
Trying to access array offset on value of type null
my array pater looks
"Question" => array:2 [▼
0 => "html full form"
1 => "water formula in science"
]
"ANSWER" => array:2 [▼ //COMPARE
0 => "Hypertext Markup Language"
1 => "h2O"
]
"OPTION" => array:2 [▼ //COMPARE
0 => "Markup Language"
1 => "h2O"
]
CONTROLLER
public function Store_Answer(Request $request)
{
$Questioncount= $request->Question;
if ($Questioncount) {
for ($i=0; $i <count($request->Question); $i++) {
$data = New OnlineExminAnswer();
if ($request->ANSWER[$i] === $request->OPTION[$i])
{
$data->ANSWER_STATUS = "1";
} else {
$data->ANSWER_STATUS = "0";
}
$data->question = $request->Question [$i];
$data->save();
}
}
return back()->with('success',' Successfully .');
}
I have been trying to create an XMLHttpRequest to fetch data on mySQL based on 2 tables, but I can't get it to work properly as the beginner I am, so after a few days I wanna ask you for help
This is how I tried to do this, I'll change a few names as the code belongs to a company, they'll be highlighted with "*":
form
<div class="col-md-3">
<div class="position-relative form-group">
<label class="">*number* - *name*</label>
<select name="*first input*" id="*first input*" required="required" placeholder="" onchange="GetDetail(this.value)" class="form-control *select class*">
<option></option>
@foreach($properties as $prop)
<option value=""> - </option>
@endforeach
</select>
</select>
this is the XMLHttpRequest function:
function GetDetail(str) {
if (str.length == 0) {
document.getElementById("*column1*").value = "";
document.getElementById("*column2*").value = "";
document.getElementById("*column3*").value = "";
document.getElementById("*column4*").value = "";
document.getElementById("*column5*").value = "";
document.getElementById("*column6*").value = "";
document.getElementById("*column7*").value = "";
document.getElementById("*column8*").value = "";
document.getElementById("*column9*").value = "";
document.getElementById("*column10*").value = "";
return;
}
else {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (this.readyState == 4 &&
this.status == 200) {
var myObj = JSON.parse(this.responseText);
document.getElementById("*column1*").value = myObj[0];
document.getElementById("*column2*").value = myObj[1];
document.getElementById("*column3*").value = myObj[2];
document.getElementById("*column4*").value = myObj[3];
document.getElementById("*column5*").value = myObj[4];
document.getElementById("*column6*").value = myObj[5];
document.getElementById("*column7*").value = myObj[6];
document.getElementById("*column8*").value = myObj[7];
document.getElementById("*column9*").value = myObj[8];
document.getElementById("*column10*").value = myObj[9];
}else{
console.log();("error " + xmlhttp.status);
}
};
xmlhttp.open("GET", "client/for-ajax.blade.php/" +str, true);
xmlhttp.send();
}
}
and this is the for-ajax file, which was originally .php, but I tried changing it to .blade.php:
<?php
$prop_id = $_REQUEST['property_id'];
$conn = mysqli_connect("localhost", "*user*", "*password*", "d*atabase*");
$property_id = "SELECT `id` FROM `*table1*`";
if ($property_id !== "") {
$query = mysqli_query($conn, "SELECT `*column1*`, `*column2*`, `*column3*`, `*column4*`, `*column5*`, `*column6*`, `*column7*`, `*column8*`, `*column9*`, `*column10*` FROM `*table2*` WHERE property_id='$property_id'");
$row = mysqli_fetch_array($query);
$*column1* = $row["*column1*"];
$*column2* = $row["*column2*"];
$*column3* = $row["*column3*"];
$*column4* = $row["*column4*"];
$*column5* = $row["*column5*"];
$*column6* = $row["*column6*"];
$*column7* = $row["*column7*"];
$*column8* = $row["*column8*"];
$*column9* = $row["*column9*"];
$*column10* = $row["*column10*"];
}
$result = array("$*column1*", "$*column2*", "$*column3*", "$*column4*", "$*column5*", "$*column6*", "$*column7*", "$*column8*", "$*column9*", "$*column10*");
$myJSON = json_encode($result);
echo $myJSON;
?>
At first I was getting a 404, then I created a view for that url "client/for-ajax.blade.php/" and now I get a syntax error on the console:
Uncaught SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON
at JSON.parse (<anonymous>)
at GetDetail.xmlhttp.onreadystatechange
I'm Trying to pass value 1 for if equal
value 0 for if not equal
in columan ANSWER_STATUS
using if and else condition in controller, i was tried two different methods but it was giving error help me to fix this.
ARRYR value
"Question" => array:2 [▼
0 => "html full form"
1 => "water formula in science"
]
"ANSWER" => array:2 [▼ //THIS ARRAY CONTAINING ALL RIGHT ANSWER
0 => "Hypertext Markup Language"
1 => "h2O"
]
"OPTION" => array:2 [▼ //THIS ARRAY STUDENTS ANSWER
0 => "Markup Language"
1 => h2O"
]
]
my controller method 1
public function Store_Answer(Request $request)
{
$count = $request->Question;
if ($count) {
for ($i = 0; $i < count($request->Question); $i++) {
$data = new OnlineExminAnswer();
$data->ANSWER_STATUS = $request->ANSWER[$i] == $request->OPTION[$i] ? 1 : 0;
$data->question = $request->Question[$i];
$data->answer = $request->OPTION[$i];
$data->save();
}
}
}
error
Trying to access array offset on value of type null
my controller method 2
public function Store_Answer(Request $request)
{
$count = $request->Question;
if ($count) {
for ($i = 0; $i < count($request->Question); $i++) {
$data = new OnlineExminAnswer();
if ($request->ANSWER[$i] == $request->OPTION[$i])
{
$data->ANSWER_STATUS = "1";
} else {
$data->ANSWER_STATUS = "0";
}
$data->question = $request->Question[$i];
$data->answer = $request->OPTION[$i];
$data->save();
}
}
}
error
Trying to access array offset on value of type null
I got error in my Laravel controller that says syntax error, unexpected token "}", i have checked every line but couldn't identified the error reason.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Dompdf\Dompdf;
class WordController extends Controller
{
public function importForm()
{
return view('import');
}
public function importWord(Request $request)
{
$file_path = $request->file('word_file')->getRealPath();
try {
$word = new COM("Word.Application") or die("Unable to instantiate Word");
$word->Visible = 0;
$word->Documents->Open($file_path);
$content = $word->ActiveDocument->Content->Text;
$word->Quit();
$word = null;
unset($word);
} catch (Exception $e) {
return redirect()->back()->with('error', 'An error occurred while importing the Word document');
}
$dompdf = new Dompdf();
$dompdf->loadHtml($content);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
return $dompdf->stream();
}
}