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.

Show pages on Wordpress that led to the current page's path

Currently, I am working on a Wordpress project where I want to showcase a dynamic path to the current page. For example, something along the lines of: Home / Blog / Post - Name. Since this is within a blog page, static HTML won't work as the path is consta ...

Arranging a multidimensional array based on key value pairs in PHP

My array contains states with key-value pairs representing companies. I need to sort the array for each state in descending order based on the company's value, with the highest value company listed first and the lowest value company listed last. arr ...

How to Remove Header Image from New Order Template in Wordpress Woocommerce

I've set a header image for my woocommerce email settings, but I only want it to display in some emails and not others. Does anyone know how I can achieve this, specifically for the 'new order' notification? ...

The issue of missing the 'Access-Control-Allow-Origin' header on the requested resource cannot be rectified using Php header

I am trying to make an Ajax request for a URL like this: $.ajax({url: "http://techparty.ir/e.php", success: function(result){ $("#div1").html(result); }}); However, I encountered the following error: XMLHttpRequest cannot load http://techpar ...

Has Google Altered the URL for its Keyword Tool?

Recently, I have been using a code snippet to scrape valuable keywords from Google: $data=file_get_contents('http://clients1.google.com/complete/search?hl=en&gl=us&q='.$keyword); However, my script has started experiencing some errors. It's sho ...

Return data for Direct Payment with PayPal Payments Advanced: Understanding the process

I currently have PayPal Payments Advanced set up with hosted checkout pages. On the initial page of the paylinkpro.paypal.com site, users are presented with two options: Everything functions properly when a user chooses "Checkout w/ PayPal." However, I am ...

Working with PHP arrays and mapping them based on textual data

When processing orders, different text strings are returned based on the shipping method selected. Examples of these text strings include: productmatrix_Pick-up_at_Store productmatrix_Standard productmatrix_3-Day_Delivery productmatrix_Pick-up_at_Store_-_ ...

Laravel issues with displaying data in a 'foreach' loop

I encountered a quirky issue while working with Laravel 5.2. I have a chunk of text that I'm attempting to display using some explode functions. The strange part is, Laravel is rendering it oddly by adding incorrect ':' before the end of the ...

Steps to activate CORS using .htaccess in a ZURB Foundation Project

Embarking on my first website development project from scratch, I took on the task of handling front-end, back-end, and database integration. Utilizing the ZURB Foundation Framework (ZURB Template), I structured my project to be modular with Webpack4, Babe ...

The authentication system in my Laravel 8 application runs smoothly on XAMPP Local Server, but encounters issues when deployed on cPanel. Instead of successfully authenticating users, it displays a "Page Expired"

After successfully developing an application with Laravel and implementing Laravel Auth for authentication, everything worked perfectly on my local server. However, when I decided to host the application online, I encountered a major issue. Despite input ...

There seems to be some incomplete information in an image file that was extracted from the MSSQL database

I am facing an issue where I am unable to display the full image stored in the Image field of the database. Currently, only a partial image of 63KB is being displayed. Here is the code I am using: $sql='SELECT Photo FROM Personel WHERE ID_USER = '.$id; ...

Encountering challenges while integrating Angular with a Laravel forum creation project

Currently, I am working on building a forum application that involves users, posts, and comments using Laravel. However, the next step in my project requires integrating Angular, which is new territory for me and I'm not sure where to start. I have a ...

I would like to include the value of the "file_id" variable in the href attribute of an appended HTML element, but it seems

