I am tring to send an array to PHP, PHP however, only outputs “array”. I have two files: forms1.php and forms1.js. The PHP if statement never turns true. I have tried without the if statement too. Thanks for pointing it out in the comments, Yes I call the function, and the alert returns entire for…
Tag: php
How To Target A Specific PHP Function Using Ajax
I am creating a simple comment program. i want to use ajax to refresh the comments and total number of comments. Keeping both functions in a single file is not working for me. here is my code: HTML: PHP: include.php AJAX: Answer Set the PHP to process a named POST item and use switch to determine which functi…
Console.log does not show result based on variable value
I’m using Laravel 5.8 and in this project, I wanted to show some results in Javascript based on the variable which is sent to View. So at the Controller, I have added this: Then at the view: So basically, if title does not have any value, it should be showing 1 at the Console bar, otherwise 2 must be ap…
How to keep session after storing data in Laravel 8?
I’m new to Laravel. I have created custom Change Password in Laravel 8 using Livewire. But, after succeeded in updating the user password, my session is expired and redirected to login page. So, the question is how to keep the session alive and redirect to the current page? Here’s my code: ChangeU…
Formatting a Census Tract String to xxxxx.xx
I am receiving a census track as “022100”. The proper output should be 0221.00. What is the best way to format this string in PHP? I guess I need it to remain as a string since it had a leading zero. I was originally thinking of multiplying it x .01 and then number formatting it, but that will rem…
Trailing html with ajax response form php
I am trying to send info to a php file from an html form. The form works just fine and php processes the information correctly but I am having trouble with the response from the callback. Here is the javascript code: Here is the php code: } Everything works fine except for the response from the call back. Her…
Livewire invalid arrow-function arguments on action
I’m testing out Livewire with a Laravel shopping cart plugin. To add items to the cart you call a function, passing in id, name, quantity, price, and an optional array of metadata: The rendered HTML looks perfect, but when I click the button I get: It doesn’t seem to like the => in the array as…
PHP is not working after updating to PHP 8.1 RC5
After updating PHP 7.4 to PHP 8.1 RC5, PHP has stopped working on my machine and produces following error: PHP Warning: PHP Startup: ^(text/|application/xhtml+xml) (offset=0): unrecognised compile-time option bit(s) in Unknown on line 0 it produces the error even when I ask for php version: OS: Ubuntu 20.04 u…
Annotations: How to specify timestamps in docblocks in php
I have a mehtod that returns timestamps. I want to do something like this: However, I don’t think @return array<int, timestamp> is valid. What is the valid format for specifying timestamps in docblocks? Answer You can use int[], there is no valid value for timestamps. You can however create a Valu…
Cannot Redirect to the correct page using PHP session
In my application I have 4 roles. As per the roles, Users can view their access different pages. Currently I am maintaining 2 different sessions. $_SESSION[‘user_id’] and $_SESSION[‘role_id’]. My problem is, suppose we say the role_id =1 is Admin, role_id=2 is Doctor. If I logout from …