Questions tagged [php]

PHP is a versatile scripting language that was initially developed for server-side web development. It is open-source, supporting multiple paradigms and possessing dynamic typing capabilities. If you have any queries regarding PHP programming, feel free to use this tag.

Working with dynamic array sizes in methods and setters in PHP

I am relatively new to PHP and have been researching extensively, but I am struggling to find a solution to my current issue. My problem revolves around using setters in a class when dealing with an array of unknown size. For example: class Shirt { ...

Iterating through a static array using a foreach loop

Is it possible to use a foreach loop to replace the locations in this array? I've tried putting the foreach inside the array, but it causes the code to break. I'm thinking that maybe I need to create a foreach variable and then use that for the levels valu ...

Can you help troubleshoot the issue with preg_match in Xpath? I am receiving an error message that says "

I attempted to extract the ID from Property ID using the following code snippet: <?php $getURL = file_get_contents('http://realestate.com.kh/residential-for-rent-in-phnom-penh-daun-penh-phsar-chas-2-beds-apartment-1001192296/'); $dom = new DO ...

What steps should be taken to mitigate the impact of a SQL-Injection attack?

As I embark on learning database designing and PHP, my main concern is SQL injection. In the event that it does happen, I am curious if there is a way to reverse it automatically, reset affected accounts, close hacked databases, or even find a way to aut ...

Retrieving information from database with the help of PHP and AJAX

I am having trouble printing data from a PHP and Ajax request that is initially encoded into JSON. Instead of displaying the data properly on the screen, it is showing elements from four rows all in a single line with commas separating them. $(document ...

Locate the latest items in the department that are not classified as primary caregivers

Looking for a solution to find records in PHP that are not parent nodes? These records represent the last nodes in the menu tree. The task can only be achieved by using cycles and functions. Check out the table structure here View the tree structure for ...

What is the process for converting a SEF URL to a non-SEF URL for a single view in Joomla?

I am currently working on developing an API type plugin that retrieves activity streams from easysocial. However, I have encountered SEF URLs in the activity stream, but I would like to display NON-SEF URLs when SEF is enabled in Joomla's configuration. C ...

Verify login availability using Javascript auto-check

For quite some time now, I've been grappling with a significant issue that has been consuming my attention. I am determined to implement an auto-check login availability feature in the registration form of my website. My goal is for it to verify the input ...

PHP MYSQL, streamlined alert system

Could someone assist me in removing the notification counts after they have been read or opened? I apologize if the explanation is unclear and for any language mistakes. Here are a sample of my codes: /index.php <script src="http://ajax.googleapis. ...

How can I transfer a variable from jQuery to PHP using AJAX?

I am currently working on a form that utilizes PHP to send email notifications for inquiries. Additionally, I have implemented jQuery to automatically populate details into a specific div. Could someone guide me on how to pass the jQuery variable to PHP t ...

Executing PHP code from a list item

On one of my website pages, I have a list that functions as a delete button. However, I am interested in making it so that when a user clicks on the delete option, a php script is triggered - similar to how a submit button works. Below is the list structu ...

Executing a PHP function that invokes itself with an identical set of arguments

I have a PHP function with the ability to handle a dynamic number of arguments by using the func_get_args() method. class Test { private $flag = FALSE; public function test() { $arguments = func_get_args(); if ($this->flag) { ...

What is the best way to run a separate PHP file?

I have a query: Is there a method to trigger the execution of another php file after submitting an HTML form? I am trying to avoid using header, as I do not want to navigate to the php page, rather solely execute it. Further Explanation: I have a file ca ...

Tips for invoking the controller's update method

I have been encountering an issue while attempting to utilize the update function of my controller on the dashboard.blade.php page. Upon clicking "Save", instead of updating, the page switches to show.blade.php. Content of my dashboard.blade.php: ...

Identifying Magento Bundle Products with Product ID

For the past few days, I've been grappling with a specific task in my Magento store. I am trying to dynamically display the bundles that include the current product on every product page. If anyone can point me in the right direction or provide some help ...

Troubleshooting a JQuery AJAX Autocomplete problem involving PHP and MySQL

I am facing an issue with my autocomplete feature. It is functioning properly on one of my pages, but not on this particular page. Even though the correct number of entries is being retrieved, they all appear to be "blank" or are displayed in black text th ...

PHP not delivering a variable via AJAX

I've noticed that there are similar questions on this platform, but I've spent my entire day researching and fixing bugs to figure out why my ajax code doesn't return a response from the php file. All I need is for it to notify me when a user has been regi ...

Modify PHP script to extract the Document Object Model (DOM) from a specified URL

Hey there, I'm currently using this code to extract and display the HREFs of all "A" tags from a URL. However, my output includes the entire link when I only want the name portion after So, I'm looking to clean up my output to just show a list ...

Setting up a preselected MySQL dropdown list using PHP

I am working on a form that needs to be populated with data from a MySQL table: $db = mysql_connect("localhost:3306", "user", "pass"); mysql_select_db("db",$db); $sql = "Select * from wp_awa_upload where uid = '$_SESSION[id]' and project = ...

Steps to supplying the private key when using the openssl_private_decrypt() function

I have encrypted a value using my public key but I am unable to decrypt it with my private key. Is there something wrong with my code? Here is the script that I am using: <?php $encrypted = "Q4tmeBDTS+M2UriF6zNBJYrWcXJuyclWVAFLZaOSNwTS0FOkqd/7yQ9KrwL ...

The form action now triggers the download of the PHP file instead of simply loading

I'm encountering an issue with the form on my website: <div class="searchBar"> <form action="searchDB.php" method="get"> <input type="text" class="searchBarInput" bdo dir="rtl" name="k"> <input type="image" cl ...

"Challenges Arising in Deciphering a Basic JSON Array

After countless attempts, I am still struggling to solve this issue. My PHP code is functioning properly, as it returns the expected data when "Grove Bow" is selected from the dropdown menu: [{"wtype":"Grove Bow","was":"1.55","wcc":"5","wbdmin":"12","wbdm ...

Using PHP to create a loop that generates a multi-radio form: a step-by-step guide

Despite coding it this way, the multiple radio form is still not functioning as intended. I attempted to utilize fieldset, but to no avail. How can I rectify this issue? Could using various ID's for fieldset assist in creating multiple forms correctly ...

What is the method for embedding HTML content into the header section of tcpdf?

I am currently utilizing the tcpdf library to create a PDF document. I have implemented the smarty template engine to manage the data. Below is the code snippet for inserting header data: // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, ...

What steps do I need to take to enable basic authentication for my PHP app on Heroku?

I need help enabling basic authentication for my simple PHP application hosted on Heroku's Cedar Stack. I am unsure if .htaccess / .htpasswd is supported in this environment. Can someone guide me on how to activate basic auth? ...

Creating a new form upon clicking

By clicking the "Add New Job" link, a new form with three fields will appear. This is the primary form: <h2>JOB EXPERIENCE 1</h2> <div class="job-content"> <input type="text" value="Company" name="company" /> <input type="te ...

Sending an array of form elements using jQuery AJAX

I have a form in my HTML that needs to be passed to a PHP page: for ($j=0; $j<2; $j++) { ?> <tr><th><div class="col-xs-2"> <input class="form-control input-lg" name="Time[]" id="inputlg" t ...

Issue with saving file name in database when uploading files using ajax

Whenever I try to use $filename in the code below, I am unable to successfully store anything in the database. I attempted using the basename function but unfortunately, it did not resolve the issue. $filename = $_FILES['file']['nam ...

Utilizing CakePHP 3.0 with jQuery UI for an autocomplete feature

Seeking assistance on why the current code isn't functioning. The objective is to retrieve data from the index controller to search and obtain JSON data. No requests are being made, and there are no visible results. New to CakePHP 3.0, I am attempting to ...

The form yields no response and fails to send any data

Ensuring that the form on this site successfully sends the name and phone number is crucial. However, upon clicking the send button, I encounter an empty modal window instead of a response indicating whether the data was sent or not. The contents of the fi ...

Troubleshooting Issues with Retrieving Android Data from MySQL Database using PHP and JSON

Even though I have encountered this question multiple times on stack overflow, I have tried all the solutions provided and none of them seem to work for me. I am attempting to display data in a List View. The data is stored in JSON format and it appears t ...

Loading of local resources is restricted in the Apache web server

I am encountering an issue with my Apache web server on a Raspberry Pi. I need to display graphs using the MPLD3 libraries, which are loaded from the server's folder. When I run my index.php page, I receive a Not allowed to load local resources error in ...

The Ajax Form disappears from the page

After racking my brain for a while, I've come to the conclusion that it's time to seek some assistance. I have work tomorrow and I don't want to spend all night on this. The issue lies in my form which is located inside a modal, here is my ...

Where is the storage location for images displayed on the fly using the imagejpeg() function?

When utilizing the imagecreatefromjpeg function to generate an image and then instantly displaying it to the browser with imagejpeg without saving it to a file, where is the temporary location that the image is stored for display? ...

PHP query will execute even in the absence of clicking the button

I'm encountering an unusual issue. I've defined a query to insert two names into the database, and I've used Javascript(Jquery) to ensure it only runs when the create button is clicked. However, the script seems to be executing every time I reload the page ...

Error in PHP class: Wikipedia - index out of bounds

I am new to PHP and encountering an undefined offset issue in my php class. Could someone please assist me with this? The error is currently on line 28, but there might be more errors present. The specific error message I'm seeing is: Notice: Und ...

Using AJAX to submit a PHP form without refreshing the page

Currently, I am facing an issue with my PHP and AJAX code for posting data without redirecting the page. Surprisingly, the script works perfectly on the login page but not on other pages. The main difference I observed is that the login page uses if (empty ...

creating a powerful ajax search feature for mysql databases

Currently, I am developing a search engine for a small database, but I believe that my approach to constructing it has been somewhat bloated. Does anyone have any suggestions on how to streamline the AJAX code? Here is a snippet of my ajax.php file... < ...

The PHP daemon suddenly lost connection to the parent database

I am struggling with creating a basic PHP daemon process. Our class handles database connections, caches data, and performs data processing tasks. The daemon process is initiated, creates an instance of the class, and then listens on a socket for incomin ...

Sophisticated web applications with Ajax functionalities and intricate layouts powered by MVC frameworks

I am looking to integrate an ajax-driven RIA frontend, utilizing JQuery layout plugin (http://layout.jquery-dev.net/demos/complex.html) or ExtJs (http://www.extjs.com/deploy/dev/examples/layout/complex.html), with... a PHP MVC backend, potentially using ...

Display the state of JSON data

There is a piece of data that I want to display on my page. I only need one specific data from the JSON response, but I am not sure how to do it. Can someone help me copy this data to my website? This is the code from json.php <?php $response = c ...

Show the form when the button is clicked

I want to create an application that allows users to click on a button in the top right corner (check image) to hide one div (topics) and show another div (a form for adding a new topic). Here is what it looks like: https://i.stack.imgur.com/YeRTw.png ...

Having trouble calling the Laravel hasOne relationship method from the controller

I'm having difficulty with the hasOne relationship. Here is my code: User model: class User extends Authenticatable { use Notifiable; public function candidat() { return $this->hasOne('App\Model1'); } public f ...

PHP is having trouble recognizing bind parameters in a query when multiple parameters are included

Having trouble pinpointing the issue here - when I bind only one parameter, everything works fine. But when both are present, I encounter the following warning: "Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters i ...

The preg_split function stored all results in an array

Having an issue with the preg_split function in PHP. My regular expression is: #^(-?[0-9]+)(([+x])(-?[0-9]+))*$# I am trying to transform this input: -5+69x45 into an array like this: { [0] = -5 [1] = + [2] = 69 [3] = x [4] = 45 } The regular expres ...

Visual Composer now appends "?id=" to the background images of columns and rows, enhancing the customization

I am in the process of improving the performance of a WordPress site that is using the Visual Composer plugin. When checking GTmetrix results, I came across this issue: Ensure resources are served from a consistent URL https://example.com/wp-content/uploa ...

Using the `implode()` function in PHP to concatenate values for a MySQL query

Recently, I ran into an issue while using the implode function in PHP. <?php $insertValues[] = "(default,'{$y}', '{$p}', '{$o}', '{$i}', '{$u}','AMM-40','test')"; $query_status = "INSERT INTO `mobile1_mn1`.`logs_inbound` ( `log_id` ...

What is the best method for running a MongoDB query in PHP using the CodeIgniter framework?

This is the MongoDB query I am working with: db.getCollection('fe_report').aggregate([{ $match: { date: { $gte: ISODate("2017-07-01T00:00:00.000Z"), $lte: ISODate("2017-07-19T00:00:00.000Z")} } }, { $group: ...

Using AJAX to populate a dropdown menu in a CodeIgniter application

I'm having an issue with using AJAX to populate a dropdown option. Here is the JavaScript code I am using: <script type="text/javascript"> $(document).ready(function(){ $("#sepatu").click(function(e){ e.preventDefault(); ...

Automate the removal of a designated shipping method in WooCommerce through programming

I need a solution to hide UPS shipping options on the cart and checkout pages when the total weight of items in the cart exceeds 150lbs. Here is my proposed code snippet: function disable_ups_shipping_over_onefifty($available_methods){ global $ ...

php retrieve the file extension of an image

I'm trying to extract the file extension from an image. This way, I can allow multiple file extensions while uploading an image. However, the code I currently have doesn't seem to be working as expected. $sql = "SELECT * FROM users"; $result = m ...

Issue with special characters while exporting PHP data to Excel

I found some code on a website that is supposed to convert data from MySQL to Excel. Here is the link to the code I'm trying to use: When I try to save the Excel file, it works fine if there are no special characters. However, when it converts the ...

Authentication with NTLM in PHP with Apache

Is there a way to login to my system using the NTLM protocol that is compatible with multiple platforms? I have discovered the mod_auth_sspi module for Apache, but I require a solution that works for both Windows and Linux environments (both of which have ...

Skipping validation while navigating back on SmartWizardIf you need to bypass validation during backward

Looking for assistance with Jquery smartwizard? Check out the link. I want to disable validation when a user clicks on the "Previous" button in any step, except for the first step where the Previous button is disabled by default. Below is my JavaScript co ...

When uploading from Angular 2, PHP fails to populate the $_POST and $_FILES variables

I'm encountering difficulties when trying to upload files and data to my server using Angular 2 and PHP. After following the instructions in File Upload In Angular 2? to upload data and files from Angular 2, everything appears to be functioning correctly ...

Get rid of any empty space in the image preview icon

Is there a way to eliminate the white space that appears when mixing landscape and portrait images? I want the images to move up and fill the space, even if they don't align perfectly. Additionally, I would like the images to resize based on the scale of ...

Issue with array merging/inserting feature not functioning as expected

Here are two arrays that I have: First Array: "workingHours": [ { "opening": "09:30", "closing": "13:30", "dayName": "sunday" }, { ...

Autocomplete Dropdown Options

I am trying to create a dependent autocomplete drop-down that displays suggestions based on any typed letter, rather than just the first letter. For example, if I type "Yo," it should show "New York" in the dropdown. Below is the code I have been using, ...

Determining the execution order within an if statement in PHP

Looking for a way to create a secure PHP page with a function that checks the token passed in via POST and the one stored in the session. However, I don't want to use multiple if statements like this: function CheckToken(){ if(isset($_POST['token']) & ...

After logging in, I am unable to redirect to another PHP page as the login form simply reloads on the same page

Lately, I've encountered an issue that has persisted for a few days. The login validation is functioning flawlessly. However, the problem arises when attempting to redirect to another page, specifically 'index.php', after logging in. Instead ...

Issue with Jquery's .html() function not functioning properly when trying to select HTML

I am currently working on a piece of code that looks like this: $price = $(element) > $('.main_paket_price').attr('name'); alert($price); Basically, I am trying to select an element inside element which has the class main_paket_pri ...

Utilizing AJAX and PHP to enhance Zend_Config_Ini

As I develop my own CMS, I encountered a challenging issue that I couldn't find a solution for on Google... My dilemma lies in creating an edit_settings.php file using AJAX and PHP to integrate my Zend_Config_Ini for parsing and writing purposes with the ...

PHP PDO prepared statement with SELECT query for insertion

This task is quite challenging for me. I've prepared the following "insert into" statement for Postgres using PHP PDO. $sql = "INSERT INTO mytable (zuordnung_id,spielgen_id,spielvor_id) VALUES ( :zuordnung_id, ...

Having trouble getting dropdown values to work properly in HTML?

Currently, I'm encountering an issue with a drop-down menu that contains the days of the month (ranging from 1 to 31). When I input "22," it seems to default to loading option "20" instead. Displayed below is the code snippet that I am currently using: & ...

Unable to access Heroku login using cURL and PHP

A straightforward PHP script I created for logging into a specific webpage runs smoothly on my localhost using Wamp server. However, when I attempt to run it on Heroku, I encounter a response like this: [image link](https://i.stack.imgur.com/uilks.png). ...

Is my implementation of $mysqli->real_escape_string appropriate?

I am concerned about protecting against sql injections. Can someone confirm if I am using $mysqli->real_escape_string correctly in this code snippet? Right now, I am only applying it to the $name variable. My knowledge of php and databases is limited. / ...

Can you provide a visual representation of the JSON structure?

$data = array('name'=>'John', 'age'=>25, 'city'=>'New York'); I am practicing my PHP skills by using cURL for making a POST request. Assuming the given array is converted into JSON format, what would the resulting JSON string appear as? ...

Manipulating text columns in SQL tables using PHP to convert them into clickable URLs

I have a column in my database that stores the top gaining athletes on my fantasy sports website. I want to make each athlete's name a clickable link that directs users to their individual page on our site. Currently, the function in the code is calli ...

The PHP function image_jpeg may encounter issues when dealing with UTF-8 files, but functions properly with ANSI files

In order to manipulate and resize my images, I utilize a particular PHP class that can be found at this link: This class makes use of GD library. However, I have encountered an issue when attempting to work with UTF-8 encoded files. For example, when I tr ...

Passing boolean data from JQuery to PHP can be done by sending the data

When using ajax to send data from jquery to php, I am encountering an issue where Boolean data sent through jquery is received by php as a string. However, I want the Boolean data to be recognized as Boolean on the php end. Below is the code snippet: $.a ...

Here's a clever trick to exchange the values of two variables without the need for a third variable

Is there a way to exchange the values of two variables without using a third variable? I attempted using an array, but it didn't seem to be successful. If anyone has a fast solution, please share! ...

Form a collection and calculate

Greetings from France, I hope my message finds you well! I recently spent a year in the USA, but now back in France... Let me share some code snippets with you. I have received this data from a form: cmdId[] 25 cmdId[] 26 cmdId[] 27 cmdId[] 28 cmdId[] 29 ...

Creating Custom Queries with Eloquent ORM: A Beginner's Guide

I'm in the process of developing a sleek API and utilizing eloquent ORM. However, I find myself needing to write my own queries on occasion, especially for more intricate database requests. After conducting some research, I attempted the following approac ...

Issues arise when attempting to resubmit a PHP+JQuery+AJAX form with new values

I'm having trouble understanding why my form isn't refreshing after changing the values. Let me explain further, I have a password recovery form where users enter their email address. The form is processed in PHP using AJAX and displays a valida ...

Concurrent Execution of Numerous Ajax Requests

My form has a validation process and once validated, it is submitted with the following handler: submitHandler:function (form) { $.ajax({ url: 'long_process.php', type: 'POST', data: $(form).serialize(), success: fu ...