Skip to content

Tag: php

Why does PHP file return “array”, but not its contents

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…

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…

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…

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…

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 …