PHP

121K

Solutions

33K

Contributors

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

Hi experts!  I'm new to JSON and have a nested JSON that is being sent to my API.  I've attached the JSON file as well as my PHP trying to collect the values for the various "types" of lines.  While my code does not return any errors, the values that get input to my table are all "zeros" except for the "code", "rpt" and "zip" fields.  Can you help me with the correct structure to collect this data?JSON-request.docxPHP-Code.docx
0
Build an E-Commerce Site with Angular 5
LVL 13
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

I need to remove the hover effect on the menu item "Resources" the website is https://www.henricomg.org

I have tried this code

 
.nav-menu li#menu-item-50:hover > a
{
color: inherit;
}

Open in new window


but there is no change provided I am using the right menu number.
0
Hello. I create a Mysql database and a table on a web hosting company server. but I do not have an idea, How to verify connection and  bring a record or value from Mysql database. Can someone write a simple php code for me? I have following information. for example, Server IP address- 1.1.1.1, Database name-tempdataserver, Database user ID- tempuser, Password- temppaass.
Primary key column- stock, Primary key example- aapl, Column to display- CLOSE.

I  can connect  use Mysql for Excel and make a new table.
Thank you.
0
I have this javascript code in one program:

if (ac == "r") {
			document.st.rfq.disabled = true;
			document.st.rfq.value = "Proessing Request...";
			setTimeout(restore_rfq, 5000);
			window.open("rfq.php", "rfq", "width=650, height=500, left=800, top=300, scrollbars=yes, menubar=yes, resizable=yes");
			return false;
		}	

Open in new window


Works fine, opens a new browser window, which has this code:
<!DOCTYPE html>
<?php
include "db_connect_nb.php";
$country = "";
	if (isset($_GET['country'])){ 
		$country = $_GET['country'];
	}	
	$hass = false;
	if($country == "United States" || $country == "Mexico" || $country == "Canada") {
		$hass = true;
	}	
	if ($hass) {
		$qry = "SELECT * from states where country_code = '" . $country . "' order by name";
		$res = mysqli_query($link, $qry);
		$ns = mysqli_num_rows($res);
	}	
	$qryc = "SELECT * from countries";
	$resc = mysqli_query($link, $qryc);
	$nc = mysqli_num_rows($resc);
?>
<html>
<head>
<meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="W3.css">
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<title>Request for Quote</title>
<script type="text/javascript">

Open in new window

0
Hi Expers,

As I have done many times before, I just downloaded the latest version of WordPress (5.2.4) and  copied into a newly-created dev site folder, C:\inetpub\wwwroot\my-new-site.org

First, I got the following with PHP 7.1.10
WordPress database error Unknown column 'wp_' in 'field list' for query SELECT wp_

Open in new window


Again, this  is a new instasll.

I then changed my PHP version to 5.6.5, and i get
The site is experiencing technical difficulties.

Open in new window


With PHP 7.1.10 on this server, my previous WP websites are still functional.

Any advise would be appreciated.
0
Hello,
I'm trying to move to the next record of my table with this gadget I made but I realize that there are ID numbers that are missing (which have been deliberately deleted).
I can not therefore go to the next recording if it does not exist.
Do you have an idea?

For example :
Reference BC19000001 exists
Reference BC19000002 exists
Reference BC19000003 does not exist
Reference BC19000004 exists
I'm looking to go from 2 to 4 since 3 does not exist

<?php
$Stat2 = $pdo->query("SELECT MAX(Reference) AS Nb FROM tb_shop_recap");
$data2 = $Stat2->fetch(PDO::FETCH_ASSOC);

	if($data["Reference"] == $data2["Nb"]) {
	echo "<a class='btn btn-success' disabled>Suivant</a>";
	} else {
		$Reference = explode("BC", $data["Reference"]);
		$FA = $Reference[0];
		$NM = $Reference[1];
		$RF = "BC".sprintf('%08d', $NM + 1);

		echo "<a href='editer.php?page=".$RF."' class='btn btn-success'>Suivant</a>";
	}
?>

Open in new window

0
I have installed VtigerCRM and started working.
I changed from http to https but site not opening after that.
Capture43.JPGI have a certificate ready but dont know where is the certificate location.
I followed as per this article
https://www.fastcomet.com/tutorials/vtiger/enable-ssl
0
hi my xampp not starting in browser
xampp
0
Hello,
Any suggestions for an open-source Education ERP system under MIT or Apache license?
0
Hi All,

I am a beginner of Laravel and I use MS SQL.
I want to create API to pass image for GET and POST.

The image will be stored to MS SQL database.

How could I do it?

Thank you.
0
Announcing the Winners!
LVL 13
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

