tmp_name is empty wordpress php image upload ?

If your getting tmp_name value empty in word press php image upload ,it is because of temp directory path issues you can solve by using following steps.

1) By using FTP or hosting create a php.ini file in root folder(don’t create if that file already their means.)

2) Add below line in that php.ini file

i) upload_tmp_dir= /home/username/public_html/temp/ ( /home/username/public_html= root path)

ii) Create a folder temp( in root ditectory and give full permission)

3) Now you can use same PHP upload script to upload your image

if (move_uploaded_file($_FILES[“fileToUpload”][“tmp_name”], $target_file)) {
echo “The file “. basename( $_FILES[“fileToUpload”][“name”]). ” has been uploaded.”;
} else {
echo “Sorry, there was an error uploading your file.”;
}

Cheers ūüôā

Dropdown menu in wordpress not working in mobile device

One of the main issue for integrating bootstrap js to WordPress is the conflicting of menu bar with bootstrap css.To avoid this you can do any of below steps .Actually .hide{display:none!important} in bootstrap css file automatically hiding menu in WordPress .But in mobile device WordPress nav css trying to display that menu ,but this css over hidding again .

To avoid this

  1.  Remove

 

.hide{display:none!important}  from bootstrap.min.css

0r

Add below style in the page (for mobile device only)

.nav-wrapper .hide {
 display: block !important;

mysql error Field doesn’t have a default values ?

Here is the steps to solve¬†¬†field doesn’t have a default values error

1) Go to phpMyadmin

2) Click on variables menu  as shown in figure

mysql error Field doesn't have a default values

 

3)¬†Scroll down to find sql mode and¬†click on edit button as shown in below ¬†image remove ‘STRICT_TRANS_TABLES’ Save it.

 

remove 'STRICT_TRANS_TABLES' Save it.

 

 

 

 

Paypal Masspay or Auto payment example PHP code





<?php

 

$environment = ‘sandbox’; // or ‘beta-sandbox’ or ‘live’
function PPHttpPost($methodName_, $nvpStr_) {
global $environment;

/*
// Set up your API credentials, PayPal end point, and API version.
*/

$API_UserName = ”;
$API_Password =”;
$API_Signature = ”;

// $environment = “sandbox”;
/*
$API_UserName = urlencode(‘my_api_username’);
$API_Password = urlencode(‘my_api_password’);
$API_Signature = urlencode(‘my_api_signature’);

*/ $API_Endpoint = “https://api-3t.paypal.com/nvp”;
if(“sandbox” === $environment || “beta-sandbox” === $environment) {
$API_Endpoint = “https://api-3t.$environment.paypal.com/nvp”;
}
$version = urlencode(‘51.0’);

// Set the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

// Turn off the server and peer verification (TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);

// Set the API operation, version, and API signature in the request.
$nvpreq = “METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_”;

// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

// Get response from the server.
$httpResponse = curl_exec($ch);

if(!$httpResponse) {
exit(“$methodName_ failed: “.curl_error($ch).'(‘.curl_errno($ch).’)’);
}

// Extract the response details.
$httpResponseAr = explode(“&”, $httpResponse);

$httpParsedResponseAr = array();
foreach ($httpResponseAr as $i => $value) {
$tmpAr = explode(“=”, $value);
if(sizeof($tmpAr) > 1) {
$httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
}
}

if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists(‘ACK’, $httpParsedResponseAr)) {
exit(“Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.”);
}

return $httpParsedResponseAr;
}

// Set request-specific fields.
$emailSubject =urlencode(‘example_email_subject’);
$receiverType = urlencode(‘EmailAddress’);
$currency = urlencode(‘USD’); // or other currency (‘GBP’, ‘EUR’, ‘JPY’, ‘CAD’, ‘AUD’)

// Add request-specific fields to the request string.
$nvpStr=”&EMAILSUBJECT=$emailSubject&RECEIVERTYPE=$receiverType&CURRENCYCODE=$currency”;

$receiversArray = array();
$receiverData1 = array( ‘receiverEmail’ => “[email protected]”,
‘amount’ => “7”,
‘uniqueID’ => “100”,
‘note’ => “Testing1”);

$receiverData2 = array( ‘receiverEmail’ => “[email protected]”,
‘amount’ => “6”,
‘uniqueID’ => “200”,
‘note’ => “Testing2”);

$receiversArray[0] = $receiverData1;
$receiversArray[1] = $receiverData2;
/*
for($i = 0; $i < 3; $i++) {
$receiverData = array( ‘receiverEmail’ => “[email protected]”,
‘amount’ => “example_amount”,
‘uniqueID’ => “example_unique_id”,
‘note’ => “example_note”);
$receiversArray[$i] = $receiverData;
}
*/

foreach($receiversArray as $i => $receiverData) {
$receiverEmail = urlencode($receiverData[‘receiverEmail’]);
$amount = urlencode($receiverData[‘amount’]);
$uniqueID = urlencode($receiverData[‘uniqueID’]);
$note = urlencode($receiverData[‘note’]);
$nvpStr .= “&L_EMAIL$i=$receiverEmail&L_Amt$i=$amount&L_UNIQUEID$i=$uniqueID&L_NOTE$i=$note”;
}

// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = PPHttpPost(‘MassPay’, $nvpStr);

if(“SUCCESS” == strtoupper($httpParsedResponseAr[“ACK”]) || “SUCCESSWITHWARNING” == strtoupper($httpParsedResponseAr[“ACK”])) {
exit(‘MassPay Completed Successfully: ‘.print_r($httpParsedResponseAr, true));
} else {
exit(‘MassPay failed: ‘ . print_r($httpParsedResponseAr, true));
}

?>