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 earliest version of git required to run composer?

My website is hosted and I am looking to use composer to manage my project dependencies on the production server. However, I keep encountering an error every time I try to run composer update: $ [RuntimeException] Failed to execute git status --porce ...

JSON - The challenge of incorporating single quotes within double quotes

In my current scenario, I am using the following code to populate form fields. The code is designed to handle a JSON dataset that has been encoded with PHP's json_encode function. Everything works smoothly when dealing with either single or double quotes ...

Enter the width and height of the image you want to insert using PHP

Is there a way to specify the width as 200px and let the height adjust automatically in this code? echo '<img src="'.$image_name .'" alt="'.$image_name.'"/> '."<br /><br />"; } else { continue; } } ...

What is the best way to swap values in an array with values from a different array?

Currently, I am retrieving an array: $sql = SELECT id, name, state FROM table ORDER BY name $result = mysqli_query($conn, $sql); $rows = array(); $dict = ["A","B","C"]; while ($row = mysqli_fetch_array($result)) { //replace state value here before next li ...

Refreshing a webpage with JavaScript directly from the server (2021)

Utilizing Javascript, I have successfully implemented a cookie setting feature that allows users to switch between normal and classic theme versions on my website by clicking a checkbox. The backend of my application is powered by PHP. My goal is to access ...

Combining two queries into a single JSON object

I have a couple of questions: 1) $result = $this->_db->get_where("wishes",array("is_open"=>1))->result_array(); 2) $requirements_result = $this->_db->get("requirements")->result_array(); I am attempting to format the data in JSON as ...

Difficulty in transmitting two boolean values using ajax and setTimeout()

I am working on two functions that are supposed to send either 0 or 1 to a PHP page using AJAX. When a key is pressed on the keyboard, the function that sends 1 should start, followed by the second function that sends 0 three seconds later using setTimeout ...

Refreshing Appended Content Using JQuery AJAX

Here is the script I'm working with: <script> $(document).ready(function() { $('#signUpForm').submit(function() { $.ajax({ type: 'POST', url: "process.php", data: $("#signUpForm").serialize(), success: function(d ...

Issue encountered in CakePHP 3.5 when using the Crud plugin (Uncaught Exception in CrudComponent.php)

While trying to implement the plugin friendsofcake/crud, version 5.4.1, on a fresh installation of CakePHP 3.5 with the Api, ApiPagination and ApiQueryLog listeners, I encountered an issue. My setup includes PHP 7.0 on Ubuntu. Following the installation i ...

A guide on executing an if statement based on a shortcode attribute value in WordPress

