Skip to main content

Posts

guzzlehttp throwing error on laravel project - strtolower(): Argument #1 ($string) must be of type string, int given

I am trying to consume one POST api using guzzlehttp In my laravel project. But i am getting one error on my dev server. This working perfectly on my local system. $postArray is manipulating correctly both side. This is my composer version. "guzzlehttp/guzzle": "^7.3", If any one know about this please help me out. $response = Http::withHeaders([ "accept: application/json", "content-type: application/json" ])->post('https://staging.consume.com/testing', $postArray)->json(); strtolower(): Argument #1 ($string) must be of type string, int given { "message": "strtolower(): Argument #1 ($string) must be of type string, int given", "exception": "TypeError", "file": "/mnt/drive_1/www/deploy-api-2021-07-29-14-25-12/vendor/guzzlehttp/psr7/src/Utils.php", "line": 28, "trace": [ { "file": "/mnt...

Error on cURL from Laravel middleware Attempt to read property "headers" on null

In my PHP project (Laravel middleware) I have a curl that takes the HTML dom from an URL. Subsequently, I have to save the line number in which words are found inside the dom in a variable. The problem is that running the code on a URL in localhost prints me the right line numbers, but running it on a web URL just prints me line 1 EXAMPLE $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $urlToTest); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $dom = new DOMDocument('1.0', 'UTF-8'); $dom->formatOutput=false; $dom->preserveWhiteSpace=true; $dom->validateOnParse=false; $dom->strictErrorChecking=false; $dom->recover=true; $curlDom = curl_exec($ch); libxml_use_internal_errors(true); $dom->loadHTML($curlDom); libxml_use_internal_errors(false); if ($curlDom === false) { dd(curl_error($ch), curl_errno($c...

Laravel belongsToMany not working as expected

i have an issue getting user related data from my belongsToMany relationship where i need to get all data from the Review class with all the user data from the pivot table. Reviews model: public function user() { return $this->belongsToMany(User::class, 'reviews_pivot', 'review_id', 'user_id'); } UserController: public function edit($id) { $reviews = Reviews::with('user')->get(); } View: @foreach($reviews as $review) <input type="text" name="" value="" /> @endforeach Now when i look for user id 1, where the pivot table is empty it shows the data from user id 2 and so on. source https://stackoverflow.com/questions/68581415/laravel-belongstomany-not-working-as-expected

How to display one item in my item details page from my item page using PHP/MYSQL

Okay So Here I'm trying to link a Item details page to a Item page, I have successfully done so however when I click on an item all the item details are showing up I would like to know how to Only Display one item on the item details page for the corresponding id. I know I'm missing some code (think its a GET or POST variable) to complete the link if anyone can help it will be much appreciated thanks alot Heres my code item.php <div class="rone"> <?php $conn = new mysqli("xxx", "xxx", "xxx", "xxx"); if ($conn->connect_error) { die("Connection Failed!" . $conn->connect_error); } ?> <?php $stmt = $conn->prepare('SELECT * FROM items'); $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_assoc()): ?...

Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page. Wordpress media

When I try to upload an mp4 file with 84mb. It gives me this error "Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page." SSL is activated source https://stackoverflow.com/questions/68581368/unexpected-response-from-the-server-the-file-may-have-been-uploaded-successfull

I have a page I only want accessed if someone clicks "submit" on a form. Why am I able to access the page when I type in the URL?

I have a page named "booking.inc.php" inside a folder marked "Private". Here is the PHP code I wrote to prevent someone accessing the page by typing in the URL unless they click a button with the attribute "submit" and the name "book"... <?php if (isset($_POST['book'])) { echo "It works!"; } else { header("location: ../index.php"); } The HTML page is named "booking.php" and is not in the Private folder. <!DOCTYPE html> <html> <head> <?php require "header.php" ?> <title>My Website</title> </head> <body> <form action="private/booking.inc.php" method="post"> <input type="text"> <input type="text"> <button type="submit" name="book">Submit</button> </form> </body> </html> When I enter in some text into the form and click "submit...

How to pass a value with POST from a PHP file to another one?

I have a scenario where I want to pass a value AND redirect from the authentication.php file to index.php file without using GET but only POST. I want to keep it hidden from the user. I thought about using cURL but as far as I know this will execute the index.php file, right? // set post fields $post = [ 'customer' => 'username', 'token' => 'token123' ]; $ch = curl_init('www.domain.com/index.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); // execute! $response = curl_exec($ch); // close the connection, release resources used curl_close($ch); PS: I dont want to use SESSION nor COOKIES. I understand that COOKIES can be encrypted but I still dont prefer to use them. So, is there a good way for doing this? source https://stackoverflow.com/questions/68581273/how-to-pass-a-value-with-post-from-a-php-file-to-another-one