PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm attempting to pass an XML file

    $xml = simplexml_load_file('test.xml');

Open in new window


  public 'title' => string "My Title" (length=8)
public  'properties ' =>
           array (size=1234)

Open in new window

Before some one asks I cannot upload the xml file but it looks like this (There might be errors due to fat fingers)

<?xml version="1.0" encoding="UTF-8" ?>
<resultset  xmlns="" xmlns:ns2="" xmlns:ns2="">
  <title>The Searchers</title>
  <properties >
    <ns2:value  xmlns:xs=""  xsi:type="xs:string">As a Civil War veteran spends years searching for a young niece captured by Indians, his motivation becomes increasingly questionable.</ns2:value>
  </properties >
  <properties >
    <ns2:value  xmlns:xs=""  xsi:type="xs:string">John Ford</ns2:value>
  </properties >
  <properties >
    <ns2:value xmlns:xsi="" xsi:type="ns2:list">

Open in new window

CompTIA Network+
LVL 12
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Hi expert ,  I count the period of start date and today date and by loop insert into the database , but problem is when i insert already the period and when i on the next month so how the new month was insert into . Any solution for tis case?

I also encounter with the problem of total if the payment not paid , the fine will added 10% into total , so the total should be 500 (first month) , 550 (second month) and 600 (third month) insert with the loop.

	$start = (new DateTime($sdate))->modify('first day of this month');
	$today = date("Y-m-d");
	$end      = (new DateTime($today))->modify('first day of next month');
	$interval = DateInterval::createFromDateString('1 month');
	$period   = new DatePeriod($start, $interval, $end); 
	foreach($period as $dt){
	$date = $dt->format("M Y");
	$invoice_sum = $service + $sink + $fire + $quit + $ass; 
	$total_payment = $invoice_sum + $late_payment - $paidfee;
	$query3 = "INSERT INTO owner_monthlyfees (`owner`,`unit_name`,`date`,`invoice_sum`,`payment`,`late_payment_charges`,`total`) VALUES ('$owner','$unit','$date','$invoice_sum','$paidfee','$late_payment','$total_payment')";

Open in new window

I am using the script below to verify that the user enters the correct information on a registration page. Everything works FINE per individual field, and it displays an error message if there was an error entering the field information. The problem is that there are 5 different INPUT FIELDS, and the user might enter 3 correct and 2 incorrect, BUT IF THE USER GOES BACK AND CORRECT 1 FIELD (OF THE PREVIOUSLY 2 INCORRECT), and then submit the form THE FORM IS SUBMITTED WITH 1 FIELD ERROR.  How can I solve this issue NOT TO BE ABLE TO SUBMIT FORM IF AN ERROR ON FORM

Tnx, I have been trying to figure this for 5 days already :-(
I thought of a hidden field with value 0 for correct or 1 for incorrect, but that wouldn't solve the problem according to my previous example

I am using HTML and an external PHP to verify values

<script type="text/javascript">
    function ajaxFunction(disp_div) {
        var httpxml;
        try {
            // Firefox, Opera 8.0+, Safari
            httpxml = new XMLHttpRequest();
        } catch (e) {
            // Internet Explorer
            try {
                httpxml = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    httpxml = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                    alert("Your browser does not support AJAX!");
                    return false;

        function stateChanged() {

Open in new window

I have an application built using php/mariadb

i want to create a demo of the site that has standard data in it. A user can then play around with the data.

I do not want the new data entered by the demo user to exist for another user

what are my opions?

I am using Google Maps API version 2.

I need to cusztomize the Google map zoom effect as in this below video:

Open in new window

Any help will be greatly appreciated.

Note: The zoom effect will be visible when user selects a country name from a select box.


I am attending a few of the many online PHP education courses right now, and here I have got a little challenge.

I have made this "send e-mail" form, and I am trying to create two message pop-up's to give message if the message is sent or if there is missing something to be filled in the form.
For education purposes I would very much like to make this in PHP, and it here I am getting in trouble.

With the code below, I get the right message with a green background if all fields in the form is filled out before submitting, but when I miss to fill one ore more fields in the form it displays the red background with the right message in it, but the problem is that it also displays the green box - now empty - and places it below the red one.

If anybody can give me a hint how to get the green box to disappear when all fields not are filled I would be very grateful :)

<form class="" action="index.php" method="post" style="width: 150px; margin-left: 8px; "> 
  <h3>Send e-mail</h3>
  <input type="text" name="to" value="" placeholder ="Til"><br><br>
  <input type="text" name="subject" value="" placeholder="Emne"><br><br>
  <textarea rows="10" cols="30" name="message" placeholder="Besked"></textarea><br><br>
  <input type="submit" name="" value="Send besked" style="margin-left: 50px; ">

  ini_set('display_errors', 1);

<div class="mailmessage" style ="background: #ff3300; color: #fff; font-weight: bold; width: 

Open in new window

I am reading image files from a folder and save the results in the database. There are multiple duplicate images in a folder (same image but different filename).
I am getting md5 of a file to marked the file as duplicate.

While saving the records in database how I can ignore the duplicate files to not save in Database.

This is my code:


require_once 'db.php';

$dir = '../../../../../sites/default/files/';

$exts = array('gif', 'jpg', 'jpeg', 'png');

if ( is_dir($dir) ):

    // Set up the Iterator
	$directory = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS); //skip dots and double dots hidden folders
    $iterator = new RecursiveIteratorIterator($directory);

    // Clear the table
    $conn->query("TRUNCATE TABLE searchindex_images");
    // Prepare the INSERT query   
	$insert = $conn->prepare("INSERT INTO searchindex_images (dir, img_names, lang,file_date) VALUES (? , ? , ? , ?)");
	$insert->bind_param("ssss", $path, $img, $language,$myhash);   	
$foldersToSkip = ['css','default_images','docs'];

foreach ($iterator as $file):
    $folders = explode( DIRECTORY_SEPARATOR, $file->getPath() ); // split the path into an array.	

    if ( ! empty( array_intersect($foldersToSkip, $folders) ) ) { // see if any folder is matched with $foldersToSkip
        // let's skip this folder
		print "<br>Folder SKipped";
			//// This code only works on Linux OS. It checks for arabic characters in

Open in new window

Wordpress Pagination
I've built a website related to crypto-currency . I am using coinmarketcap professional API for building a page which shows all cryptocurrency live data. For that i have a code for paginaitoh in php (File-). The code works successfully when run via Xampp (localhost), I get the required data-()
But when the same code is uploaded to wordpress page, it fails to work ( live data doesn't show up )-().
Hope any expert help me get through this. Thanks.
Redis Cache.
I am using a Redis Cache plugin on a WordPress / WooCommerce website.  There is some custom functionality that happens when a product is duplicated.  A unique UPC code is automatically issued to the new product.  What seems to be happening is that the result of the query ends up being cached and the same UPC code gets issued to each product duplicated.  When I turn off the cache the problem goes away.  The question is, is there a way to keep a specific function/query results from being cached by the Redis functionality.
This is the plugin:
Needless to say, this is above my pay grade.
PHP - two separate forms on two pages. I want to combine them into one form on one page.

Form No. 1 - uploading three images -

<form enctype="multipart/form-data" action="add_file2.php" method="post">

	<fieldset><legend>Fill out the form to upload a file:</legend>
    <input type="hidden" name="MAX_FILE_SIZE" value="524288">
	<?php // Create the inputs.
	for ($i = 0; $i < $counter; $i++) {
		echo '<p><b>File:</b> <input type="file" name="upload' . $i . '" /></p>';
    <input type="hidden" name="submitted" value="TRUE" />
    //<div align="center"><input type="submit" name="submit" value="Submit" /></div>

Open in new window

Form No 2. - general information

    <form action="PostANoticeYE.php" method="POST" accept-charset="utf-8">
         <p><label for="description" class="SmallHeading"><strong>Description</strong></label>
Please enter a brief description. You have up to 300 characters.
      <div id="div1">Characters Left = 300</div>
<?php create_form_input('description', "textarea", $PostANoticeYE_errors,"maxlength='300' onkeyup='return chlimit(this)' "); ?>

<br />

		<label for="amount" class="SmallHeading"><strong>Amount</strong></label>
        <p class="noticeType">Less than 20 characters please.
		<?php create_form_input('amount', 'text', $PostANoticeYE_errors); ?><br />

		<label for="currency" class="SmallHeading"><strong>Currency</strong></label>
        <p class="noticeType">Enter the currency that you used to

Open in new window

Learn Ruby Fundamentals
LVL 12
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

I am using 3rd party Search and I have more than 1000 HTML pages. The full HTML content is saved in database in separate rows.
In search results I display the page title from a Db field and some HTML content of 200 words. Everything works fine.

The Problem:
Some HTML pages (stored in db) have inline CSS and JS code like below:

<div class="content">
    <div class="field field-name-body field-label-hidden"><div class="field-items"><div class="field-item even"><style>
                        #dropBox {
                          border: 3px dashed #0087F7;
                          border-radius: 5px;
                          background: #F3F4F5;
                          cursor: pointer;

                        #dropBox {
                          min-height: 150px;
                          padding: 54px 54px;
                          box-sizing: border-box;

                        #dropBox p {
                          text-align: center;
                          margin: 2em 0;
                          font-size: 16px;
                          font-weight: bold;

                        #fileInput {
                          display: none;
  <script type="text/javascript">
	 if (jQuery(&#039;#myline-check&#039;).is(":checked")) {

Open in new window

Hello am trying to create an upload system that that that automatically displays the uploaded contents( Doc, img, zip) and fetches and displays the id, first name and department of the user who uploaded the file from a database i already have whiles displaying

1.uploaded file name
2.Document name
5.Download file button
6.Delete link

I have the information of the registered user and that of the upload system on different tables
The system should allow the user upload unlimited files without overwriting the previous ones

This is what i currently have for the upload.php

$page_title = "Databse System-Search";
include_once 'partials/headupload.php';

if(isset($_FILES) & !empty($_FILES)){
	$name = $_FILES['profile']['name'];
	$size = $_FILES['profile']['size'];
	$type = $_FILES['profile']['type'];
	$tmp_name = $_FILES['profile']['tmp_name'];
$location = "Doc-uploads/";
$maxsize = 10000000;
if(isset($name) &!empty($name)){
	if($type == "image/jpeg" && $size <= $maxsize){
		if(move_uploaded_file($tmp_name, $location.$name)){
			$sql = "INSERT INTO `upload` (name, size, type, location) VALUES ('$name', '$size', '$type', '$location$name')";
			$res = mysqli_query($connection, $sql);
				echo "Uploaded successfully";
			echo "Failed to Upload";
		echo "File should be jpeg image & only 100 kb in size";

Open in new window

<form method="post" 

Open in new window

WordPress and WooCommerce
I have a store with a lot of products.  The WooCommerce Admin Product Search Functionality is really really really slow.  I have made some subtractions to it because my needs do not need such a robust search.  I need to bring it out of the core so it is not over written but I'm not 100%.  Here is the the Class.  I have not put everything in it, only what I believe is necessary.  Can someone assist me with starting the new Class that would extend this?

public function search_products is what I have changed to speed up the search.

class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Data_Store_Interface, WC_Product_Data_Store_Interface {

public function search_products( $term, $type = '', $include_variations = false ) {
		global $wpdb;

		$search_fields = array_map( 'wc_clean', apply_filters( 'woocommerce_product_search_fields', array(
		) ) );
		$like_term     = '%' . $wpdb->esc_like( $term ) . '%';
		$post_types    = $include_variations ? array( 'product', 'product_variation' ) : array( 'product' );
		$post_statuses = current_user_can( 'edit_private_products' ) ? array( 'private', 'publish' ) : array( 'publish' );
		$type_join     = '';
		$type_where    = '';

		if ( $type ) {
			if ( in_array( $type, array( 'virtual', 'downloadable' ) ) ) {
				$type_join  = " LEFT JOIN {$wpdb->postmeta} postmeta_type ON posts.ID = postmeta_type.post_id ";
				$type_where = " AND ( postmeta_type.meta_key = '_{$type}'

Open in new window

Dear Experts

We have configure CRM application system running on windows server R2, configure the application for outbound and inbound in the email settings section of application  but mails are not getting delivered from CRM system to SMTP server , log report attached, from the OS level when done telnet able to communicate to the mail server, can you please suggest where we might be going wrong and help us to fix this.
Dear Experts

application server web-based of LAMP stack becomes extremely slow and makes application unable to use, web-server(application file system) is having 16GB Ram and database server is separate with 64GB ram and did run mysql tuner attached for your reference below posted recommendation section, when try to set values as recommended mysql fails to start  withe following error log, please help on what values to set so that below error is fixed, thank youmysqltuner12.txt
Plugin 'InnoDB' init function returned error.
180911 14:18:19 Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
180911 14:18:19 Unknown/unsupported storage engine: InnoDB
180911 14:18:19 Aborting

Below -extract of recommendations section from the attached

-- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/log/mysqld.log file
    Control error line(s) into /var/log/mysqld.log file
    Set up a Password for user with the following SQL statement ( SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password'); )
    Restrict Host for user@% to user@SpecificDNSorIp
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Adjust your join queries to always utilize …
I have this query to check the last 3 months sales figures and another query to check the refund figures

           // sales
            SELECT DATE_FORMAT(order_date, '%b') as month, SUM(order_total) as totalSales FROM
               SELECT order_date, order_total
               FROM order_summary
               WHERE order_date <= NOW()
               and order_date >= Date_add(Now(),interval - 3 month)
               AND `order_status` = 'Approved'
               UNION ALL
               SELECT  Date_add(Now(),interval - 2 month)  AS order_date, 0 as order_total
               UNION ALL
               SELECT  Date_add(Now(),interval - 1 month)   AS order_date, 0 as order_total
               UNION ALL
               SELECT  Now() AS order_date, 0 as order_total
            ) as test
            GROUP BY DATE_FORMAT(order_date, '%m-%Y')
            ORDER BY DATE_FORMAT(order_date, '%m-%Y') desc

Open in new window

           // refunds
        SELECT DATE_FORMAT(credit_date, '%b') as month, SUM(`credit_value`) as totalCredit FROM
               SELECT credit_value, credit_date
               FROM credit
               WHERE credit_date <= NOW()
               and credit_date >= Date_add(Now(),interval - 3 month)
               AND `reason` = 'Refund'
               UNION ALL
               SELECT  Date_add(Now(),interval - 2 month)  AS credit_date, 0 as credit_value
               UNION ALL
               SELECT  Date_add(Now(),interval - 1 month)   AS credit_date, 0 as credit_value
               UNION ALL
               SELECT  Now() AS credit_date, 0 as credit_value
            ) as test
            GROUP BY DATE_FORMAT(credit_date, '%m-%Y')
            ORDER BY DATE_FORMAT(credit_date, '%m-%Y') desc

Open in new window

I want to show the data in a table like:

Month          Sales          Refunds

Sep                100                 0
Aug                100                20
Jul                   50                   5

I thought of trying to combine the queries into one but that seems very complex. And trying to nest the foreach loops creates 6 rows instead of 3. What would be the best way to achieve this?
Having issues with resume upload parsing page: as an example

When a user clicks to upload their resume, and selects CONFIRM INFO, the page refreshes after a couple of seconds and it appears as if no data has been processed.

Code is below, simple file upload and script. Working with Joomla.

<form class="uk-form"  name="frmMain" method="post" id="frmMain" enctype="multipart/form-data">
	<input type="hidden" name="jobId" value="<?= $this->jobID ?>" />
	<input type="hidden" name="email" value="<?= $this->email ?>" />
	<input type="hidden" name="action" value="resume" />

           <input class="form-control  uk-form-large uk-width-7-10" id="filResume1" type="file" name="filResume1" /> <button class="uk-button-primary submit uk-button" >Confirm Info</button>
           <label class="error" for="filResume1"></label>
           <button class="noresume uk-button uk-button-primary" >I  don't have a resume</button>
		   <p style="font-size:12px">No Resume? No Problem you can still apply manually</p>

		<p id="spProcessing"></p>


jQuery('.submit').click(function() {
	jQuery('#spProcessing').text('Processing resume ............... ');
jQuery('.noresume').click(function() {


Open in new window

There are no errors in the console, and I cannot figure out what may be the cause of the issue.

Would the PHP / MySQL version possibly affect tthe functionality of this?

Any insight would be helpful,

Thank you!
Hello Experts
  I have this link


I need to add a some text to the displayed page, But I do not know where I should go or what code or php file generate this page.

Can you tell me what file I should look for as to add the new text

Thank youuuuuuuuuuuuu
This is a follow on question to

Now it appears that the memory leaks are coming from php-fpm and Apache.

Please tell me how to isolate what is using up the memory so quickly.

In less than an hour I have lost .9 GB.
PMI ACP® Project Management
LVL 12
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

could you anyone explain how we will convert c++ code to PHP ?
USING PHP PROGRAMMING LANGUAGE, PLS NO OTHER LANGUAGES.You will be given a binary tree with N nodes (1 <= N <= 100000) numbered from 0 to N - 1, each one labeled with some integer. You have to answer Q (1 <= Q <= 75000) queries, each one denoted by some node (some integer between 0 and N – 1). The answer for each query is the largest difference of the labels you find in the path from the given node to the root of the tree, which will always be node 0. N will be given in the first line of the input. N lines follow, the i-th line describes the data of the i-th node of the tree (first line describes node 0, and so on), with 3 integers: label, left child, right child. The absence of any of the children will be denoted by -1. Then a line with the integer Q, followed by Q lines, each one a single query as described above. Case 1: For the input provided as follows:


10 1 2
12 -1 -1
15 -1 -1




Output of the program will be:



Case 2:

For the input provided as follows:


10 1 -1
15 2 -1
20 -1 -1




The output of the program will be:


We are trying to create a search function inside a website to access and search a MySQL Database. The General Search options would be to search the whole database for a specific phrase and combine with a date range. Help is needed to build a PHP script to link to our database and offer a web-based form to allow users to search as detailed above. I have no experience of PHP but have some HTML knowledge.
How can I Read more than 10280 bites data using PHP
$read = socket_read($sock,10240);
it can showing max 3000 bites.
Dear Experts,

I have created on demand task to import an Excel file from Dropbox, but I want to run this task from a Wordpress page, just like we can deploy Datapage and paste it wo a Wordpress page.  I am trying to use this as a way of uploading a file by non-admin person on demand.
Please advise.
I had created a form, but there is drop down menu its telling me Invalid data entered in column. I created table in SQL and used enum  as field type. Attached you will see main.sql file and folder with INDEX.php form.






PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.