When I try to update or make changes to my pages in WP backend it redirects me to the posts lists (/wp-admin/edit.php) without saving. It also won’t let me preview pages without redirecting.
Please help!
Many thanks
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
When I try to update or make changes to my pages in WP backend it redirects me to the posts lists (/wp-admin/edit.php) without saving. It also won’t let me preview pages without redirecting.
Please help!
Many thanks
I have installed PHP from brew and it works just fine in VS Code, but on PHPStorm I am not able to configure the interpreter in order to debug my php code.
When executing:
php -v
on terminal, I get:
PHP 8.0.17 (cli) (built: Apr 5 2022 22:43:04) ( NTS ) Copyright (c)
The PHP Group Zend Engine v4.0.17, Copyright (c) Zend Technologies
with Zend OPcache v8.0.17, Copyright (c), by Zend Technologies
which tells me that this installed correctly.
this is what my code looks like:
Any help will be very appreciable.
<?php
$btn = get_field('line_btn');
if( $btn && in_array('study', $btn ) ) {
echo 'study';
}
elseif( $btn && in_array('help', $btn ) ) {
echo 'help';
}
elseif( $btn && in_array('study', 'help', $btn) ) {
echo 'both selected';
}
?>
I try to accept a file using php:
<?php
if (isset($_FILES["file"])) {
$uploaddir = '/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.n";
} else {
echo "Error";
}
}
I send Postman request as POST form-data: file: Filename.
Why I always get echo "Error";?
I have a database named (myDatabase) and a table inside which is called Category, inside the table I have 3 columns (ids, categories, product_name), I want to retrieve the values or rows that contains specific categories, or let’s say fetching values inside the table depending on an array containing some categories available in the table. This is my code but it gives error, it is not working when I want to print them.
$conn = mysqli_connect('localhost','root','','myDatabase');
$MyCategories = array('food','entertaintment','vehicle');
$where_in = implode(',', $MyCategories);
$query = "SELECT * FROM Category WHERE categories IN ($MyCategories);";
$result = mysqli_query($conn,$query);
$cats = mysqli_fetch_all($result,MYSQLI_ASSOC);
print_r($cats);
I tried that with mysqli_fetch_array() but it doesn’t work, says (arrays to string conversion) error.
$conn = mysqli_connect('localhost', 'root', '', 'myDatabase');
$MyCategories = array('food', 'entertaintment', 'vehicle');
$where_in = implode(',', $MyCategories);
$query = "SELECT * FROM Category WHERE categories IN ($MyCategories);";
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_array($result)) {
echo $row['2'];
// third column (product_name) in table Category
}
please help me, thanks a bunch.
Lately, I am trying to tweak Magento 2 Cart Price Rule feature for our business requirements and I realized something. First of all, I need to say that we override MagentoSalesRuleModelRuleConditionProductSubselect::loadAttributeOptions() because in our location we must apply the discount on top of the tax included amount so we changed the ‘base_row_total’ with the ‘base_row_total_incl_tax’. Here is the scenario;
I have 2 Cart Price Rule;(₺ = currency)
I have a cart with 1 item with a total of 300₺ and let’s say that shipping is free. Our requirements say that; it should apply the first cart price rule and should not apply the second cart price rule because after applying the first cart price rule cart total is going down to 150₺ thus second cart price rule’s condition is not met from now on.
If we go back to the reality Magento validates conditions by the product’s attributes; Magento always looks for the same value, not the discounted fresh value.
MagentoSalesRuleModelRuleConditionProduct::validate($model) declares that;
$total += ($hasValidChild && $useChildrenTotal) ?
$childrenAttrTotal * $item->getQty() : $item->getData($attr);
// $attr value is "base_row_total_incl_tax" for our case, and it does not change after every rule process step
return $this->validateAttribute($total); // this func just makes a logical comparison with boolean return
So, what do you think about this topic? Has anyone thought about it, should I just change the $total with the latest discount applied cart amount(using registry) or does anyone have a better idea?
I made 4 migrations and I’m trying to migrate them with php artisan migrate:fresh. However, I’m getting an error
Migrating: 2019_12_14_000001_create_personal_access_tokens_table
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `personal_access_tokens` add index `personal_access_tokens_tokenable_type_tokenable_id_index`(`tokenable_type`, `tokenable_id`))
at C:UsersVictorDesktopOefenexamenoefenexamenvendorlaravelframeworksrcIlluminateDatabaseConnection.php:745
741▕ // If an exception occurs when attempting to run a query, we'll format the error
742▕ // message to include the bindings with SQL, which will make this exception a
743▕ // lot more helpful to the developer instead of just the database's errors.
744▕ catch (Exception $e) {
➜ 745▕ throw new QueryException(
746▕ $query, $this->prepareBindings($bindings), $e
747▕ );
748▕ }
749▕ }
1 C:UsersVictorDesktopOefenexamenoefenexamenvendorlaravelframeworksrcIlluminateDatabaseConnection.php:530
PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")
2 C:UsersVictorDesktopOefenexamenoefenexamenvendorlaravelframeworksrcIlluminateDatabaseConnection.php:530
PDOStatement::execute()
However, I don’t have the 2019_12_14_000001_create_personal_access_tokens_table migration, why is it being ran?
I’m writing a web cryptocurrency web service and trying to encode smart contract parameters with the Etherium js library. I have created a js file and trying to import ethers library that I have installed. When I’m trying to call the created js function I get an error Uncaught SyntaxError: Cannot use import statement outside a module (at encoder.js:4:1) Here is the code
import { ethers } from "ethers";
const AbiCoder = ethers.utils.AbiCoder;
const ADDRESS_PREFIX_REGEX = /^(41)/;
const ADDRESS_PREFIX = "41";
async function encodeParams(inputs) {
let typesValues = inputs;
let parameters = "";
if (typesValues.length == 0) return parameters;
const abiCoder = new AbiCoder();
let types = [];
const values = [];
for (let i = 0; i < typesValues.length; i++) {
let { type, value } = typesValues[i];
if (type == "address")
value = value.replace(ADDRESS_PREFIX_REGEX, "0x");
else if (type == "address[]")
value = value.map((v) =>
toHex(v).replace(ADDRESS_PREFIX_REGEX, "0x")
);
types.push(type);
values.push(value);
}
console.log(types, values);
try {
parameters = abiCoder.encode(types, values).replace(/^(0x)/, "");
} catch (ex) {
console.log(ex);
}
return parameters;
}
async function main() {
let inputs = [
{
type: "address",
value: "412ed5dd8a98aea00ae32517742ea5289761b2710e",
},
{ type: "uint256", value: 50000000000 },
];
let parameters = await encodeParams(inputs);
console.log(parameters);
main();
}
Please can someone help me to understand the issue? I’m using Laravel framework. If any additional info is needed I will be happy to provide it.
I’m writing a functional test, the execution of tested code includes the execution of a symfony command but it seems like the command its not executes, it doen’t stop on a breakpoint and the results are not stored on the database, the code works when is not executed on a test.
There is any problem to execute commans on phpunit, should I configure anything??
public function testUploadResults():void{
//set api key in header
$crawler = $this->client->request( Request::METHOD_GET, '/en/upload-result');
//test if response is ok
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
//get the form
$form = $crawler->selectButton('Upload')->form();
$form['analysis[type]']->setValue('TYPE1');
$form['analysis[file]']->setValue(new UploadedFile('/var/www/test_files/test.csv', 'test.csv', 'text/csv'));
//submit form
$this->client->submit($form);
//test if response is ok
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
//probar que haya labresults para el test
$results = $this->em->getRepository('AppBundle:Result')->findBy(['sample' => 'XXXX']);
$this->assertTrue( count($results)>1 );
}
xgb=XGBRegressor(*xgb_params)
xgb_model=xgb.fit(X_train[features],y_train,
sample_weight=X_train['dataweight'])
”’error incurred during prediction”’
xgb_predict=xgb.predict(X_test[features])
I am trying to make a function where:
i search data 1 (this exist in database) within date range of 13-04-2022 to 14-04-2022 (there is no data in this date range). From this query that i used on my controller still return the data that contains a keyword that i search for (data 1). What i wanted is to return collection of data with the range of the date filter (which is nothing since i dont have any data from that date range).
How to solve this problem? is there any best practices that i could implement for this search within the filtered date?
this is my back-end :
$rekans = Rekan::query()
->join('dokters','dokters.id','=','rekans.dokter_id')
->join('pasiens','pasiens.id','=','rekans.pasien_id')
->join('penyakits','penyakits.id','=','rekans.dokter_id')
->join('treatments','treatments.id','=','rekans.treatment_id');
if(request('from_date')){
$rekans->whereDate('rekans.created_at','>=',request('from_date'));
}
if(request('to_date')){
$rekans->whereDate('rekans.created_at','<=',request('to_date'));
}
if(request('search')){
$rekans->where('berat','LIKE','%'.request('search').'%')
->orWhere('rekan_inv','LIKE','%'.request('search').'%')
->orWhere('suhu','LIKE','%'.request('search').'%')
->orWhere('hasil_pemeriksaan','LIKE','%'.request('search').'%')
->orWhere('anamnesa','LIKE','%'.request('search').'%')
->orWhere('pengobatan','LIKE','%'.request('search').'%')
->orWhere('kasus','LIKE','%'.request('search').'%')
->orWhere('dokters.nama_dokter','LIKE','%'.request('search').'%')
->orWhere('pasiens.nama','LIKE','%'.request('search').'%')
->orWhere('penyakits.nama_penyakit','LIKE','%'.request('search').'%')
->orWhere('treatments.nama_treatment','LIKE','%'.request('search').'%');
}
this is my sql
select * from `rekans` inner join `dokters` on `dokters`.`id` = `rekans`.`dokter_id` inner join `pasiens` on `pasiens`.`id` = `rekans`.`pasien_id` inner join `penyakits` on `penyakits`.`id` = `rekans`.`dokter_id` inner join `treatments` on `treatments`.`id` = `rekans`.`treatment_id` where date(`rekans`.`created_at`) >= ? and date(`rekans`.`created_at`) <= ? and `berat` LIKE ? or `rekan_inv` LIKE ? or `suhu` LIKE ? or `hasil_pemeriksaan` LIKE ? or `anamnesa` LIKE ? or `pengobatan` LIKE ? or `kasus` LIKE ? or `dokters`.`nama_dokter` LIKE ? or `pasiens`.`nama` LIKE ? or `penyakits`.`nama_penyakit` LIKE ? or `treatments`.`nama_treatment` LIKE ? order by `rekans`.`created_at` desc
I have PHP code at the top of my document and I want to surround it with HTML comment tags so that it is commented out in the source code in my dev environment.
<!--
<?php
session_start();
lib->checkSession();
?>
-->
<html>
my website
</html>
Normally, HTML comment tags shouldn’t prevent the php from executing but somehow it does. Is that configurable?
I am trying to fetch data from the database and getting the error as:
Warning: Attempt to read property “username” on null in C:UsershpDesktopxampphtdocs19Aprilmain.php on line 33
Please suggest/guide me through the solution
My main.php file
<!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>Document</title>
</head>
<body>
<h3>Search Meetings</h3>
<form action="" method="POST">
<!-- <label>Enter Your Name:</label><br /> -->
<input type="text" name="username" placeholder="Your Name" required/>
<br /><br />
<button type="submit" name="submit">Search</button>
</form>
</body>
</html>
<?php
if(isset($_POST['username']) && $_POST['username']!=""){
$username = $_POST['username'];
$url = "http://localhost/19April/api/".$username;
$client = curl_init($url);
curl_setopt($client,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($client);
$result = json_decode($response);
// echo "<table>";
echo "<tr><td>User Name:</td><td>$result->username</td></tr>";
// echo $result->$username;
// echo "<tr><td>Age:</td><td>$result->age</td></tr>";
// echo "<tr><td>Email-Id:</td><td>$result->email</td></tr>";
// echo "</table>";
}
?>
My api.php file
<?php
header("Content-Type:application/json");
if (isset($_GET['username']) && $_GET['username']!="") {
include('db.php');
$username = $_GET['username'];
$result = mysqli_query($con,"SELECT * FROM `transactions` WHERE username=$username");
if(mysqli_num_rows($result)>0){
$row = mysqli_fetch_array($result);
$username = $row['username'];
$age = $row['age'];
$email = $row['email'];
response($username, $username, $age,$email);
mysqli_close($con);
}else{
response(NULL, NULL, 200,"No Record Found");
}
}else{
response(NULL, NULL, 400,"Invalid Request");
}
function response($username,$age,$email){
$response['username'] = $username;
$response['age'] = $age;
$response['email'] = $email;
$json_response = json_encode($response);
echo $json_response;
}
?>
I have a number of pages (400) which are all build individually in a visual editor (DIVI), even though they are identical other than the images on each page – This was my first website and so I knew no better than this approach when I began.
They are all child-pages of pageX and their slug begins with a common word. eg:
mysite.com/pageX/commonword-page1/
mysite.com/pageX/commonword-page2/
If I wanted to use a custom page template and insert unique images for each page, how would I go about doing this? Would adding an advanced custom field for each page containing an array of image ids/urls be a good option? Then simply call this and loop through each one and insert into the DOM?