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.

What is the process for changing the selected value after it has been clicked and removing the previous selection

Is there a way to change the class of a li element in a PHP view after it has been clicked? <ul> <li> <a href="<?=base_url()?>home" id="home" onclick="select_class('home');" class="shortcut-dashboard" title="Home">Home</a>& ...

Exploring the process of transforming a dynamic PDF into a static PDF using PHP or NodeJS

Issue I am looking for a PHP/NodeJS API that can convert editable PDF files to non-editable PDFs online. Our client application requires the user to download PDF files that cannot be modified using software like Foxit Reader or Adobe. We are currently us ...

Tumblr OAuth - Request token not provided or expired

Experiencing some difficulties with authorizing against Tumblrs API using OAuth. This is the scenario in my callback.php: require_once('../vendor/autoload.php'); // defining essential variables $consumerKey = 'xxx'; $consumerSecret ...

Prevent loss of data when user incorrectly submits a webform

Currently, I am working with Wordpress and a contact form plugin which is based on php. The form provided by the plugin is quite lengthy and my client has requested that the data entered by users should not disappear if they make a mistake and need to co ...

Explore registrations by year and month

I am currently working on coding where a record needs to be displayed based on the date (Month, Year), for instance: 12-2022. However, with the current code I have, I am unable to achieve this. Can anyone offer some guidance on what steps I should take? ...

Send PHP data through AJAX and retrieve it on a different PHP page

I need to send a variable through an AJAX URL to another PHP page and retrieve it using: $id=$_GET['id']; Here's an example where the value is passed, for instance $id=6. <a id="pageid" href="ifsc-bank.php?id=<?=$id?>"><im ...

What is the process for redirecting users after they log in to Codeigniter?

After a user logs into their account, I want them to be redirected back to the page they were on instead of the members area section. Below is the specific page I want the visitor to see post-login: http://www.localhost.com/folder/this-is-the-restricted- ...

Accessing data from a PHP array using JQuery

I've been struggling with extracting data from a PHP array for quite some time now. Despite examining multiple examples, my code simply refuses to work and I can't figure out where I am going wrong. A Different Approach in PHP function fetchLatestActivit ...

Effortlessly retrieve related data when serializing in Laravel Eloquent using toArray and toJson

I have been using this method to automatically fetch user and replies when serializing my object to JSON. However, I am not sure if overriding the toArray method is the correct approach for this. What do you think? <?php class Post extends Eloquent ...

The issue with Laravel Elixir BrowserSync not displaying the page

After checking out the latest episode on TechSavy Forums () I was inspired to experiment with CodePen for web development. First, I followed the usual steps for starting a new project: npm init cd project npm install Next, I attempted to access the Code ...

Stop the print dialog box from causing the page to refresh

I have implemented a print button for an invoice: </script> <!--Function for printing invoice--> <script> function printpage() { window.print() } </script> <button id="print" name="print" class="btn btn-info" onClick="pri ...

When data is updated in Php Laravel, a new record is inserted instead

Hey there, I'm facing an issue when trying to update data in my table; instead of updating the existing record, a new one is added. Here is my update method: public function update(CompanyUpdateRequest $request, Company $company) { try{ ...

Looking for a way to optimize query performance within a loop? Concerned about memory constraints?

I have created a custom shopping cart component for my Joomla website. Users are buying codes that we store in our database, which are linked to physical incentive cards. During checkout, I need to retrieve the purchased codes from the database and then up ...

Creating a Form with PHP that Sends AJAX Request

I created a simple form with room equipment options. Here is the code for the form: <form action="javascript:void(0);" method="post"> <fieldset> <legend>ROOM EQUIPMENT</legend> <div class="inline_inputs"> &l ...

Using PHP's exec() function to manipulate character encoding via the command line

I've been struggling to pass UTF-8 text as an argument to a command line program using the exec function in PHP. It seems like there are some issues with character encoding causing trouble. When I run locale charmap from the terminal, it returns: UTF-8 . ...