I'm attempting to execute an if statement based on an attribute in my shortcode, but for some reason it's not functioning correctly. Even though I can confirm that the attribute is being passed through successfully (as I can see its value when & ...

Looking up results in an array in PHP/MySQL

I have retrieved the results from mysql ($date_options) as shown below: Array ( [0] => stdClass Object ( [id] => 4 [start_date] => 2010-09-29 ) [1] => stdClass Object ( [id] => 13 [start_date] =&g ...

What is the proper way to incorporate a wildcard for an email address in this specific format?

Is there a way to replace the specific email address with a wildcard in this line of code: if ($email != "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="146167716654707b79757d7a3a7779">[email protected]</a>")? I ...

Discovering an array using regular expressions

When I input certain data into my array, it will return a different name for a specific node. For example, the key node's name could be n1:ModemProduct1207, or it could also be n1:ModemProduct1308. I am curious if there is a way to achieve something like ...

Investigating the Netbeans PHP Xdebug Socket Exception while debugging Joomla

System Information PHP Version 5.4.0-1build1~ppa1~oneiric Xdebug v2.2.0rc1, Copyright (c) 2002-2012, by Derick Rethans Apache/2.2.20 (Ubuntu) While debugging a Joomla project, I encounter a Socket Exception error right before reaching the spot where the ...

Utilizing Google Fonts offline without the need for an API

Instead of relying on Google Fonts API to access a variety of fonts for my website, I took matters into my own hands. I downloaded a snapshot of fonts from this GitHub repository: https://github.com/google/fonts and transferred them to my web directory. T ...

Prevent image swapping when selecting variations in Woocommerce

Can the image change be disabled when selecting a variation for a variable product? I understand that I could remove the image from the variation, but in my situation, I need to keep the variation images. Any assistance would be greatly appreciated. ...

Load select box with options upon document load

After the document loads, I want to populate a select box with values from my database using ajax and jQuery. Can someone help me identify what's wrong with my code? <select class="form-control sec" id="sec" name="sec"> <option value="sec"&g ...

Is there a way to conceal/remove the text displayed on the submit button?

I am facing an issue with a submit button in my PHP code. The button displays an integer value that is crucial for running a script, but I want to hide the value as it interferes with the design using CSS. I have attempted various solutions like removing t ...

Avoiding JavaScript onclick event using JSON information

Here's a situation I'm dealing with: I have a button created using PHP that triggers a JavaScript onclick event: <button onClick='edit(this, "<?php echo $this->result[$i]["type"]; ?>","<?php echo $quality; ?>", "<?php echo json_encode ...

CakePHP 3.6 encountered an issue where it could not convert an object of the class CakeI18nFrozenTime to an integer

In my index.ctp file, I am attempting to determine if a date is more recent than one week ago: (((!isset($task->date_end) || is_null($task->date_end))? strotime('now') : $task->date_end) > strtotime('-1 week')) However, I am encounte ...

Pass the search query and a specific flag to a PHP function using the Ajax method

I need help figuring out how to filter autocomplete results based on a custom flag being sent to the function along with the search term. This would allow users to specify additional criteria, like finding cities with a stadium or swimming pool. var filt ...

Retrieving attribute values in PHP using XPath

Similar Question: How can I extract an attribute from an XML node using PHP's DOM Parser? Can someone help me with extracting the value of an HTML tag? Here is the HTML code snippet: <input type="hidden" name="text1" id="text1" value="need to ge ...

Using Icons in a Symfony ChoiceType Field

In my Symfony Form, I am attempting to display a SelectField with various icons. Here is what my ChoiceType looks like: ->add('icon', ChoiceType::class, [ 'choices' => [ '' => '', '' = ...

Make sure to fully load the HTML page before running the PHP code

Here is the code snippet I am currently working on: <div class="text-center"> <img src="img/ford_lodding.gif" alt="Loading GIF" style="width: auto; height: 500px;"> </div> <?php require 'php/loading.php';?> The content of php ...

JavaScript struggles when dealing with dynamically loaded tables

I am currently working on integrating the javascript widget from addtocalendar.com into my website. The code example provided by them is displayed below. Everything functions as expected when I place it on a regular page. However, I am facing an issue wher ...

obtaining data from various forms and showcasing it in the corresponding field according to the form's identification number

I have implemented 2 forms on a single page with different structures <div id="tabs-7"> <form action="/admin/languages" id="1" class="mainForm" method="POST"> <fieldset> <div class="widget"> ...

Interpret an array of PHP objects using jQuery Ajax

Trying to populate a website with data retrieved from a database through an array of objects using jQuery. For example: <?php function testFunction() { $data = array() $mydata = new stdClass; $mydata->example = 'test'; $data[] = $mydata ...

Transform an array containing objects into a single object

Currently exploring the Mapael Jquery plugin, which requires an object to draw map elements. In my PHP code, I am returning a JSON-encoded array of objects: [ { "Aveiro": { "latitude": 40.6443, "longitude": -8.6455, ...

Issue encountered with Bing webmaster API when retrieving keyword statistics: an unknown error occurred resulting in an empty

My goal is to retrieve keyword statistics through the bing webmaster API using JSON GET requests. The required parameters for this operation are as follows: List<KeywordStats> GetKeywordStats( string q, string country, //optional s ...

The PHP SDK function works flawlessly in the local host environment and in console, however, it fails to perform on the browser when deployed

My PHP function is behaving differently between the server's command line and the web page, with successful execution on a local WAMP host. Any thoughts on what could be causing this inconsistency? function getCFTemplateSummary($CFUrl){ //init client ...

The function to modify text color in Yii2 using the material bootstrap library is not functioning as intended

My attempt to modify the text color or background of the footer has been unsuccessful after integrating this library. I am unable to alter even a single text color. This is my MaterialAsset: <?php /** * @link http://www.yiiframework.com/ * @copyrigh ...

Utilizing CURL for PHP to extract information from any webpage

Can a PHP function be created to generate an HTML string of any link like a browser does? For example, links such as "", "", "mywebsite.com", "somesite.com/.page/nn/?s=b#85452", "lichess.org" What I have attempted: $curl = curl_init(); curl_setopt($curl, ...

A tutorial on dynamically adding fields with a dropdown list (populated from a database) and a text box using PHP and JQuery

I have multiple form components that I need to add dynamically, allowing users to add more than one. Firstly, there is a dropdown list with values populated from MySQL, followed by a text box for inquiries entry. The dropdown list displays a list of users, ...

Error occurs while attempting to return a JSON record using an Ajax request

As I am still new to the concept of MVC and Ajax, please bear with me while I try to understand how they work together to fetch data from a database. I encountered the following error: parse error syntax error Unexpected token < [object, object] wh ...

Unable to remove MySQL row using AJAX and JSON

After successfully inserting rows into my MySQL database, I encountered an issue when trying to DELETE a row using the same logic. Despite following similar steps, I am unable to delete the specified row by its ID. I need assistance in identifying what is ...

How to Send an Ajax Request from a Vue.js Application to WordPress

I've designed a custom page template to seamlessly integrate a vue app into an existing website <?php /* * Template Name: Registration Form */ get_header(); ?> <div id="app"></div> <?php get_footer(); ?> After some troub ...

What is the process for deleting the model column in an email invoice on Opencart?

I want to completely remove the "model" column from all aspects of the Opencart admin and email notifications. I have already taken steps to remove it from admin >> view >> template >> sales >> order_invoice.tpl, but it did not wo ...

Utilize the IFRAME element in jQuery/PHP to reference a specific TAG within a URL

Is it possible to link to a specific tag (such as H1) within an iframe using the source URL? For instance, consider the link . I am wondering if it's feasible to refer to the first H1 element in the provided link ("How the Fed rate hike will impact ...

Encountering an Error 405 Method Not Allowed while attempting to send a PUT AJAX request to a PHP server using

I am currently working on implementing a REST-like application using PHP and jQuery. During my initial attempt, I encountered the following error: PUT http://... 405 (Method Not Allowed) To address this issue, I added the following lines at the beginn ...

What is the best way to use preg_match to search for Hebrew words?

Can anyone assist me with finding a function that can match full Hebrew words in PHP? Your help is greatly appreciated. ...

using if-else statements within other if-else statements in PHP

My goal is to display a graphic change on a php page based on the outcome of a mySQL database query. <?php $find_howto=mysql_query("SELECT * FROM `answers` WHERE `username`='$username' AND `pagename`='_I1' ORDER BY `answer` DESC") o ...

Ways to incorporate a tertiary tier in my CSS dropdown navigation

I currently have a CSS code that displays a two-level menu, but I'm looking to expand it to include a third level. Unfortunately, I'm stuck and unsure of what changes to make in the CSS. Below is the existing code: #topnav{ // Existing CSS properties ...

Managing the initial record in mysql

As I work on a slideshow, my goal is to dynamically change the HTML class attribute from "item" to "item active" when the first record is fetched from the database. For all subsequent records, the class should revert back to just "item." $RelatedTo=1; $ ...

Iterating Through an Array using Foreach Loop in PHP after using json_decode

I am having some issues with a foreach loop that I'm trying to run through an array. Specifically, I keep coming across the error message "Undefined index: text". Here is the code snippet in question: $tweets = json_decode($response,true); foreach ($twee ...

What is the functionality behind a free hosting website?

Is anyone familiar with websites like Hostinghood, where users can create a subdomain and upload HTML, CSS, etc.? I'm curious about how they operate and how I can create a similar site. This is my first question here, so please respond instead of disl ...

Personalizing text in HTML using JavaScript results

I have a modal dialog box function that pops up when a user clicks a button, triggered by a javascript/jquery script. The text displayed in the dialog is set up within an HTML div element that references the script function. My query is how to personalize ...

Can someone explain why my table in Laravel is only showing the third set of data and not the others?

I'm facing an issue with displaying all of the data in my table named taglineImageCarousel. The problem lies in the slide_ID column, where it is being populated with data from slide-01, slide-02, and slide-03. Below is the code snippet: taglineImageCarou ...

Leveraging the orWhere clause in Eloquent

I have two tables: courriers(courrier_id, repondre ..) and reponses(reponse_id, structure, courrier_id) connected through a one-to-many relationship (where 1 courrier can have several reponses). I am looking to retrieve the courriers where courriers.repond ...

What is the best way to extract the HTML from a DOMDocument without including the HTML wrapper

Below is a function that is experiencing difficulty outputting the DOMDocument without appending the XML, HTML, body, and p tag wrappers before the content. The suggested solution provided: $postarray['post_content'] = $d->saveXML($d->getElementsByT ...

What is the best way to transfer PHP form data to an Angular2 application?

As I am still getting familiar with angular2/4, please bear with me if I overlook something obvious. I am currently working on updating a booking process using angular2/4. Initially, the booking procedure commences on a php website, and once some basic in ...

Height and Width Dilemma in Visuals

Can you help with changing image resolution using jQuery? I have a background image applied to the body using CSS/PHP. My goal is to make the image fill the entire window by applying the screen height and width, without using repeat style. The code I am c ...

How can PHP effectively interpret JSON strings when sent to it?

When working with JavaScript, I am using JSON.stringify which generates the following string: {"grid":[{"section":[{"id":"wid-id-1-1"},{"id":"wid-id-1-4"}]},{"section":[{"id":"wid-id-1-5"}]},{"section":[{"id":"wid-id-1-2"},{"id":"wid-id-1-3"}]}]} I am ma ...

Establish and oversee remote connections for a variety of devices

I have a unique setup where I am using a cross domain and PHP server to retrieve user information when they log in. On my website, I incorporate PHP code that includes: session_start(); After a successful login, I declare the user information as follows: ...

Populating hidden fields in Javascript with mouseover event trigger - Pre-click action

Seeking a solution for another issue, I stumbled upon the capability to execute JavaScript on mouseover. Here is what I want to execute: $(document).ready(function(){ function myPayment() { var value = document.mortgagecalc.value_input.value; var rate ...

Using PHP to ascertain the requested dataType or responseType from the client

My ajax request is fairly simple: $.post('server.php',data, function (json) {console.log(json)},'json'); I have configured jQuery to expect json data based on the dataType setting. Question: Is the dataType parameter equivalent to re ...

PHP throws an "Undefined index" error when attempting to access an array key that does

When I use select *, I encounter a problem, but when I specifically select fields from my database, everything works fine. $sql = "SELECT * FROM `product id`;"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { echo $row["product ...

Struggling to encode an array of objects in JSON format

I have a PHP class called Country that I am fetching as an array of objects from a database function call. When I use var_dump($countries), I can see the objects, but when I try to json_encode($countries), it returns empty. class Country implements JsonSe ...

PHP contact form not properly sending complete submission data

I'm facing an issue with my HTML contact form that utilizes JavaScript for a change function. Essentially, I have a dropdown menu for different subjects, and based on the selected option, specific fields should appear. However, when a user fills out t ...

PHP if statement inquiry

I need to create an if statement that checks for the existence of a specific set of items as well as any additional items. For instance: foreach($id_cart as $id) { if(($id == 4 || $id == 5) && **IF ANY OTHER ITEM EXISTS**){ echo "Yes"; } Is there an ...

Retrieve just a fragment of the feedback by utilizing the .load directive

Hello there, I've been using Wordpress and I have a shortcode with a bunch of code to arrange my blogs in a specific layout. In addition, I've integrated the isotope plugin as well as the infinite scroll plugin. The infinite scroll feature utilizes a dest ...

The "Symfony QueryBuilder" is an outstanding tool

I'm creating a website that showcases various projects with a menu. This menu allows users to filter projects by language. However, I'm facing an issue with the query to retrieve projects for a specific language. I have two entities: Project and Language: ...

Unable to retrieve the ID value for the HTML form

Need help updating a table in the database with individual update buttons for each row. The issue is that when the button is clicked, nothing happens because I'm struggling to pass the ID value to the form and then to an UPDATE query. while(list($na ...

The lifespan of a PHP object

As my files became longer than 100 lines, I started considering breaking them into smaller functional parts. However, when I attempted to do so, I encountered a problem as shown in the simplified code below. I understand that HTTP is stateless and variable ...

PHP is experiencing issues when trying to insert data into the database

When I run a query in phpMyAdmin such as INSERT INTO table('نچجاعجان'); it appears correctly, but when I try to insert data through my PHP page, it displays in the field like this: ÙاننناÙنعن The collation of ...

Retrieve information from one table and compare it with another table to display any matches

Here's the scenario. I have successfully implemented joins in various parts of the website, but there's one issue that has been causing me quite a headache. It's likely something simple that I'm overlooking. This system allows users to log in and follow e ...

A single Modal, Ajax, and data that is continuously refreshed

I'm currently facing a challenge in my project as I try to implement Ajax functionality. Although I'm relatively new to using it, I believe I have a basic understanding of its workings. My website involves collecting form data, posting it to a d ...

Verify if a document is present within the collection; if not, insert a new document

I am currently using PHP and MongoDB to save songs that users add through a basic form. The structure of the collection I have created is as follows. $object = array( "trackName" => "Sju sorger", "artistName" => "Veronica Maggio", "album ...

Difficulty encountered while using MySQL column update button

I'm looking for assistance in updating my database using an SQL statement after a button is clicked on the website. I attempted something but it was unsuccessful. Could anyone provide guidance? Here's the code snippet: http://pastebin.com/D0S83Jgh I'm ...

What is the best method for preserving theme/plugin/php modifications in WordPress?

After researching php file editing and scripts on various platforms, including WordPress related sites, I find myself feeling a bit overwhelmed and confused. I have some clarification questions that I hope to get answered: 1. Is it safe and advisable to c ...

Improving database values by adding a constant to them and updating them using PDO

Here is the situation: I am trying to create a system that updates a value (by adding 1 to the current value) stored in a database for a specific user who logs into the website. Below is the code I have been using: $value = $row["value"]; $add_value = $db ...

Wordpress articles refuse to appear side by side

I've been at it for hours now, trying to solve this issue with no luck. I have a Wordpress loop on my homepage that displays post thumbnails vertically, but I want them to appear in sets of three images before starting a new line. Here's the code snippet: ...

Error encountered: PHP unable to locate DB2 extension

My development environment is set up with a Vagrant box that has been working smoothly for months. Recently, I decided to update it by running vagrant box update, as it had been reminding me to do so. Unfortunately, this action has now caused some issues. ...

How to Handle Laravel Routing with URL Query Parameters

I am working on a route called stats. This is how my current routing setup looks like: Route::get('stats', 'StatsController@index'); Route::get('stats/{query}', 'StatsController@store'); The main objective is to display stat data when someone visits the ...

Getting data sent via Ajax and jQuery through window.location.href in a new controller in CodeIgniter

How to retrieve ajax jquery data passed through window.location.href in a new controller using CodeIgniter? $(".x").on("click","a.p",function(){ productId = $(this).attr("productId"); alert("product ID : " + product ...

Using AJAX validation, capture radio button input and save it to a MySQL

Initially, I am utilizing the email script created by Jeffrey Way on In the Woods. Here is a basic form structure: <form method="post" action="sendEmail.php" id="form_reserveren"> <div id="container"> <div id="main" style="width: 100% ...