<div id="invite_popup"> </div> $(".invite_button2").click(function(){ var file_id = $(this).data("id"); //alert(file_id); var popup2 ='<div i ...

Leverage the power of DOMXPath in combination with the query function

Here is a snippet of HTML code to work with: <ul id="tree"> <li> <a href="">first</a> <ul> <li><a href="">subfirst</a></li> <li><a href=""> ...

The challenge with using prepared statements in PHP/MySQL for inserting data into a form

Recently, I encountered an issue with the code below that takes information from a form and sends it to MySQL. Previously, everything was working fine for category, contents, date, and user ID fields. However, after adding a new column called 'seclevel' in ...

Maximizing the Potential of Return Values in JavaScript

I have a JavaScript code that retrieves information and displays it in a div. It's functioning properly, but I want to dynamically change the div id based on the returned data. For example: function autoSubmit3() { $.post( 'updatetype.php', ...

"Incorporating a new column into the database through the model and controller in Yii

When working in the Yii MVC framework, I decided to add a new column to my database model using the following code: $success = Yii::app()->ft_website_prod->createCommand()->addColumn('ft_website.users', 'columnname', 'varchar(64)'); Now, I am f ...

Ajax transmitting data with concealed characters

I'm trying to send data from one PHP site to another. On the first site, everything looks good. The string appears as --show="author,book,text/n However, when I check the string after receiving it on the second site, it shows --show="author,b ...

Personalizing the layout of Joomla's search results page

I am facing an issue with Joomla search results appearing on the home page instead of a new page. I have tried to modify the mod_search.php file by setting the item id to 0 as suggested in online posts, but unfortunately, the changes are not reflected in t ...

Transmit data from a form row to an external PHP script

I'm facing an issue that I need help resolving. My challenge is to transfer data from a form ROW to a php file. Below is the initial PHP code (embedded within an echo statement where values are fetched from a MySQLi query): <form id="comedivid" met ...

a single button with dual functionalities

I am new to the development field and have a question about jQuery. I want a single button to perform two different actions. For example, let's say we have a button labeled Pause/Resume. When I click on the button, it should first display "Pause", and th ...

Strategies for thorough module testing in my PHP application using PHPUnit and Zend Framework 2

I have successfully tested my application module and another module separately. However, I would like to run all tests (both for the application module and the other module) together in order to generate a clover report for Jenkins. What steps should I tak ...

jQuery Form: Despite the Ajax response being visible on the page, it does not appear in the source code

Utilizing Jquery Form for an Ajax image upload. This is the relevant HTML code: <div class="input_con imageupload_con"> <form action="processupload.php" method="post" enctype="multipart/form-data" id="MyUploadForm"> < ...

Using AJAX to send an array as a response from Laravel

After implementing Laravel to handle an AJAX post request, I encountered an issue with displaying the route data. public function infoRoute(Request $request) { // Extracting required information $ship_id = $request->ship_id; ...

Can you explain the distinction between X-XSRF-TOKEN and X-CSRF-TOKEN?

What is the difference between using a hidden field and a header in web development, and why would you choose one over the other? When do we use X-XSRF_TOKEN? And when do we use X-CSRF TOKEN? ...

Issue with call function not operating consistently across all subclasses

I am experimenting with using the __call function for pre-action instructions. The issue I am facing is that the __call function only works once, but I need it to be triggered every time the run() method is called. When I call $second_child->run() ins ...

Troubleshooting Plesk 12 API Connection Issues due to cURL Connection Reset

I'm currently utilizing cURL to send requests to the Plesk API. Whenever I attempt a request that involves extensive processing by Plesk (like creating or deleting a subscription), I encounter a "connection was reset" error in my browser after approx ...

Why is my code displaying "Resource id #6" instead of the actual names of the lecturer or student stored in the database

$query = mysqli_query($con,"SELECT position FROM employees WHERE id ='$empId' AND password = '$empPassword'"); echo ($query); This snippet of code searches for the employee's position in the database and then echoes it out. ...

What is the most effective way to transfer an array from one PHP file to a different JavaScript file?

Utilizing AJAX to send a request to another php page and retrieve the result of a query, I originally used xmlhttprequest to pass the php logic along with the query information. However, I wanted to separate the presentation logic from the actual code logi ...

Deleting associated records in LaravelLaravel gives you the ability

Managing soft deletion of departments when a company is soft deleted can be tricky. The current implementation involves iterating through each department associated with the company and soft deleting them. However, it seems that only the first department i ...

Making a Guzzle 6 API call using a POST method

Can anyone help me figure out how to send multiple data with a POST request? Here's what works: $data = array( 'post_params'=>[ 'Name'=>'Foo', 'LastName'=>'Bar' ] ); But when I try this, it doesn't work. Any suggestions? $data = array( 'pos ...

Having difficulty utilizing WP_Query effectively for accomplishing certain tasks

Currently, I am diving into the world of WordPress theme development by adapting my existing Bootstrap and JavaScript website. My requirements are as follows: 1) Implement a section on the homepage of my WordPress site to display the latest three blog ar ...

Laravel 5 is known for experiencing a frustrating "This site can't be reached" error message when attempting to download a file

I am experiencing an issue with my Laravel 5.2 and PHP7 setup on my hosting server. Everything seems to be working fine, except for the links that are supposed to generate and download xlsx files using Laravel Excel. Whenever I click on these links, I enco ...

Accessing PHP output within Jquery

Even though I know PHP is a server-side script and JavaScript is client-side, I encountered an issue. I struggled to bypass browser security when making an AJAX request to another domain. Feeling lost, I decided to turn to PHP for help. The challenge I f ...

Fetching information from the string of tags

The code retrieves user input and searches a database field called tags. Within the tags field, there is data such as hello, hey, how, happy, hell stored in a single cell or string. I attempted the query below, but it only seems to work for "hello" and n ...

Tips for transferring a value between two pages in PHP

Passing a variable value from one page to another is proving to be a bit tricky for me. I am using a link to navigate to the next page and trying to retrieve the value using Session, The link variable seems to be working fine but the price variable is cau ...

optimal method for managing lists that are both stationary and able to grow

Here is the structure of my database: 'Article' title text user_id language_id 'User' id language_id 'language' id language name Is it best practice to store a list of languages in a MySQL database? I am a desig ...

Facebook Connect Module for Silverstripe CMS

I encountered an issue while working with the Facebook authentication module. I was attempting to log in using Facebook, but it appears that it's not functioning correctly. After clicking the login button, it prompts for permissions on the Facebook site an ...

Organizing outcome searches through ajax

I have a result table displayed on the left side https://i.stack.imgur.com/otaV4.png https://i.stack.imgur.com/pp9m0.png My goal is to transform it into the format shown on the right side of the table In a previous inquiry found here, @Clayton provided ...

How to extract Network Content displayed in Chrome using file_get_contents in PHP

While browsing through a website on Chrome, I noticed that one of the items loaded in the network tab of ChromeDev Tools is a JSON file. I tried using file_get_contents to retrieve this JSON file but all it returned was the HTML content of the webpage. I ...

Embedded Youtube code saved in database is not displaying on HTML form

My PHP update page allows me to modify a website's database that contains YouTube embed codes. However, when I try to edit the embed code on the update page, only "<iframe width=" displays instead of the complete original code. <html> <? ...

Once the form has been submitted, proceed to open a new page following processing

Trying to remove an entry or offer from the database and then return to the page with all entries/offers. Attempted using Javascript, but it successfully deletes the item without redirecting to the overview page. Is this the correct approach with Javascri ...

Retrieving the initial array element within a foreach loop

I am just starting with ajax concepts... When I post data using ajax, only the first array from the foreach loop gets posted. Here is the code snippet: <tbody id="presentor"> <?php if(!empty($data)):?> <?php $counter = '0'; foreach ($dat ...

Using PHP Propel ORM to perform a left join on a many-to-many relationship in MySQL

There are two tables I'm working with: one called "meeting" and the other called "attendance". The "attendance" table is a many-to-many relational database structured as follows: Attendance: user_id | meeting_id | invited --------+----------- ...

Choose a record in MySQL using its unique identifier with PHP

I want to retrieve rows by their id and display the information. My table is called text and here's its structure: BookID Type init Title Author PublisherName CopyrightYear This is how I plan to access them: text id 10 With this command, I can fetch ...

Looking to implement a condition that prevents the echoing of HTML code when a certain template ID is selected?

Struggling with inherited PHP MVC code for a website, I encounter an issue on a specific page where unwanted code is echoed out. To prevent this, I aim to skip the echoing when a specific templateID (which I set as default) is selected. However, I'm unsure ...

Exploring the Integration of MySQL with PHP

I have a great tool on my website that displays different pages based on user input. Here is the code for it: if(isset($HTTP_GET_VARS['mod'])) { $page = $HTTP_GET_VARS['mod']; } else { $page = 'home'; } switch($page) { case 'home': ...

Is combining filter_input() and filter_var() in a chain problematic?

I am currently testing a URL http://localhost:8000/2.php?site=https://google.com<script></script> Next, I proceed to sanitize the "site" parameter: $site = filter_input(INPUT_GET, 'site', FILTER_SANITIZE_URL); var_dump($site); // str ...

Guide on utilizing PHP DOM to display the file size for files included in the table of an HTML webpage

example.html (contains an extensive table with hundreds of files making it impossible to list all as arrays):- <table> <tbody> <tr> <td class="book"><a class="booklink" href="../file1.pdf" >Book1</a></td ...

How to Ensure the Security of JSONP?

Currently, I have a script that utilizes JSONP for conducting cross domain ajax calls. While it is functioning effectively, I am pondering if there is a method to hinder other websites from accessing and retrieving data from these particular URLs. My goal ...

Using PHP to implement conditional statements for multiple days of the week

Could this be done? $d=date("D"); ... else if ($d=='(Thu|Fri|Sat)') { I have managed to make it work for one day of the week. if ($d=='Wed') { Thank you ...

The clash of interests between jQuery and Bootstrap

I'm facing a problem with conflicting jQuery and Bootstrap files in my header.php code. Whenever I include the jQuery file before the bootstrap.js file, it causes issues with the tabs on my website where clicking on them does not navigate me to the correct ...

How can Laravel integrate Elasticsearch to retrieve documents based on multiple categories?

After successfully implementing the code snippet below to retrieve blog posts based on a query, I encountered an issue when attempting to fetch documents that match specific categories. $params = [ 'index' => 'blog', 'type' => 'p ...

Is PHP8 introducing a vertical line with a new data type?

Encountered an issue with the following line of code while running on a server with PHP7.4: public function expiresAfter(int|DateInterval|null $time); Received a ParseError indicating that PHP was expecting a variable. Unable to find information about th ...

A JSON object containing a PHP variable

I'm trying to integrate a PHP variable into my PayPal single payout call code where the price is defined at 'value':".$planPrice." When I manually input a number like "1000", it works fine and I receive the notification. However, when I use the PHP variabl ...

Combine all select commands in a relational table in MySQL into one JSON column

I have a table with headers that include the id and name of individuals. Additionally, there are multiple tables containing specific details about each individual, such as phone number, address, gender, birthplace, etc. How can I construct a SELECT comman ...

Eliminating Repetition: Preventing Message Duplication in WordPress Database Entries

Whenever I attempt to insert a single post into the database using wp_insert_post(), two posts end up getting added: Ajax request: /wp-admin/admin-ajax.php?action=getchats&chat_type=all-chat&last_msg=110&add_msg=true&chat_message=hellow ...

Is mysql(i)_real_escape_string a reliable method for ensuring data safety?

function CustomQuery() { $arguments = func_get_args (); if (sizeof ($arguments) > 0) { $query_string = $arguments[0]; for ($index = 1; $index < sizeof ($arguments); $index++) $query_string = preg_replac ...

Using Jquery and AJAX to insert a PHP file into a DIV container

I am facing a challenge where I need to dynamically load a PHP file into a DIV element upon clicking a button, all without the page having to reload. If you refer to the 'Jsfiddle' document linked below, you will find further details and explanations: ht ...

Why is the PHP MySQL result showing up twice?

Having an issue with my PHP script that is fetching results from the localhost WAMP server. When I print out the query, each record is being displayed twice! Check out the screenshot below for a visual representation: This is the PHP MySQL script: <? ...

Do not include quotation marks around the echo json_encode() function

$result = mysql_query("SELECT * FROM $tableName WHERE id=1"); $array = mysql_fetch_array($result); $help_name = $array['name']; $req = $array['req']; //fetch result echo json_encode($help_name); Issue arises when the result is ...

There appears to be a disconnection issue with the PHP Zend Framework 2 and

Hey there, I have a PHP daemon set up to manage requests from RabbitMQ. However, after running for a day, it stops functioning due to encountering the error "MySQL has gone away." PHP Warning: PDOStatement::execute(): MySQL server has gone away in /var/ ...

Enabling permissions on a Linux Apache server to execute a Python script through PHP

Recently, there has been quite a bit of discussion surrounding this topic and I have immersed myself in research over the past few days. When running the PHP script that executes the Python script from the command line, everything functions properly (show ...

Using PHP to generate a table populated with generic elements from an array

How can I create a dynamic table in PHP that can handle any generic array with different keys and values, including nested arrays? I want to use the same table structure for various arrays regardless of their content. Any advice on achieving this flexibili ...

Exploring the world of interactive storytelling through a basic PHP text adventure

I recently completed coding a text adventure using functions like fgets(STDIN) that works in the command line. Now, I want to convert it to run on HTML (internet browser) but I'm facing a challenge. I am unsure how to transition from this: $choose=0; whi ...

Ensure that any requests to www.domain.com are consistently redirected to domain.com

My website is experiencing an unexpected redirect issue where it keeps directing from www.mydomain.com to mydomain.com. Despite being a Wordpress Multi User installation, there is nothing in the .htaccess file that would trigger such redirection. I have t ...

Slow query in MySQL and PHP causing a delay in execution time that has been exceeded

I am facing an issue with fetching records from my 20 tables which each contain over 5000 records. The data fetching process is extremely slow and instead of displaying the data, I am getting the following error: Fatal error: Maximum execution time of 3 ...

Data not maintained when page is reloaded

I am in the process of implementing a login panel on my index page. The login data will be sent via an ajax call. Upon successful verification of the username and password, I am storing the user data in a session and then reloading the index page upon ajax ...

Switch up the Thumbnail Image based on the selected category

While testing a shopping site I created, I encountered an issue with changing the banners at the top of the page based on the category the user is viewing. This site is hosted on a server on my localhost, not using wordpress by the way. <div class=" ...

Save a PNG file using the HTML5 Canvas when the Submit button is clicked, with the help of PHP

I am looking for assistance with a signature capture form. I came across a standard template on Github that works perfectly, but I wanted to customize it further. However, my Javascript skills are still in the early stages. The current code allows you to c ...

Ways to eliminate the leading bullet point from an unordered list

I am currently working on creating a gallery of images using php and css. The images are placed in an unordered list as shown below: <ul style="list-style-type:none;"> <? while($data=mysql_fetch_row($result)) { $pic=$data[2]; if ($pic) { $ ...

What is the best way to directly access a child node for updating or removing?

This is an example of an xml file structure: <participants> <participant> <number>1</number> <name>toto</name> </participant> <participant> <number>2</number> <name>ti ...

Is there a method to prevent unphar-ing a phar file (PHP Archive)?

Have you heard about the handy tool in php that allows you to archive php files in "phar" format for easy distribution and installation? This tool can create a single "phar" file of an entire php folder. http://www.php.net/manual/en/intro.phar.php Additio ...

"Retrieve the values of the items that have been chosen from a list using jQuery

In my PHP page, I have a list displayed using the following script: <div id='demo' style="padding-left:20px"> <select name='lists[]' multiple='multiple' class='multiselect' > <?php $sql="select list_id,list_name from tbl_list"; $result=my ...

PHPWord setup complication

I am struggling to run a PHPWord script. When attempting to execute the sample example Text.php, it does not display anything. I have verified that the class is loading successfully. You can find more information in the documentation. If anyone has encou ...