Extract time value from html datetimepicker input

Recently, I've been utilizing a datetime_picker that I found on the web to create a value for an html text input. However, I encountered a problem in separating the value into distinct date and time components. When using the date_picker, the TEXT inp ...

How to incorporate global JavaScript and global blocks in Contao 2.11?

I am in need of creating a chat module for Contao 2.11. The website contains both standard and custom modules. I am looking to add a global JavaScript file that will load on every frontend URL, as well as an HTML block that can be added to each page. It wo ...

AJAX request experiences significant delays due to MySQL query execution

The issue There is a significant delay in the execution of AJAX requests that involve any database queries. This problem has suddenly emerged without any recent updates to the codebase. Interestingly, if the same query is executed on a webpage directly (e ...

Unordered calling of functions in JavaScript - is it possible?

I'm currently working on a project that involves extracting data from an SQL database and converting the output of a query (which is a number) into a corresponding color, which is then passed to a JavaScript variable. Essentially, I am using ajax to ...

What is the best way to pass an array to a JavaScript function from a different page?

My website has a static settings page where my JavaScript function uses AJAX to retrieve data from a MySQL table and display it in a table on an HTML document. It's working perfectly, gathering all the necessary data efficiently. Here's the code ...

Can Eloquent Model JSON Method Include Null Values?

Is there a way to print a Laravel Eloquent Model with null values? I am looking to generate a new Question object that includes all fields, but with null values. However, when I attempt this, it only prints an empty array, []. var app = new Vue({ el: ...

Different methods to retrieve content within a div that is located on a separate, included page

It's a bit tricky to come up with a title for this topic, but essentially, I'm trying to figure out how to get content from an included page into a specific div using HTML and PHP. Let me break it down: In the header.php file, we have the follo ...

Whenever I shop on Shopware 6, I can store my Affiliate/Campaign code in the session for easy access in

I am currently experiencing an issue on my Production System version 6.4.2.1, although I encountered the same problem on a newer version, 6.4.14. The issue arises when entering the shop for the first time with a query parameter URL such as https://shop/?a ...

Encountering an unforeseen T_STRING error with CURLOPT_CUSTOMREQUEST

Currently, I am attempting to send data to a different URL using Curl and encountering an issue. Parse error: syntax error, unexpected T_STRING, expecting ')' in sending.php on line 8 This is the current content of sending.php: <?php // ...

What is the best way to send a JSON response from a Symfony2 controller?

I am utilizing jQuery to modify my form, which is created using Symfony. The form is displayed within a jQuery dialog and then submitted. Data is successfully stored in the database. However, I am unsure if I need to send some JSON back to jQuery. I am ...

Attempting to retrieve an HTML response

Every time I attempt to retrieve an HTML response using PHP, I encounter this issue. screenshot [image removed from post due to binary characters] <?php $header_request = array ( "accept: text/html,application/xhtml+xml,application/xml;q=0.9, ...

Creating a customized navigation menu for websites containing subdirectories: Tips and techniques

I'm eager to grasp how navigation functions on websites with subdirectories. For instance, if my layout looks like this, index.php about_usabout_us.php The navigation link for index.php to return to the homepage would be, <a href="./inde ...

My attachment.php template is not utilized by WordPress

Recently, I encountered an unusual issue with a WordPress site where attachments/images were displaying using an old template. Despite updating and revising the attachment.php file, the production site continued to show the outdated template. Here is a com ...

Iterate over multiple form input variables using PHP

When I iterate through Rice form variables on the PHP side, everything functions properly. <input class="rice" type="text" name="rice[]" > <input class="beans" type="text" name="beans[]" > <input class="price" type="text" name="price[]" > ...

Exploring the Laravel rule set before today: a guide to mastering it

Encountering an issue with this rule showing a syntax error syntax error, unexpected '.', expecting ')' public static $rules = array( 'first_name' => 'required|alpha-dash', 'last_name' => &ap ...

Ensure the form is validated using AngularJS along with an Ajax request

I need help with HTML code <input type="text" name="username"> <label for=""> Email </label> <input type="email" name="email"> My goal is to use AJAX to check if the username and email already exist in the database ...

"Strategies for creating a function to determine if a string is in English

Can someone help me find a PHP function that can verify if the input consists of English characters with a dot (.) like me.too, and is free of any spaces? ...

What is the best way to move between websites or pages without having to reload the current page using a selector?

Have you ever wondered how to create a webpage where users can navigate to other websites or pages without seeing their address, simply by selecting from a drop-down menu? Take a look at this example. Another similar example can be found here. When visit ...

What is causing Apache to not start after PHP7 installation?

After encountering issues with the PHP version on my macOS Sierra system, I decided to upgrade to PHP 7.1.4 by building it from the source. To do this, I performed a fresh install by first removing the old PHP and then downloading the source code from php. ...

How can I transfer the database from my live server to my localhost using php?

I have a large SQL database operating on a live server. Whenever a bug arises, my usual process is to manually export the database from phpmyadmin (by viewing the output text), dropping the localhost database, importing the output dump, and then importing ...

adding numerous records simultaneously into a MySQL database

Having trouble with PHP inserting multiple rows simultaneously into a MySQL database. My current code is: $sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d', '$e')"; I am trying to insert 5 rows at once, but it only seems to insert e ...

Retrieve JSON data and use a button to sort and display markers on a Google Map

Is it possible to modify my function in order to use different PHP files with separate buttons without duplicating the code? Currently, I have a function that displays markers on an external HTML page when a button is clicked. The data is retrieved from fi ...

User-specific editing with the username

I am attempting to substitute {username} with the actual user name. I have made several attempts: $username = htmlentities($gegevens['gebruikersnaam']); $text = preg_replace("{username}",$username, $text); However, this did not produce the desired outpu ...

How do I switch between liking and unliking a post using Ajax's success response?

I have successfully implemented code to insert or delete likes from the database, and it functions correctly upon page refresh. However, I am struggling to figure out how to make it toggle upon clicking. I have attempted various online solutions without su ...

The search bar is equipped with Ajax code for real-time results. In the event that no data matches the search query

If the API call returns data, then the code works as expected. However, if it returns an empty response, it should display an error log but this is not currently happening. $.ajax({ type: "POST", url: "<?php echo base_url();?>homecontroller/catego ...

Unable to deactivate account, experiencing technical issues

After running once, the code in deactivate_myaccount.php throws an error stating: "Notice: A session had already been started - ignoring session_start() in C:xampphtdocsincludesincludesheader-inc.php on line 2". Furthermore, the intended functionality ...

Using multi-dimensional JSON arrays for posting requests through Ajax

Is it possible to serialize HTML fields in a multi-dimensional array format for AJAX post transmission? I tried using serializeArray but it only formats the first level of the array. The data I need to serialize includes name/value pairs like: name="cus ...

Ways to extract a link from an image tag

$image = '<img src="http://some-img-link" alt="some-img-alt"/>'; $source = preg_match('/<img src="(.*?)">/', $image); echo $source; Can someone help me retrieve the src value from the img tag as well as possibly the alt value? ...

The error message "Required parameters are missing in Laravel" indicates that some essential

Hey there! I'm completely new to coding and recently started following a YouTube tutorial on setting up a simple server-side processing CRUD and DataTable in Laravel. However, I've encountered an error that I can't seem to figure out. I'm currently attemp ...

Unable to remove a particular entry from the table

Having trouble with deleting just one row or record? Finding articles that don't quite help, and ending up deleting the entire table instead? <?php // set database connection details $databaseHost = 'localhost'; $databaseName = ...

Display the output based on checkbox selection using JavaScript

I am working on a feature where I need to capture checkbox inputs using JavaScript and then store them in a PHP database. Each checkbox corresponds to a specific column in the database. If a checkbox is checked, I want to insert its value into the databa ...

Best practices for utilizing the getTile() method within Google Maps

I have a question about storing markers in a database using tile IDs. The goal is to display all the markers associated with a specific tile when it is displayed on a map. Initially, I created a code that was not working correctly. It only requested one ...

Moving a Drupal website from a live server to a local server causes broken hyperlinks to appear

Just starting out with Drupal and I have been tasked to work on a live website running on Drupal 7. The website is functioning properly on the live server, but when I downloaded it to my localhost, I encountered an issue. The homepage loads fine, but click ...

What is the specific method or action hook triggered when a shipping method is changed on the checkout page?

To ensure the address fields are required when a user selects a shipping method other than "local pickup," I need to implement dynamic changes using an action instead of just setting them as optional by default. Currently, I have managed to make the field ...

Using slashes to separate URL parameters in Codeigniter

For my project, I need to pass parameters in the URL like this: The goal is to change the URL structure to: I am currently generating URLs dynamically as shown below: <a href="<?php echo base_url()?>controllername/function?id=<?php echo $def ...

"Encountering a crash after setting a breakpoint in xdebug version 2.4.0 for PHP

Facing a challenge while debugging PHP pages. Every time I set a breakpoint, the debugger halts at the line, but as soon as I try to continue by clicking f8, f7, or f5, the debugger crashes. After this, in the output on the browser, only what was sent be ...

Obtaining address information from a textor

I've been searching for a solution to my problem, but haven't come across one yet. The issue is similar to this query: Extract address from string However, I'm struggling to modify the php code in order to resolve my specific problem. Using Magento, I ha ...

Tips for Eliminating the (") Character from a String

I am looking to eliminate the character ( " ) from a String. Although str_replace works perfectly for some strings, it is not working for the following string and displays a syntax error. $string = 'dfghhhhfgh 0201-228 8"X1" 'G' rgth fgh fgh ...

Obtain Selenium Server directly from the website

Is there a simple way to send commands to a selenium server via a web interface? I need to automate filling out multiple online forms that require login credentials, but I want to do it remotely so my team can also access it. Currently, we are manually ent ...

Unexpected outcome when applying rtrim to DOCUMENT_ROOT

Is there a way to eliminate any trailing slashes from the DOCUMENT_ROOT? rtrim($_SERVER['DOCUMENT_ROOT'], '/\\') Unfortunately, after using rtrim, it is adding %5C: E:%5Cwamp%5Cwww%5Ctestfolder I even tried replacing all s ...

Verifying Username with AJAX and JSON Technology

In a PHP file, I have stored usernames in JSON format. [ {"korisnicko_ime":"darbranis"}, {"korisnicko_ime":"markrc"}, {"korisnicko_ime":"leoluk"}, {"korisnicko_ime":"borbau"}, {"korisnicko_ime":"ivavad"}, {"korisnicko_ime":"andtikv ...

Elusive Class Yet Dynamic: Discover Its Static Method Marvels

After dedicating two hours of my time to this, I am bewildered by the inexplicable circumstances surrounding it. <?php error_reporting(7); //warning & parse include($_SERVER['DOCUMENT_ROOT'].'/echo/EchoApplication.php'); $db_credentials = array( ...

Laravel 5.2 email delivery error caused by Swift_TransportException

My current challenge involves sending mail from my Laravel application using a Gmail account with Allow less secure apps: ON and 2-Step Verification OFF. The configuration in the .env file for the mail is as follows: MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail ...

Exploring the power of jQuery's Ajax feature combined with the POST method

I'm facing an issue with two files named basic.php and pptimeline.php. The objective is to choose a value from a combobox in basic.php, process it in pptimeline.php, and then display the result back in basic.php. However, I haven't been able to a ...

When using jQuery and AJAX, the functions each, if, post, and .html work properly but occasionally erase data inexplicably

I have a PHP page containing FedEx and UPS tracking numbers stored in a MySQL database, which are displayed within DIVs with the class "trackingnumber". Using JavaScript, I loop through these divs to retrieve the ID and then send it to a PHP page that fetc ...

Combining JSON arrays in PHP derived from MySQL query outcomes

The current code is as follows: function getList(){ $sql = 'SELECT DISTINCT `person`.`person_name` as name, `skill`.`skill_name` as skill,`skill_linker`.`skill_score`; $result = $GLOBALS['conn']->query($sql); if ($res ...

Transform JSON arrays into JSON structure

I'm currently facing an issue with converting JSON arrays to JSON format data. The output I am currently getting looks like this: https://i.stack.imgur.com/SW2NW.png However, I would like my output to be in the following format: https://i.stack.imgur.co ...

Determine the number of XML elements and display the results for each XML element counted

I need assistance with a problem I am facing. I am extracting data from an XML API using PHP. Below is my code snippet: <?php $gigatools = simplexml_load_file('http://gigs.gigatools.com/u/A2LTD.xml'); echo "<table id='gigs_parse&apos ...

Guide on adjusting PHP variable values and updating functions with ajax requests

One of my functions determines dates based on a variable For example: $modification = "+1 Week" function updateCalendar($change){ $month = array("January","February","March","April","May","June","July","August","September","October","November","Dece ...

Executing PHP code that imports a Python library

My attempt to execute a Python script from a PHP file is encountering issues when it comes to loading a local library. Surprisingly, the PHP successfully calls the Python script without the local libraries, and manually launching the Python script works fl ...

Collect information from forms and save it to a mobile phone number

Is it possible to forward form field details to a cell phone number via text message? Here is the code I currently have for sending form data to an email address. If any adjustments need to be made, please provide instructions. <?php if(isset($_POST[ ...

Mysql is ignoring the use of my indexes

I am utilizing the 'explain' function to investigate why my query is scanning every row in my database, but I am unable to comprehend the reason behind it. Would anyone be able to review this and provide a clue as to what might be missing? The database I ...

How do you link a failing test to a reference when using $this->fail()?

Incorporating my custom assertion into Laravel's base TestCase class is something I'm working on. Here is a snippet of what it looks like: <?php namespace TestsMine; use TestsTestCase; class SomeTest extends TestCase { public function testSomet ...

PHP function preg_match has a limit on the maximum number of non-greedy matches allowed

Is there a maximum number of times the non-greedy .*? match can be used in a regular expression in PHP? I have a haystack that is approximately 200k characters long and I need to determine if 75 numbers are in the correct order. While I am aware there may ...

Can someone help me with this PHP syntax error? I feel like I'm

I'm having trouble locating the syntax error on line 4 in my code. Could you assist me in finding it? Syntax Error: Unexpected ':', expecting ',' or ')' in C:\XAMPP\htdocs\projekt\ajax.php on line ...

Include CakePHP named parameters in the URL when selecting from a list

If I have a selection list like the one below: <select name='languages'> <option value='german'>German</option> <option value='english'>English</option> </select> How can I use JavaScript/jQuery to refresh the ...

Transforming PHP Data into the Desired Format

According to the Eventbrite API v3 documentation, it is recommended to submit data in JSON format. I am currently trying to update simple organizer data through an ExtJS grid, but the changes are not being processed. The solution involves MODX and the upd ...

Importing PHP backend variables into ReactJS with the help of webpack

Is there a way to pass a PHP backend variable into my ReactJS (using react-router) application via Webpack? I'm interested in accomplishing something like this: <?php if ($us->inGroup('Admin')) { ?> <script> var ...

What is the best way to implement Facebook-style friend tagging in a text input field?

Looking to implement a Facebook-style friend tagger feature on a blog post creation application. When a user types the "@" symbol and then starts typing a friend's name from a user table, the application will search for that name and allow the user to ...

What is the solution for the issue of encountering an undefined key array email while attempting to log in through the form?

I encountered an issue while working on a login form that communicates with the database using PHP at the backend. Even though I have verified the correctness of my login credentials, I am facing an error related to undefined array keys 'email and pas ...