Move a Wordpress site from wildwestdomains (Godaddy's Sister) Deluxe hosting to Godaddy Deluxe hosting CPanel site. The site won't load I get this from error log. I did not design this and I have never moved WP sites before so any help would be great.

[03-Oct-2019 08:11:45 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function site_url() in /home/mivn8z69yz1h/public_html/danatannenbaummd.com/wp/wordpress/wp-content/plugins/gravityforms/includes/webapi/webapi.php:21
Stack trace:
#0 /home/mivn8z69yz1h/public_html/danatannenbaummd.com/wp/wordpress/wp-content/plugins/gravityforms/gravityforms.php(162): require_once()
#1 /home/mivn8z69yz1h/public_html/danatannenbaummd.com/wp/wordpress/wp-settings.php(305): include_once('/home/mivn8z69y...')
#2 /home/mivn8z69yz1h/public_html/danatannenbaummd.com/wp/wordpress/wp-config.php(179): require_once('/home/mivn8z69y...')
#3 /home/mivn8z69yz1h/public_html/danatannenbaummd.com/wp/wordpress/wp-load.php(37): require_once('/home/mivn8z69y...')
#4 /home/mivn8z69yz1h/public_html/danatannenbaummd.com/wp/wordpress/wp-blog-header.php(13): require_once('/home/mivn8z69y...')
#5 /home/mivn8z69yz1h/public_html/danatannenbaummd.com/index.php(17): require('/home/mivn8z69y...')
#6 {main}
  thrown in /home/mivn8z69yz1h/public_html/danatannenbaummd.com/wp/wordpress/wp-content/plugins/gravityforms/includes/webapi/webapi.php on line 21

Open in new window


Line 21 is:
define( 'GFWEBAPI_API_BASE_URL', site_url( GFWEBAPI_SLUG ) );

the PHP is:

Open in new window

0
I'm working with a small company that runs a website with an e-commerce system running in the Laravel framework with the rest of the site running in WordPress. Now I want to take a copy of all of this so that I can work on stuff without affecting the production site. Naturally there is no existing dev area. This was all set up for them by a 3rd party who have effectively run away and refuse to answer any calls or emails. I've created a VM running Ubuntu 18.04, Laravel (5.7 I think) MariaDB Apache2 and PHP7.2. I can (and have) taken a backup copy of the WordPress items that I can install onto the VM using the Duplicator Pro plugin. I've tested this on the VM and know that I can expand everything there and having done so I can at least rung the CMS side of WP although seeing the actual web pages is difficult.

I need to get this running partly because I may need to move from the existing hosting arrangement so want to use this as a sort of trial run in addition to creating a dev setup. My question is what do I need to do to get this working? Do I need to make changes in the Laravel set up? It's still got the "your-project" folder where I've put things like phpminiadmin.php (like phpMyAdmin but just one page) so I know that all the bits are running. Can I get away with just duplicating the file and folder structure of the production site and then run the Duplicator Pro installer script to set up the site? Am I being too naïve here? :-)
0
Hi,

We have a contact form on our website that we are testing.

The form was created using HTML and I used PHP code to send the details through email.

I have it set that a person fills out the contact form, clicks on "submit" button and the details are sent as email to our Gmail address.

As emails kept going to spam, I set that contact form emails are sent from our domain email address to fix this.

These contact form emails sent successfully to our Gmail address but when sent to our domain email address, the email is not received and not in Junk folder (this email address receives and sends emails fine).

We would like to have contact form details sent to our domain email address.

What do we need to do to get this to work?

Thanks,
Robbie
0
Hi All,

I have application that created with laravel and publish to windows server.
Then I want to create development environment.
So I copy from production folder to a new one.
I create a new website that pointed to the new folder.
I could login, but after login error message 500 | server error.
What is going on ?

Thank you.
0
I am trying to conditionally add items to an array (I've tried a couple different approaches, below are 2)

        'items' => [
            ['label' => 'Countries', 'icon'=>'fa fa-globe', 'url'=>Url::to(['/lst-countries/index'])],
            ['label' => 'Province', 'icon'=>'fa fa-map', 'url'=>Url::to(['/lst-provinces/index'])],
            (Yii::$app->user->can('Administrator') ? ['label' => 'Currencies', 'icon'=>'fa fa-dollar', 'url'=>Url::to(['/lst-currencies/index'])] : Null),
        ],

        'items' => [
            ['label' => 'Countries', 'icon'=>'fa fa-globe', 'url'=>Url::to(['/lst-countries/index'])],
            ['label' => 'Province', 'icon'=>'fa fa-map', 'url'=>Url::to(['/lst-provinces/index'])],
            (Yii::$app->user->can('Administrator') ? ['label' => 'Currencies', 'icon'=>'fa fa-dollar', 'url'=>Url::to(['/lst-currencies/index'])] : []),
        ],

but when the condition isn't met I end up with a blank item and I don't want any item at all, how can I achieve this?

Thank you.
0
Good morning all,
I encounter a little problem with my code js and ask for your help.

Here is my code that calls my calculation page:
function Montant_Livraison() {
	var VAL_Poids 		= $('#VAL_Poids').val();
	var VAL_Livraison 	= $('#VAL_Livraison').val();
	var VAL_Zone 		= $('#VAL_Zone').val();
	var VAL_Lieu		= $('#VAL_Lieu').val();
	var VAL_Table;
	switch (VAL_Livraison) {
		case "SIVOP"	: VAL_Table = null; break;
		case "EXPRESS"	: VAL_Table = "tb_shop_prices_laposte"; break;
		case "LA POSTE"	: VAL_Table = "tb_shop_prices_laposte"; break;
		case "DHL"		: VAL_Table = "tb_shop_prices_dhl"; break;
		default			: VAL_Table = null; break;

	}

	var data = {VAL_Poids:VAL_Poids, VAL_Livraison:VAL_Livraison, VAL_Table:VAL_Table, VAL_Zone:VAL_Zone, VAL_Lieu:VAL_Lieu};

	$.ajax({
				type: "POST",
				url: "_montant_livraison.php",
				cache: false,
				data: data,
				async: true,
				dataType: "json"
			})

	.done(function(reponse) {
	var erreur = typeof(reponse.Error) != 'undefined' ? reponse.Error : null;
	var result = typeof(reponse.success) != 'undefined' ? reponse.success : null;

	if (!erreur) {
	if (result != null) {
	console.log('Resultat', result);

var TAX = ""
var Poids = "";

	$.each(result, function(i, vx) {
	$.each(vx, function(colonne, valeur) {

var Taux = Number(<?php echo $MNY_Taux; ?>);
var Pays = document.getElementById("VAL_Lieu").value;

	});
	});

$("#RCP_Frais").html("<?php echo ": ".$MNY_Symbole." "; ?>" + Poids);
$("#VAL_Transport").val(Poids);

Open in new window

0
We are developing PHP program to get Office 365 data, such as calendar.
Use Office 365 Home account.
Use Microsoft Graph API.
Use client credentials grant type.

We can get token, user profile, but can not get calendar.

https://docs.microsoft.com/en-us/graph/auth-v2-service 
Follow this document,
[1] Register app - OK
[2] Configure for Microsoft Graph - OK
Calendars.Read Application Read calendars in all mailboxes
Calendars.ReadWrite Application Read and write calendars in all mailboxes
User.Read.All Application Read all users' full profiles
User.ReadWrite.All Application Read and write all users' full profiles

[3] Get administrator consent - OK
[4] Get access token - OK
[5] Use access token to call Microsoft Graph
Get user - OK works well to get user profile
Get calendar - not working
{
  "error": {
    "code": "OrganizationFromTenantGuidNotFound",
    "message": "The tenant for tenant guid '<tenant-ID>' does not exist.",
    "innerError": {
      "request-id": "<request-id>",
      "date": "2019-09-20T20:15:31"
    }
  }
}
0
Some time ago we migrated some databases from SQL Server 2012 running on Windows Server 2008 R2 (Databases are in an Availability Group) to SQL Server 2016 running on Windows Server 2016.

The new server is running on All-Flash storage.

There are a pair of web servers running a web application, these servers are Windows Server 2016 and it is a PHP web application running in IIS.

Since migrating there has been a noticable reduction in page load times, particularly when saving data.

Typically it was < 5 seconds, but now has increased to >10 seconds.

We use ExtraHop to monitor our wire data and can see that round trip times to the DB servers is <100ms, however the application executes a significant amount of queries per save operation, so the comulative effect could be a part to play in the performance issues.

We have disabled Anti-Virus, but this had no effect.

What would be the suggested places to look to try and identify where the bottleneck is?
0
I am making a php script to access Office 365 single sign on.
In Office 365 I registered a new app and made the necessary settings based on another app the was registered for my Coldfusion website which works ok.
I am using this class https://www.phpclasses.org/package/7700-PHP-Authorize-and-access-APIs-using-OAuth.html to get access to Office 365 using Oauth2.
That all works fine.
But after logging I use curl to call the api https://graph.microsoft.com/beta/me with the access token as header to find out who has logged on.
The result is this error:
Error:
{ "error": { "code": "InvalidAuthenticationToken", "message": "Access token validation failure. Invalid audience.", "innerError": { "request-id": "85c73f9f-4931-4f7d-b700-26cc174fcff3", "date": "2019-09-17T08:08:16" } } }
Anyone any idea how to solve this?
0
CompTIA Network+
LVL 13
CompTIA Network+

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

Hi, I need help with this problem.

I need to use a proxy socks4 via php curl

i have php5.6

with socks5 I have no problem and I use

curl_setopt ($ ch, CURLOPT_PROXYTYPE, 7);

but I have no idea how to do it with socks4

Thank you
0
hi,

The following page demos a simple API call and displays the result:

https://developer.waveapps.com/hc/en-us/articles/360018937431-API-Playground

I'd like to produce the same output on my own html page. How could I start?

Many thanks
0
I am looking to build an alternative to Zapier "zap" using a digital ocean droplet. Can anybody recommend a technology? The first thing that comes to mind is Node.js or PHP. Zapier is great, and we love it, however we are now being asked to processes files with up to 10,000 lines per file per month. This brings our zapier bill from @20 per month to $300. I would like to have a webHook online with custom URL. (myDomain.com/myWebHook)

our zap is very simple:
* push FirstName, LastName, Email to a webook
* add the user to a mail chimp list
* add the user to a wordPress memberPress subscription
* send the user a custom welcome email from an office 365 account

There are a few reasons it might make sense to build our own integration tool:
1 ) if we are going to get 10,000 items to process every month or so, it it much nicer to just budget $50 per month for an AWS or Digital Ocean VM
2 ) During the memberpress user create, then add to the correct subscription, the smallest time pause that Zapier allows is 1 minute. When we are processing 10K of new users, this can extend out for quite some time. It might be easier to have the ability to control down to a 15 second wait time.
3 ) I am not sure how zapier runs each zap, but during the memberPress adds it might be nice to know they are all running in serial. I often wonder if zapier runs them in parallel. We frequently get DB timeout errors when the zaps are running.

What I am looking for is advice on the following:
1
Here's this old chestnut again.

I've got this to work: Most recent 10 posts have term "Free". Whenever a new post is added eleventh post gets term "Premium", the term with id 174 is excluded from this dynamic term naming.

/*Add terms to posts */

add_action( 'save_post', 'total_set_default_object_terms', 11, 2 );
function total_set_default_object_terms( $post_id, $post ) {
  if ( 'publish' === $post->post_status) {
    $position = 1;
    $args = [
      'numberposts' => -1,
      'order' 			=> 'DESC',
      'orderby' 		=> 'date',
      'post_type' 	=> 'post',
      //'taxonomy' => 'episode_type',
      'tax_query' => array(
					array(
					'taxonomy' => 'episode_type',
					'field' => 'id',
					'terms' => array( '174' ),
					'operator' => 'NOT IN',
					),
					),
						];
						
						
    $posts = get_posts( $args );// query posts that are episodes in descending publish date order
    foreach($posts as $post) {
      if ($position > 10) {
        wp_set_object_terms($post->ID, 'premium', 'episode_type', false);
      }
             
      $taxonomies = get_object_taxonomies( $post->post_type );
      
      $position++;
     }
  }
}

Open in new window


However, when I trash any of the 10 most recent posts and update any post, I don't get 10 Free posts, just the number remaining after the trashing/deletions.

Only 7 posts with term "Free" when there should be 10.
How do I remedy that in the code above?
0
I am having a problem with PHP coding  to force a file to download. I have attached the page - index.html
which redirects to dwnapppdf.php, which selects the fie to download based on the value of "id" send to it in a query string. What happens is that it writes the file on a web page instead of downloading it.
Yet, it works fine in localhost mode. My website is a php base so I know it isn't that problem.
I have attached both pages, and the link is https://mjsayers/com/index.html
I would appreciate any help. Thank you.
0
We have a page on our website that offers products for sale.  Some of the products are linked to an outside website to purchase and some have a PayPal "Add to Cart" button.  The first item (Thrip Cloth) on the page was the last one added to the page and when you click on the "Add to Cart" button the browser says it is waiting for the main website page and eventually, it times out with a "Gateway timeout" error and never gets added to the cart.
There are 7 of these buttons on the page, all the other 6 buttons work fine.  If I take out any of the other buttons and try the first item on the page (Thrip Cloth) after that, then it works beautifully.  My conclusion is that we are limited to 6 buttons on the page.  PayPal says there is no limit.  They suggested calling our hosting company; they said there is no limit imposed by them and it is out of their scope.  
This is a Linux site using PHP.
The site is http://crcweb.org/books.php - this file has 7 buttons on it.
The site page that works is http://crcweb.org/books%202019-09-10D.php
Does anyone have any ideas on what else I can look at to troubleshoot this issue?
Any help would be most appreciated!
Jan
books.php
0

PHP

121K

Solutions

33K

Contributors

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.