$sql = "SELECT pid, project.eid, pname, duedate, subdate, mark, points, firstName, lastName, base, bonus, total FROM `project` , `rank` ,`employee`, `salary` WHERE project.eid = $id AND pid = $pid";
Category: PHP
Category Added in a WPeMatico Campaign
Only some pages showing “There has been a critical error on this website”
I am using WordPress wplms theme. only some tabs and menu pages are showing there has been a critical error on this website.I updated wplms theme,wordpress and php version of the website,activated debugging mode,deactivated all the plugins but the problems still persist.can anybody please help me with this.
Payment of purchase receipt with several methods
I have a receipt that I want to pay this receipt in several ways through a bank or fund or cheque or wallet and payment by any of these methods must save the payment information. With Laravel in MySQL. How can I do this?
Woocommerce – Use SKU as unique identifier in the order creation with REST API
I have a website where I want to transfer woocommerce orders. Everything is working very well now but I have a strungle with product pairing. Products ids on testing are not the same as on live website. What do I need to add products to order and pair them not with their ID but with the SKU which is the same on both websites. My code is bellow.
I’m following this structure over here: https://woocommerce.github.io/woocommerce-rest-api-docs/?php#create-an-order
add_action( 'woocommerce_order_status_processing_to_gls', 'transfer_order_woo_api', 9999, 3 );
function transfer_order_woo_api( $order_id, $order ) {
$live_ck = 'ck_some ID';
$live_cs = 'cs_SOME ID';
$live_url = 'https://testsite.com/wp-json/wc/v3/orders?consumer_key=' . $live_ck . '&consumer_secret=' . $live_cs;
$order = wc_get_order( $order_id );
// Line items - HERE IS THE PROBLEM
$lineitems = array();
foreach ( $order->get_items() as $item_id => $item ) {
$product_id = $item->get_product_id();
$quantity = $item->get_quantity();
$product = $item->get_product();
$lineitem = array('quantity' => $quantity,
'product_id' => $product_id //I need to pair theese line items by the SKU because the product ID is not the same on different sites but the SKU is the same.
);
$lineitems[] = $lineitem;
}
$body = array(
'status' => 'processing',
'meta_data' => array(
array(
'key' => 'carrier',
'value' => ''.get_post_meta($order->id, 'ywot_carrier_id', true).''
),
array(
'key' => 'order_number',
'value' => ''.get_post_meta($order->id, '_alg_wc_custom_order_number', true).''
),
array(
'key' => 'orderid',
'value' => $order->get_id(),
),
array(
'key' => 'shipped_date',
'value' => ''.get_post_meta($order->id, 'shipped_date', true).''
),
array(
'key' => 'ywot_tracking_code',
'value' => ''.get_post_meta($order->id, 'ywot_tracking_code', true).''
)),
'billing' => array(
'first_name' => $order->get_billing_first_name(),
'last_name' => $order->get_billing_last_name(),
'address1' => $order->get_billing_address_1(),
'city' => $order->get_billing_city(),
'postcode' => $order->get_billing_postcode(),
'country' => $order->get_billing_country(),
'phone' => $order->get_billing_phone(),
),
'shipping' => array(
'first_name' => $order->get_shipping_first_name(),
'last_name' => $order->get_shipping_last_name(),
'address1' => $order->get_shipping_address_1(),
'city' => $order->get_shipping_city(),
'postcode' => $order->get_shipping_postcode(),
'country' => $order->get_shipping_country(),
),
'line_items' => $lineitems,
);
$raw_response = wp_remote_post( $live_url,
array(
'headers' => array( 'Content-Type' => 'application/json' ),
'timeout' => 30,
'body' => json_encode( $body ),
)
);
Thanks in advance for your ideas.
Import data from .php webpage to Google Sheets [duplicate]
Kindly answer the following : I am trying to pull a table(financial data) from the following website into Googlesheets: https://www.moneycontrol.com/financials/relianceindustries/balance-sheetVI/RI#RI . Website is given for illustration
In the above webpage, we can select various options of financial data (Balance Sheet, Profit Loss Statement etc.). On choosing an option (say Profit loss statement) and pressing the Go button for “Print/Copy to Excel” the following webpage displays : https://www.moneycontrol.com/stocks/company_info/print_main.php The second website has remark that “The data can be copied and pasted into an MS-Excel sheet”. But I am not able to pull the data from the .php webpage directly into Google Sheets I am using the IMPORTHTML but I am getting error using =IMPORTHTML(“https://www.moneycontrol.com/stocks/company_info/print_main.php”,”table”,2).
Also, the the financial data (say Profit loss statement) in the webpage: moneycontrol.com/stocks/company_info/print_main.php which has a remark that “The data can be copied and pasted into an MS-Excel sheet” . While the data in a table format can be directly copied and pasted into an MS-Excel sheet, it is not showing up as a table while I am trying to import the data from the web directly into MS-Excel using Power Query. Please solve this issue and also provide a code how import the data from .php webpage directly into Google Sheets
How to get id of a row to display more info?
My purpose is when we click on the button info, we have more info displayed in the same page.
But, we need to get info’s client for the good client.
With my structure of td echo php, i am lost.
For example, i want to display info only for id_client 1
My php HTML (simple array)
<table border=1>
<tr>
<td>#</td>
<td>Nom</td>
<tr>
<?php
require 'config.php';
$rows = mysqli_query($conn, "SELECT * FROM client");
$i = 1;
?>
<?php foreach ($rows as $row) : ?>
<tr id_client=<?php echo $row["id_client"]; ?>>
<td><?php echo $row["id_client"]; ?></td>
<td> <?php echo $row["nom_client"]; ?></td>
<td><button type="button" onclick="display_info(this.id_client);">Info client</button></td>
<td><button type="button" onclick="hide_info(<?php echo $row['id_client']; ?>);">Masquer client</button></td>
<?php endforeach; ?>
</div>
</table>
Info array
<table id="info_client" border=1>
<tr>
<td>#</td>
<td>Nom</td>
<td>Prénom</td>
<td>Date de naissance</td>
<td>Adresse</td>
<td>Adresse mail</td>
<td>Téléphone</td>
<td> </td>
</tr>
<?php
require 'config.php';
$rows = mysqli_query($conn, "SELECT * FROM client");
$i = 1;
?>
<tr id_client=<?php echo $row["id_client"]; ?>>
<?php
foreach ($rows as $row) :
?>
<td id="id"><?php echo $row["id_client"]; ?></td>
<td id="nom"><?php echo $row["nom_client"]; ?></td>
<td id="prenom"><?php echo $row["prenom_client"]; ?></td>
<?php echo '<td id="date"' . $class . '>' . $row["client_date_naissance"] . ' </td>'; ?>
<td id="adresse"><?php echo $row["client_adresse"]; ?></td>
<td id="mail"><?php echo $row["client_mail"]; ?></td>
<td id="tph"><?php echo $row["client_tph"]; ?></td>
<td>
<a href="edit_client.php? id_client=<?php echo $row['id_client']; ?>">Modifier</a>
<button type="button" onclick="submitData(<?php echo $row['id_client']; ?>);">Supprimer</button>
</td>
</tr>
My ajax function
function display_info(action) {
$(document).ready(function() {
var data = {
action: action,
id_client: $("#id_client").val(),
nom_client: $("#nom_client").val(),
prenom_client: $("#prenom_client").val(),
client_date_naissance: $("#client_date_naissance").val(),
client_adresse: $("#client_adresse").val(),
client_mail: $("#client_mail").val(),
client_tph: $("#client_tph").val(),
};
$.ajax({
url: 'function.php',
type: 'post',
data: data,
success: function(response) {
$("#" + action).css("display", "block");
location.reload();
}
});
});
}
PHP functions SQL
if(isset($_POST["action"])){
if($_POST["action"] == "insert"){
insert();
}
else if($_POST["action"] == "edit"){
edit();
}
else if($_POST["action"]== "read"){
read();
}
else{
delete();
}
}
function read (){
global $conn;
$id_client = $_POST["action"];
$query = "SELECT * from client WHERE id_client = '$id_client'" ;
mysqli_query($conn, $query);
}
Sorry the lenght.
I know i am doing something wrong but i don’t know…
Thank you guys.
is there a way to store data from one form then submit it with another?
I am building a contact form that will send an email containing the data inputed. But it is suppose to contain data that has been inputed in a form which submit button is also a CTA that shows the contact form. Is there a way to store data written by user into the first form to then add it to the data written into the contact form ? Basicly the first form is a calculator and on user click it shows the result next to contact form. And upon filling that contact form the email needs to contain the info from calculator as well as the info from contact form.
Need help using goutte to get url from a piece of code
I am trying to use goutte to scrape google serp and i precisely want to get the url from the search results but i am finding it difficult to do so with goutte primarily because of the code layout. Check an example which i took from google serp source code below:
<div class="TbwUpd NJjxre">
<cite class="iUh30 qLRx3b tjvcx" role="text">https://blog.apilayer.com
<span class="dyjrff qzEoUe" role="text"> › search</span></cite></div>
I want to get the url https://blog.apilayer.com but i don’t know how to put the goutte code to do this. This is what i did for the title of the search results and it works fine:
$url = 'https://www.google.com/search?' . http_build_query(array('q' => $query));
// Request search results
$client = new Client();
$crawler = $client->request('GET', $url);
return $crawler->filter('h3')->each(function ($node){
return $info[''] = $node->text();
});
The above is easy since the title is wrapped in an like below:
<h3 class="LC20lb MBeuO DKV0Md">A Complete Guide to Google Search Result Scraping</h3>
but then to get the url from the search result is difficult since the url is not directly wrapped on the target html tag.
How can i convert Base64 string to an image file using PHP from SOAP?
I use this function to connect to a web service that allows me to retrieve product photos for e-commerce. However, it returns strange strings (picture below).
function RecupPhotoProduit($pUsername, $pPassword, $pClient, $pCodeFab, $pReffab, $pi) {
$optionsRecupererPhotoProduit = array(
'user' => $pUsername,
'password' => $pPassword,
'codeFab' => $pCodeFab,
'refFab' => $pReffab,
);
$responseRecupererPhotoProduit = $pClient->RecupererPhotoProduit($optionsRecupererPhotoProduit);
$array = get_object_vars($responseRecupererPhotoProduit);
if(empty($array)) {
$responseRecupererPhotoProduit = null;
} else {
$responseRecupererPhotoProduit = $responseRecupererPhotoProduit->RecupererPhotoProduitResult;
$responseRecupererPhotoProduit = base64_decode($responseRecupererPhotoProduit);
}
return $responseRecupererPhotoProduit;
}
This code is supposed to retrieve and decode the Base64 string contained in “RetrievePhotoProductResult” of my XML (“/9j/4AAQSkZJRgABAQEAYABgA…”).
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<RecupererPhotoProduitResponse xmlns="http://tempuri.org/"> <RecupererPhotoProduitResult>/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCACEAJoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AA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f2q4drhwm7zQmQoP8AdH8IH4k1oXl9b2Fv51xIiKeFywG49hWFf63a6ba2sU++ZpZBDGlvllyeu4jqPXHSsmRLrVLmUam0M0RnDW8YTiNR03HvzzjtW8aPMy5xjeyNfS0m1rV2u76BBHauXh757IfbGGOPdTXU1Q0eDytORyuHnPmtnrz90H3ChR+FX6xm7y0MmFFFFQIKKKKACiiigAooooAK5zV4At+2AMyKHA/Q/wAh+ddHWD4p0a/1fT0GmXiWt5ESUd03KwI6H05wcj0rWjPklcadmcNrcW/WlhcAxS221lJID5J4PseRSW09zZtYrb3Tw2VoCDbquRJGeMMTz8p6fWqkFn4iiviPEgWS7UGNHjUKrp25HXJ6H1FXNvOeOecsevbJ+vQ+hrsVpK5ZcXX9Vjt74taQT3Cu32OJX2h1HRZGPRsZORxVj+3yLm2iFkTbyRlpp9w/cnjaNvVsnPI6YrPCLjjpj3zgf+zL+opGjOfuKfYPxz2+jdvep9nEa02LT+JNVFjdG1tIILxZGW28xt8bIMfO+OQeuVHSm3Opajdais4vZFhERiNuwyjM3RyeufTHrVQqM5JA77iSfof6Gp4og3AQH+HZnGfVf6imoRWwilY20dtfWdvbjyovNLiMMcEk5bP+1nmuvt7YSSLCQP3xEYHTIP3sf8B3H8K5W6h1F1d9JTzL5cNCHUHc2cZx6joR7V0/g/QdftH+3eIr6Ke4KnbFHGAFJxzn2GR/wI8VNSooxaE3Y7GiiiuEgKKKKACiiigAooooAKKKKACiiigDlfFaq1xDkZ+Tkeo5rmJFCeYcZKhj83fBA5+oPNFFd9H4EWtiYIDLs5/1rJnPPyrkH6jpn061EVUoG2jmNWx2+Y4I+nf60UVoMQgLkjqN5z7r3/EdasxKvzAqCAyJg9we34dqKKTA19EQRa9tGTmQjLcnhW5+tdjRRXHX+IiW4UUUViIKKKKACiiigD//2Q==</RecupererPhotoProduitResult>
</RecupererPhotoProduitResponse>
</soap:Body>
</soap:Envelope>
In my code, I browse all the products of the ecommerce with a foreach loop.
For each product, I retrieve the information of the image given by my function “RecupPhotoProduct()” in a variable “$dataRecupPhotoProduct”.
I then add the information of the image at the end of each line of my product. I save all this data in a CSV file that I can send to a WordPress plugin to display my products and their images.
$fp = fopen(plugin_dir_path(__FILE__).'file.csv', 'w+');
$i = 0;
foreach ($dataRecupererEtatStock as $fields) {
$dataRecupPhotoProduit = RecupPhotoProduit($username, $password, $client, $fields->CodeFab, $fields->RefFab, $i);
$i+=1;
$fields->image = $dataRecupPhotoProduit;
fputcsv($fp, get_object_vars($fields));
}
fclose($fp);
My problem is that despite the php base64_decode function, the image information is still unreadable.
Indeed, in my CSV, this is what the images look like:
Ideally, in my RecupPhotoProduct() function, I would like to upload the images so that I can simply store their names in my CSV file.
I have already tried, but the images are unreadable.
Do you know how to proceed?
How do i get html do post data through php in a docker container?
So i have an HTML form which on click of ‘submit’ posts input data through to a basic PHP file which takes the data and stores it in a JSON file. I am able to run the index.html file on a PHP webserver with the command php -S localhost:4040 and on submit, it does as expected. i want to containerise the website. But when I run the website on a docker container, click submit on the form, I get shown ‘405 Not Allowed’ error. i use docker-compose.yml file to get the docker container running. How can I get this working on a docker container?
Snippet of my code.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Registration</title>
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
</head>
<body class="container">
<div class="container">
<h1>Registration</h1>
<section>
<form id="regForm" action="form.php" method="post">
<div class="form-group">
<label for="nameInput">Name</label>
<input type="text" class="form-control" id="nameInput" name="studentName" aria-describedby="emailHelp" placeholder="Enter your full name">
</div>
<div class="form-group">
<label for="loginInput">Login</label>
<input type="text" class="form-control" id="loginInput" name="studentId" placeholder="Enter your login">
</div>
<button type="submit" name="submit" value="submit" class="btn btn-primary" id="submitForm">Submit</button>
</form>
</section>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
PHP
<?php
error_reporting(0);
echo "<h2>Submitted</h2>";
if(isset($_REQUEST['submit'])) {
$data = '';
$filename = "data.json";
//if file exists
if(is_file($filename)) {
$data = file_get_contents($filename);
}
$json_arr = json_decode($data,true);
$json_arr[] = array(
'studentId' => $_REQUEST['studentId'],
'studentName' => $_REQUEST['studentName'],
);
//saving file in jsonarray
file_put_contents($filename, json_encode($json_arr));
}
?>
docker-compose.yml
version: '3'
services:
product-services:
build: ./src
volumes:
- ./src:/usr/share/nginx/html
ports:
- 5001:80
How to share SESSION between LARAVEL user and GUZZLE
I am using Guzzle from my Laravel application to CURL into another Laravel application.
The user database is shared between these apps and both use the same session table In a common database.
I want to pass the session from the first Laravel app (which users have access directly) to the nested Laravel apps (which users have access through guzzle request).
the first laravel app is a front that acts as a subdirectory or somehow similar to a reverse proxy, getting the user request and delivering the requested page via a making guzzle request and returning the response.
I have followed the instructions of this blog but due to the difference of user-agent and etc in the request of guzzle and user, it does not work.
is there any way to make the guzzle use an existing session from another laravel app and user agent?
How do I hide my website’s the log files from users who aren’t me?
My website has a couple logs including an error log, email log, etc. I already made it so that they can be accessed only if reached through a link on the website (using RewriteEngine in .htaccess), but technically, if someone knew the URL path, they could just create an anchor tag in the browser’s “Inspect element” mode and access the file. I also tried prefacing the log file with some php code that checks if user is logged in and if it’s me, but it just gets parsed as text.
How can I make the logs inaccessible by anyone who isn’t me?
Get Server CPU Type with php
I’m trying to determine the CPU type of the server my PHP is running on. I’m not need the CPU usage.
The determination of the CPU type should work independently of the system (Win/Linux..).
The solutions I found evaluate the /proc/cpuinfo file.
This solution only works for linux systems and then only if the rights for access are available.
Example: PHP Script – Get Server Processor
My approach was to use php function php_uname with parameter ‘m’.
<?php
var_dump(php_uname('m'));
//string(6) "x86_64"
Unfortunately, this solution fails on some host systems.
An answer is then generated there which is identical to the parameter ‘a’.
Example:
'Linux localhost 3.10.0-1160.36.2.el7.x86_64 #1 SMP'
I am thankful for all hints.
Upload PDF file to multiple folder in php
I’m trying to upload a PDF file to multiple folders, as the code which I use as below
$uploaddir="uploadfile";
$uploaddir1="../t1/admin/uploadfile";
$type=$_FILES["file"]["type"];
$path=$uploaddir.'/'. $_FILES['file']['name'];
$path1=$uploaddir1.'/'. $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'],$path);
copy($path, $path1);
when executed the PDF file moved to $path (ie.uploadfile) folder but not to the folder path (ie. ../t1/admin/uploadfile)
Please any solutions.
I can’t redirect to Route in Symfony
Hello, everyone.
I am building symphony 5 project, but I have an issue.
The URL is not redirecting after I create or edit an element.
But in other functions, the redirectToRoute() function works.
Strange problem…
These are my controller code.
Please check it and let me know what I missed.
Thanks.
/**
* @Route("/list", name="animals")
*/
public function animals(): Response
{
if (!$this->getUser()) {
$this->redirectToRoute('app_login');
}
$animals = $this->getUser()->getAnimals();
return $this->render('animals/overview.html.twig', [
'animals' => $animals,
]);
}
And
/**
* @Route("/create", name="animal_create")
*/
public function create(Request $request, EntityManagerInterface $entityManager): Response
{
$animal = new Animal();
$customer = $this->em()->getRepository(Customer::class)->findOneBy(array('id' => $request->request->get('customer')));
$animal->setCustomer($customer);
$form = $this->createForm(AnimalType::class, $animal, [
'csrf_protection' => false,
]);
$form->handleRequest($request);
if (!$form->isSubmitted() || !$form->isValid()) {
return new Response('failed');
}
$customer->addAnimal($animal);
$entityManager->persist($animal);
$entityManager->flush();
return $this->redirectToRoute('animals');
}
/**
* @Route("/{id}/update", name="animal_update")
*/
public function update(Request $request, Animal $animal, EntityManagerInterface $entityManager): Response
{
$form = $this->createForm(AnimalType::class, $animal, [
'csrf_protection' => false,
]);
$form->handleRequest($request);
if (!$form->isSubmitted() || !$form->isValid()) {
return new Repsonse('failed');
}
$entityManager->persist($animal);
$entityManager->flush();
return $this->redirectToRoute('animals');
}