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.

Secure PHP application thwarted by CSRF vulnerability

I have an issue with my controller action that generates a CSV file using the league/csv package. Whenever I submit the form, the file can be downloaded successfully. However, if I try to submit the request again, I receive a CSRF token failure due to th ...

Which programming languages are recommended for building a web crawler?

My background includes extensive experience with PHP, but I have come to understand that PHP may not be the most suitable language for building a large-scale web crawler due to its limitations on running processes indefinitely. Can anyone recommend alter ...

PHP encountered an issue when retrieving a value from a URL and passing it to a JavaScript variable

How can I pass a PHP variable from the URL using $_REQUEST to JavaScript in order to send it through Ajax? Here is the code snippet at the top of my page: <?php include_once('../php/connection.php'); include_once('../php/getDiagnosis.php'); $pid ...

Failing to send contact information using JSON in PHP

I attempted to transmit JSON data to PHP for email processing, but encountered an issue where the process veered into the 'else' condition during debugging. Here is the code snippet: HTML <form id="cbp-mc-form" class="cbp-mc-form" method="po ...

PHP static arrays declaration

My PHP skills are still in the early stages. I'm curious about how to define a static array in PHP. In languages like C, it's straightforward - here is an example: char a[][] = { (1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3) }; After some ...

Sharing transient information with concealed field in Yii

Trying to transfer temporary data from my form to my model is proving to be a challenge. Despite having hidden data in the form, it fails to retrieve any values from the model. The form code looks like this: <?php echo $form->hiddenField($model, 'f ...

How jQuery Autocomplete handles lowercase conversions in queries

Currently, I am utilizing the jQuery Autocomplete plugin 1.1 for a project. Below is my calling code: $("#txtCombo").autocomplete("http://www.example.com/autocomplete.php", { autoFill: false, width: 550, minChars: 3, ...

What is the best way to identify the cell names in a mysql table that meet a specific condition when using an OR statement?

Utilizing 'OR' in a mysql query. I am looking to display the name of the cell from the table that contains the data. Example: SELECT * FROM routes where stop_1='cityA' OR stop_2='CityA' OR stop_3='CityA' OR stop_1='cityB' OR stop_2='CityB' OR stop_3=' ...

Executing PHP code inside Angular may require configuring a backend server

Currently, I am implementing angular to add page transitions on a wordpress website. The way it works is that my site initially loads a standard wordpress page, runs its PHP code, and then fills the body with angular components. These angular elements are ...

Ways to automatically refresh the div block's content whenever new data is added or updated in the database

Is there a way to automatically refresh the div block whenever there is activity in the database? I attempted using the setInterval function, but I'm looking for a solution that will update or insert data into the block based on updates made to the datab ...

Converting a nested tree array into a hierarchical CSV using PHP

I'm faced with a tree structure array of departments that I need to flatten into a CSV format, displaying the full path to each end department. Consider this example array: $arr = array("AA" => ["BB" => [], "CC" => ["DD" => [], "EE" => []] ...

Deciding between a pair of Meta Tags options

My current project involves extracting meta tags from websites and displaying the results. The code I am using has been working well, but I have encountered an issue... This is the code snippet in question: static private function _parse($HTML) { $ol ...

Tips for dynamically populating select options with objects

After executing a query using ajax to retrieve data from a database, I found that the response is in the format shown below. array(206) { [0]=> object(stdClass)#6707 (8) { ["id"]=> string(1) "8" ["year"]=> string(4) "1947" ["make"]=> string(7) ...

PHP/AJAX user action history manager

Is there a library available that offers undo/redo functionality with a complete history for a web application? One possible solution could be a system using php/javascript/ajax where you can record the opposite action and variable state for each user acti ...

Codeigniter displays a view with an empty variable

After submitting data from another form, I am able to successfully retrieve and print the ID with `print($id)`. However, when I try to pass it to the view, the value returned is null. Below is the code snippet: Jquery post function viewAccount(orId) { ...

PHP and MySQL powered blogging platform

If I am creating a blog system and I would like to incorporate 'tags' into my blogposts. These tags function in a way that is similar to what you see here, as they help to categorize posts with similar topics. My plan is to store the tags in the database ...

Utilize Laravel to trigger a route action based on a dropdown selection change, generating a unique URL

In my code, I have a dropdown select containing the list of the next 12 months: <select name="month" id="specificMonth"> @foreach(Carbon\CarbonPeriod::create(now()->startOfMonth(), '1 month', now()->addMon ...

In PHP, we divide a number by 10 and then increase the result by 1 if it is greater than

I am new to coding and I am grappling with how to correctly assign a value to a variable. The calculation for this variable involves dividing by 10, and if the result is not a whole number, I must add 1 to it. For instance, if I divide 294 by 10, I end up ...

Tips for automating the activation of intents at specific scheduled times in Dialogflow

I'm attempting to automatically trigger intents in Dialogflow to obtain the user's contact details at a scheduled time. Is it possible to achieve this using JavaScript? If so, could you please provide the code? ...

PHP fails to respond following the use of the imagedestroy function

During my development process, I encountered an issue. After using imagedestroy, my script refuses to execute certain PHP and HTML code. If I remove the header, then the PHP / HTML executes after the imagedestroy function. However, I require the header in ...

Techniques for incorporating a variable into the value field in JavaScript

let y = data[1]; cell1.innerHTML ='<input id="text" type="text" value= "'y'"/>' ; This snippet of code does not render any content when attempting to pass the variable, but if you provide a specific value like "h", it will display that in the textbo ...

Checking for a Match - Identifying if a string contains any characters from a different string

Is there a way to verify if a string contains any characters other than those listed below? A-Z 0-9 / - _ . ( ) space ...

Using Ajax (Jquery) to send data to a PHP script

Currently, I am working on an application where users can click a checkmark to complete a task. When this action is taken, a popup window appears (created using bootstrap), prompting the user to enter their hours worked on the task. After entering the hour ...

Is there a way to achieve the same task with Ajax?

Hey there, I am new to the world of JavaScript and AJAX. I have been reading about how to convert a client-side JavaScript variable into a server-side PHP variable by using AJAX. Can someone please provide me with a code snippet using AJAX for this purpose ...

Tips for obtaining the image url with the Facebook PHP SDK

After finally mastering the latest version of the Facebook PHP SDK (version 4) and integrating it into my PHP code successfully, I encountered a hurdle. Here is an excerpt from my code: $user_profile = (new FacebookRequest($this->session, &apos ...

What is the best way to highlight a specific city on a map by placing a circle around it?

I am currently developing a project that involves creating a circle around the location of an item on a Google Map. In the code snippet below, when the show tab is clicked, it should display a circle around the item's location on the map: <div cla ...

If the index.php file is not found, use .htaccess to redirect to the parent folder

Currently, I am in the process of creating a web api using php. One issue that I am encountering is configuring the htaccess file to reroute to the index.php file in the parent directory if a particular resource does not exist. Here is how my folder struct ...

Assistance with PHP and XPath

Looking for assistance with using XPath in PHP. I am seeking guidance on accomplishing the following tasks within any given HTML content: Eliminate all tables and their contents Get rid of everything that comes after the first h1 tag Retain only paragra ...

What is the best method for clearing all cookies in PHP?

unset($_COOKIE['id']); The code snippet shown above will remove a specific cookie. But what if we want to delete all cookies at once? ...

Need a jQuery callback function in PHP that only retrieves the value without any redirection

Initially, I expected this task to be simple but it turns out my skills are a bit rusty. The snippet of javascript/jquery code that I am using is: $.get("plugin.php", {up_vote:surl}, function(data){ //alert(data); document.getElementById(&apo ...

Retrieve JSON data from a PHP script to be used in an Angular scope

I am attempting to retrieve JSON data from a PHP file to use in an Angular controller. I have used json_encode(pg_fetch_assoc($result)); within the PHP file and when I check with console.log($scope.contents); in the Angular controller, the JSON data is ret ...

Translating a PHP POST request into Java code

I am currently facing an issue with a PHP script that successfully makes a POST request to an old server (that I cannot access). My task now is to develop a REST API in Java/Spring to handle all interactions with this outdated server. However, my efforts a ...

I am having trouble getting PHP to parse JSON in the way I need

Currently, I am working on a hobby project that involves an API for accessing data. While everything seems to be functioning well on the other ends, I am facing an issue with the JSON array format. I need the JSON array to not have brackets so that I can e ...

Using JSON with PDO may not be possible, however, it is compatible with the mysql_ functions

Even though this code functions perfectly, I encountered an issue when attempting to utilize JSON as it fails to display any data. The problem arose when I made an effort to transition all of my codes to PDO due to the fact that I was informed about the d ...

Tips for showing form values in pop-up boxes based on their unique identifiers

I am experiencing an issue with displaying posted values in a pop-up box. Specifically, when I click on "Book now", it only shows one set of id values for all entries. For example, if I click on the 1st row's "Book now" button, it displays the values ...

Access Tokens in Azure API Application are not authorized to create contacts

Encountered an error with code NoPermissionsInAccessToken while attempting to create contacts using Application Permission in Microsoft Azure. You can view my code here: , and see what I am passing through here: http://prntscr.com/p6uiwx. ...

Uploading files using Ajax without the need for additional plugins or submitting a form

I have been struggling to find a solution for uploading files via Ajax when the input field is not enclosed within a form tag. I have already attempted this method. This is the HTML snippet: <span id="user-image-up-btn">Upload Image</span> &l ...

Using Symfony to override a set function in an Entity with the id of a different Entity

Is it possible to modify a set function of an entity based on a field from another entity? I have a field in table 1 (column E) that could contain either the value from column C or D (although having two fields with the same information seems messy, I am ...

How can I stop preg_replace in PHP from removing certain special characters?

When my software searches a mySQL database, it first processes the keywords with the following command: $keywords_search = preg_replace("/[^a-zA-Z0-9 ]/", "", $keywords_search); The issue is that this code removes words that contain special characters, s ...

utilize PHP to compress an entire directory on a remote FTP server

I've been brainstorming ideas for creating an automated PHP transfer system between two servers. Server A only has FTP access, while server B has both FTP access and can run PHP scripts. My goal is to transfer all files from server A to a folder on s ...

Displaying PHP strings with spacesFeel free to let me know

I have two files named "index.php" and "output.php". In the index.php file, there is a dropdown list populated with all Italian city names fetched from a MySQL table. The objective of my test case is to select a city from the dropdown list and send its val ...

Stop duplicate submissions made through ajax requests

I am currently using AJAX to generate a list of replies. At the end of the reply list, I have included a textarea form that allows users to add their own reply (also using AJAX). However, I am encountering an issue where I call my JavaScript in my main P ...

Unexpected response from ajax request

I am struggling to properly handle error messages in my jQuery ajax code. When the fetch array result from my ajax page contains data, I want to display an error message; however, when the array result is empty, I want nothing to happen. Unfortunately, my ...

What is the best way to change a JavaScript variable into a PHP variable?

I am interested in converting my JavaScript variable to a PHP variable... Currently, I have the following scenario - in the code below there is a variable e, but I would like to utilize e in PHP as $e: <script> function test() { var e = documen ...

Utilizing HTML forms in combination with Google Charts to generate interactive graphs

Recently, I've been working on a project where I'm trying to incorporate Visual Analytics. I'm looking to create a graph from a UI that's part of an HTML form. Below is the code snippet from my HTML page: <!DOCTYPE html> <html& ...

What is the best way to show additional information in a record when the clause is null?

I have a table for attendance records CREATE TABLE `msattendance` ( `id` int(11) NOT NULL AUTO_INCREMENT, `regnum` varchar(20) DEFAULT NULL, `reg_b` varchar(20) DEFAULT NULL, `in_hr` time NOT NULL, `out_hr` time NOT NULL, `in_i ...

AJAX Code Causes Browser to Crash

Attempting to send user registration details using AJAX, here is an example of the code: <script> $("#submit_btn").click(function() { event.preventDefault(); var supplied_username = $('#desired_username').val(); var password = ...

Tips for rounding small decimal numbers in PHP

I need help with rounding a specific number to two decimal places. The number is: 0.108504578471184 To achieve this, I tried using the round() function in PHP as shown below: round(0.108504578471184, 2) The expected result should be: 0.11 However, th ...

Setting up your YAML configuration to utilize both PHP and Python with AJAX in a unified project on App Engine

Here is my project idea https://i.stack.imgur.com/oGOam.jpg $.ajax({ url: '../server/python/python_file.py', dataType: 'json', type: 'POST', success:function(data) { //Perform additional AJAX requests using PHP files }, error: function(e ...

What is the best way to send a JSON string from a Corona SDK app to a PHP server?

I'm in the process of building an app with Corona SDK. I'm facing an issue where I am sending null values to a mySQL server even though the variable on the app side has a value in the form of a json string. The php code works fine for entering data into ...

I am looking to show images based on the number chosen from the dropdown menu in CodeIgniter

When a number is selected from the dropdown menu, I want to display images accordingly. The options in the dropdown are 9, 12, and 18. Here is the code snippet for my view page: <form action="<?php echo base_url();?>roxcontrol/numberdisplay" id=" ...

utilizing PHP to transform a JSON string into an array

I am facing an issue with json parsing and despite researching extensively on Stackoverflow, I cannot seem to figure out what I am doing wrong. On my website, I utilize the Facebook API to post my feed using curl, which returns a json message. I store thi ...

Using the power of PDO, implementing variable SQL query with bindParam and executing it within

After making the switch from using mysql_ functions to PDO, I've encountered a bit of a challenge that I'm hoping to get some help with. The issue I'm facing is with the search query. Currently, I have it set up like this: $result = $DB->prepare('SELE ...

Inheritance and Method Overriding in PHP Objects

Recently, I have been working on some PHP code within the CodeIgniter framework. I have created my own Model class which extends and overrides the default CodeIgniter model. Below is the implementation: <?php class MY_Model extends CI_Model { publi ...

Is it possible for the WordPress Polylang function `pll_the_languages()` to return an empty string instead of the switcher

Having trouble displaying the polylang switcher on my custom WordPress theme's header.php file. $mlkLng = pll_the_languages(); var_dump( $mlkLng ); //this returns a string(0) "" I have 3 languages on my site, which I can confirm using the follo ...

Creating a custom rule in Yii's URLManager to handle multiple parameters for controller actions

I'm looking to utilize the following URL: index.php/form/2/fields/all In order to display a list of fields with the same form ID. At present, I have a Form CRUD and a Fields CRUD. FieldsController.php public function actionAll() { if (isset($_GE ...

What is preventing my MySQL foreign key from being created?

I have been experimenting with different methods to create a table that includes a foreign key and then insert it into phpMyAdmin. Unfortunately, the results are not meeting my expectations. Here is what I have tried: CREATE TABLE user ( user_id BIGI ...

There is a problem regarding the authentication process for users logging in to Facebook

I am currently working on an Android Application that involves user login. After the user logs in, I send the access token to the server to retrieve additional information about the user from Facebook. However, I have encountered a problem where Facebook a ...

updating each row in a mysql table

Hey there, I'm facing a bit of a challenge and could really use some help. I've created a table using Bootstrap v4 to display products along with relevant data. In each row, there are buttons - a green one with a pencil icon that redirects me to ...

The table populated by Ajax is blank

I am facing an issue while trying to display a table using AJAX and PHP. The table is not appearing in the designated div. Since I am new to AJAX, I have limited knowledge about its functionalities. Below is the HTML code for my div: <div class="body" ...

How to Establish a Connection Script: Is Unset the Right Choice?

I came across a helpful article that was teaching me how to create a connection script in PHP. You can find it here: However, I noticed that the article defines the unset function differently in two different places, which has left me feeling confused. Fo ...

Phalcon seems to be having trouble loading the Incubator Files

After successfully registering the Phalcon namespace in my loader, I am encountering an issue with loading Phalcon incubator files into my project. Even though I have used PhalconLoader to register namespaces and confirmed the registration via spl_autolo ...

How should a function be called within a string while adhering to proper syntax?

Why do I keep encountering an error stating that the function name must be in a string? Or in some cases, it just runs without printing anything. What could I be overlooking? <?php $funName = "{'$oneRun()'}"; echo "Hello! You are currently executing ...

Aggregate the data in a 2-dimensional array by grouping rows based on one column and calculating the sum of another column within each group

Issue: I need to find the sum of 'subtotal' values for each 'id' and store these sums in an array or variables. My current approach involves using a foreach loop with multiple if statements to count occurrences. While this method works ...

The dropdown button becomes unresponsive when attempting to navigate within it using ajax requests

Hello fellow members of the StackOverFlow community, I recently implemented a Bootstrap 5 dropdown button to fetch tabs from the backend using AJAX. Everything was functioning correctly until I encountered an issue where, upon clicking a button within one ...

You can only access mypage.php from the /mypage directory, not from /mypage.php

Currently, I am in the process of developing a PHP website and utilizing htaccess to conceal php extensions using the following script: Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILEN ...

Top method for generating a random word for a captcha program using PHP

Currently, I am in the process of developing a fresh captcha script which is nearing completion. However, one thing that remains unresolved is incorporating a list of words into the image text. For instance, I have around 300 five-letter words that I wish ...

Using Yii2 Active Record to find records where a field value is divisible

When working in SQL, I was able to select records where their IDs are divisible by 4 using the following query: SELECT id FROM table_name WHERE id%4 = 0; However, when attempting this in Yii2 active record, it resulted in an error: $model = Verses::find() ...

Using PHP to pull updates from SVN and refresh a file is a valuable

I am encountering an issue when trying to access an HTML file in an SVN repository, as the contents are showing up as plain text. My goal is to link this file from an external website and have it open directly in the browser. However, since it's a TiddlyW ...

"Encountering issues while trying to establish a connection to localhost with Behat and Selenium

Setting up my Behat tests in a Selenium environment has been quite a challenge for me. Currently, I have managed to start Selenium with Docker. This is what my docker-compose.yml configuration looks like: hub: image: selenium/hub ports: - "4444:4 ...

"Troubles Encountered While Trying to Create a Database Record Using

I am currently facing an issue while attempting to write to a database using PHP. Despite having asked for assistance from multiple individuals, the problem still persists. Therefore, I am reaching out in hopes that a fresh pair of eyes might be able to ...

Ways to verify if php's mysqli_fetch_array is void prior to entering the while loop

I need to confirm the presence of results before executing the while loop, but every approach I've attempted so far is causing the first result to be eliminated. $nearbyResult = mysqli_query($con,$sqlNearby); if(mysqli_fetch_array($nearbyResult) == ...

Attempting to retrieve information from a PHP array

When outputting this array as JSON: $events['data'] The result is: [ { "id":"3" } ] However, attempting to access the id directly throws an error Undefined index: id, using the following code: $events['data']['id'] How can I properly ...

Transfer data from href link to specific detail page

I am currently working on a table that displays all the users. My goal is to turn the usernames into clickable links that direct you to their profile page. What steps should I take to convert the username into an href link and send it to the detail page? ...

What is the best way to transfer an XML file from a server to a device using HTTP POST method?

I am in the process of setting up a server that will run on PHP, and I need to create an app for both iPhone and Android devices to parse the XML data that is sent. The app will send requests such as login and sign-in, and I am looking for guidance on ho ...