For example
I m losing uuid,conversions_disk, and generated_conversions columns when importing the old media table.
Category: PHP
Category Added in a WPeMatico Campaign
PHP + SQL Dropdown locale issues [duplicate]
I am creating a PHP form, which collects items for a dropdown list from WordPress MySQL database. The database locale is set to utf8mb4_unicode_520_ci and I tried to force this in the code, however, my dropdown list still does not display any Cyrillic characters.
<div>
<label for="course_name">Course Name:</label>
<select id="course_name" name="course_name" required>
<?php
// Connect to the MySQL database
mysqli_set_charset($conn, "utf8mb4_unicode_520_ci");
mysqli_query($conn, "SET collation_connection = 'utf8mb4_unicode_520_ci'");
$conn = mysqli_connect("host", "user", "password", "database");
// Query to select all course names
$query = "SELECT post_title FROM wpv1_posts WHERE post_type = 'courses'";
$result = mysqli_query($conn, $query);
// Loop through the result set and create options for the dropdown list
while ($row = mysqli_fetch_assoc($result)) {
echo "<option value='".$row['post_title']."'>".$row['post_title']."</option>";
}
mysqli_close($conn);
?>
</select>
</div>
The result in the dropdown at the moment is basically:
| Dropdown options |
|---|
| ?????? 12345678 |
| ?????? ???? ????? Text |
| Any English Text |
I tried forcing the locale through mysqli_set_charset($conn, "utf8mb4_unicode_520_ci"); and mysqli_query($conn, "SET collation_connection = 'utf8mb4_unicode_520_ci'");, as well as doing the same with cp1251_general_cs. This yielded no results.
How to Create Pagination and Filters product by category_id With PHP?
I have a problem on pagination, first I have php function called (get_product) that get the data from two different table (categories and product). second I have categories.php page that show only products with the same categories_id. so my question is I want to use pagination on categories.php page to show only for example one product pre page and the rest of product in other pages.
this is my function:
function get_product($con,$limit='',$cat_id='',$product_id='',$search_str='',$sort_order=''){
$sql="select product.*,categories.categories from product,categories where product.status=1 ";
if($cat_id!=''){
$sql.=" and product.categories_id=$cat_id ";
}
if($product_id!=''){
$sql.=" and product.id=$product_id ";
}
$sql.=" and product.categories_id=categories.id ";
if($search_str!=''){
$sql.=" and (product.name like '%$search_str%' or product.description like '%$search_str%') ";
}
if($sort_order!=''){
$sql.=$sort_order;
}else{
$sql.=" order by product.id desc ";
}
if($limit!=''){
$sql.=" limit $limit";
}
$res=mysqli_query($con,$sql);
$data=array();
while($row=mysqli_fetch_assoc($res)){
$data[]=$row;
}
return $data;
}
and this is my categories.php:
<?php
require('he.php');
if(!isset($_GET['id']) && $_GET['id']!=''){
?>
<script>
window.location.href='index.php';
</script>
<?php
}
$cat_id=mysqli_real_escape_string($con,$_GET['id']);
$price_high_selected="";
$price_low_selected="";
$new_selected="";
$old_selected="";
$sort_order="";
if(isset($_GET['sort'])){
$sort=mysqli_real_escape_string($con,$_GET['sort']);
if($sort=="price_high"){
$sort_order=" order by product.price desc ";
$price_high_selected="selected";
}if($sort=="price_low"){
$sort_order=" order by product.price asc ";
$price_low_selected="selected";
}if($sort=="new"){
$sort_order=" order by product.id desc ";
$new_selected="selected";
}if($sort=="old"){
$sort_order=" order by product.id asc ";
$old_selected="selected";
}
}
if($cat_id>0){
$get_product=get_product($con,'',$cat_id,'','',$sort_order);
}else{
?>
<script>
window.location.href='index.php';
</script>
<?php
}
if (!isset ($_GET['page']) ) {
$page = 1;
} else {
$page = $_GET['page'];
}
$results_per_page = 1;
$page_first_result = ($page-1) * $results_per_page;
$result = mysqli_query($con, "SELECT * FROM product WHERE categories_id='$cat_id'");
$number_of_result = mysqli_num_rows($result);
$number_of_page = ceil ($number_of_result / $results_per_page);
$result = mysqli_real_escape_string($con, "SELECT * FROM product WHERE categories_id=$cat_id LIMIT '$page_first_result' , '$results_per_page'");
?>
<!-- HEADING-BANNER START -->
<div class="heading-banner-area overlay-bg">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="heading-banner">
<div class="heading-banner-title">
<h2>Shop</h2>
</div>
<div class="breadcumbs pb-15">
<ul>
<li><a href="index.php">Home</a></li>
<li><?php echo $get_product['0']['categories']?></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- HEADING-BANNER END -->
<!-- PRODUCT-AREA START -->
<div class="product-area pt-80 pb-80 product-style-2">
<div class="container">
<!-- Shop-Content End -->
<div class="shop-content">
<div class="row">
<?php if(count($get_product)>0){?>
<div class="col-md-12">
<div class="product-option mb-30 clearfix">
<!-- Categories start -->
<div class="htc__product__rightidebar">
<div class="htc__grid__top">
<div class="htc__select__option">
<select style="background-color: #f7f6f8;border: 0 none; background-image: url(images/icons/select-option.png);background-position: right 7% center;background-size: contain;background-repeat: no-repeat;padding: 0 32px 0 15px;background-size: 14px;height: 35px;color: #000;" class="ht__select"
onchange="sort_product_drop('<?php echo $cat_id?>','<?php echo SITE_PATH?>')" id="sort_product_id">
<option value="">Default softing</option>
<option value="price_low" <?php echo $price_low_selected?>>Sort by price low to hight</option>
<option value="price_high" <?php echo $price_high_selected?>>Sort by price high to low</option>
<option value="new" <?php echo $new_selected?>>Sort by new first</option>
<option value="old" <?php echo $old_selected?>>Sort by old first</option>
</select>
</div>
</div>
<!-- Categories end -->
</div>
</div>
<div class="col-md-12">
<div class="row">
<!-- Single-product start -->
<?php
foreach($get_product as $list){
?>
<!-- Single-product start -->
<div class="single-product col-xl-3 col-lg-4 col-md-6">
<div class="product-img">
<a href="product.php?id=<?php echo $list['id']?>"><img style="display:block;max-width:270px;max-height:270px;width:auto;height:auto;" src="<?php echo PRODUCT_IMAGE_SITE_PATH.$list['image']?>" alt="product images" /></a>
<div class="product-action clearfix">
<a href="javascript:void(0)" onclick="wishlist_manage('<?php echo $list['id']?>','add')" data-bs-toggle="tooltip" data-placement="top" title="Wishlist"><i class="zmdi zmdi-favorite-outline"></i></a>
<a href="#" data-bs-toggle="modal" data-bs-target="#productModal" title="Quick View"><i class="zmdi zmdi-zoom-in"></i></a>
<a href="javascript:void(0)" onclick="manage_cart('<?php echo $get_product['0']['id']?>','add')" data-bs-toggle="tooltip" data-placement="top" title="Add To Cart"><i class="zmdi zmdi-shopping-cart-plus"></i></a>
</div>
</div>
<div class="product-info clearfix">
<div class="fix">
<h4 class="post-title floatleft"><a href="#"><?php echo $list['name']?></a></h4>
<p class="floatright hidden-sm"><?php echo $list['categories']?></p>
</div>
<div class="fix">
<span class="pro-price floatleft"><?php echo $list['price']?></span>
<span class="pro-rating floatright">
<div style="left: -60px;position: relative;" class="rateYuo" data-rating="<?= $list['averageRating']; ?>">
</div>
</span>
</div>
</div>
</div>
<?php } ?>
<!-- Single-product end -->
</div>
</div>
<div class="col-md-12">
<!-- Pagination start -->
<div class="shop-pagination text-center">
<div class="pagination">
<?php for($page = 1; $page<= $number_of_page; $page++) {
echo '<a href = "categories.php?id="$cat_id"=page=' . $page . '">' . $page . ' </a>';}?>
</div>
</div>
</div>
<!-- Pagination end -->
</div>
<?php } else {
echo "Data not found";
} ?>
</div>
</div>
<!-- Shop-Content End -->
</div>
</div>
<!-- PRODUCT-AREA END -->
the number of page is working it’s Calculates all the products and splits to number of pages. but the link is not recognize by cateory_id
as you can see:
<div class="shop-pagination text-center">
<div class="pagination">
<?php for($page = 1; $page<= $number_of_page; $page++) {
echo '<a href = "categories.php?id="$cat_id"=page=' . $page . '">' . $page . ' </a>';}?>
</div>
</div>
<!-- Pagination end -->
and the display of product not working its only show the all product with the same category id.
How to change Divi Portfolio module to a custom module with modifications
I try to add a custom link with ACF plugin… The modified php file with my ACF fields inside is finished but Im not able to override the original module.
`
function override_parent() {
remove_shortcode( ‘et_pb_fullwidth_portfolio’, ‘et_pb_fullwidth_portfolio’ );
add_shortcode( ‘et_pb_fullwidth_portfolio’, ‘et_pb_fullwidth_portfolio_custom’ );
}
add_action(‘after_setup_theme’,’override_parent’);
// Replacing the existing filterable portfolio with new customised version
function et_pb_fullwidth_portfolio_custom() {
get_template_part( 'custom-modules/FilterablePortfolio' );
$wph = new Custom_ET_Builder_Module_Filterable_Portfolio();
}
add_action( ‘wp’, ‘et_pb_fullwidth_portfolio_custom’, 99 );`
In my child theme i add a file with modified module.
Can anyone help?
what is the best tutorial framework in doing file transfer system? [closed]
I don’t know how to start my backend and frontend.
I already try the ABP framework, Can someone help me? what is framework should I use in creating file transfer system? thanks in advance
Laravel 9: Converting An Image From Bytes To Jpeg From Storage Directory
I’m using Laravel 9 and I wanted to show an image which is stored at storage/app/avatars.
So I tried this at the Blade:
{{ AppHttpHelperClassesImageHelper::admAvatar() }}
And this is the ImageHelper Class:
namespace AppHttpHelperClasses;
use IlluminateSupportFacadesResponse;
use IlluminateSupportFacadesStorage;
class ImageHelper
{
public static function admAvatar()
{
$content = Storage::get('avatars/profile.png');
return Response::make($content)->header('content-type','image/jpeg');
}
}
So I tried making an image from the profile.png and return it after all.
But the problem is it does not show anything!
And when I dd(Response::make($content)->header('content-type','image/jpeg')), I get this:
And the result of dd($content) also goes like this:
So how can I convert this properly into an image?
I have a problem displaying data in an html table from a mysql query using GROUP_CONCAT, only on the production site
Here is a part of the mysql query.
SELECT
GROUP_CONCAT(DISTINCT CONCAT('<a href="?rubriqueid=intranet&pageid=gestion§ionid=oeuvres&detail=ok&sourcerub=intranet&sourcepg=gestion¶m1=sectionid&vparam1=volumes_preparation&signet=ovr',O.PK_OEUVRE_OVR, '&id_oeuvre=', O.PK_OEUVRE_OVR,'">', O.TX_TITRE_LATIN_OVR, '</a>') ORDER BY O.TX_TITRE_LATIN_OVR SEPARATOR ', ') AS la_works_links,
GROUP_CONCAT(DISTINCT CONCAT('<a href="?rubriqueid=intranet&pageid=gestion§ionid=oeuvres&detail=ok&sourcerub=intranet&sourcepg=gestion¶m1=sectionid&vparam1=volumes_preparation&signet=ovr',O.PK_OEUVRE_OVR, '&id_oeuvre=', O.PK_OEUVRE_OVR,'">', O.`TX_TITRE_FRANCAIS_OVR`, '</a>') ORDER BY O.`TX_TITRE_FRANCAIS_OVR` SEPARATOR ', ') AS fr_works_links
FROM sc_t_oeuvre AS O
Here is a part of the php/html script to display the outputs.
<tbody>
<?php
while ($pmt = mysqli_fetch_assoc($oRecordset)) {
$works = $pmt['la_works_links'] ?: $pmt['fr_works_links'];
?>
<tr class="datagrid-lignesA text-center" style="line-height: 14px;">
<td style="overflow-wrap: break-word; white-space: pre-wrap; font-weight: bold; font-size:13px;"><?php echo $works; ?></td>
</tr>
<?php } ?>
</tbody>
Here is the display in the browser (chrome, firefox), only in production (stage and local are OK). After displaying four outputs (‘works’), we have the following tag:
<a class="datagrid-lignesA"
href="?rubriqueid=intranet&pageid=gestion§ionid=oeuvres&detail=ok&sourcerub=intranet&sourcepg=gestion¶m1=sectionid&vparam1=volumes_preparation&sig</td>
</tr>
<tr align="
center"="" style="line-height: 14px;">
</a>
Each time, the url is truncated in the middle and the td tag is closed.
Design a small application using Code Igniter MVC Framework with the following functionalities [closed]
Design a database with the following tables:
- User
- Front desk
- Patients
- Doctor
- Nurse
(You can give any columns as you like)
You would have to implement role management.
Design a small application using Code Igniter MVC Framework with the following functionalities. - User wise login (doctor login, nurse login and front desk login)
- Front desk can add patients.
- After adding patients, front desk will assign patient to nurse.
- After nurse is logged in, nurse will see the patient and will assign it to the doctor.
- After doctor is logged in, patient will be visible to the doctor.
I m stuck at the second query can anyone please help me?
destroy function in resource controller not working properly in LARAVEL 9
thanks in advance for taking the time to read through my question.
when ever I delete a user from my records the wrong user gets deleted
the deletion is happening in an incremented way no matter what the user id I’m choosing to delete
let’s say I’m deleting the user with the id 4
the one that actually gets deleted is the one with the id 1
if I try again to delete id 4 the user with the id of 2 gets deleted and so on.
my view is :
@extends('layouts.app')
@section('content')
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">{{ __('Admin panel') }}</h1>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- Main content -->
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<h5 class="card-title"></h5>
<p class="card-text">
@if (Session::has('successMsg'))
<div class="alert alert-success">
<h6 style=" text-align:center !important;"><b>Successfully Deleted! </b></h6>
</div>
@endif
<a class="btn btn-primary m-2" href="/addAppointment">Add new Appointment</a>
<a href="/appointments" class="btn btn-primary"> Appointments List</a>
<div class="container">
@if ($users->count())
<table class="table" id="table">
<thead>
<tr>
<th>Id</th>
<th>Email</th>
<th>View</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
@if ($user->id > 1)
<tr>
<td>{{ $user->id }}</td>
<td>{{ $user->email }}</td>
<td><a href="/cpanel/{{ $user->id }}"
class="btn">👁</a></td>
<td>
<form action="/cpanel/{{ $user->id }}" method="POST"
id="EditForm">
@method('DELETE')
@csrf
<button type="submit" class="btn" data-toggle="tooltip"
title='Delete' onclick="submitResult(event)"
aria-hidden="true">🗑</button>
</form>
</td>
</tr>
@endif
@endforeach
</tbody>
</table>
@endif
</div>
</p>
</div>
</div>
</div>
</div>
<!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content -->
@endsection
@section('scripts')
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="sweetalert2.all.min.js"></script>
<script type="text/javascript">
function submitResult(e) {
e.preventDefault();
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
Swal.fire(
'Deleted!',
'Your file has been deleted.',
'success'
)
document.getElementById("EditForm").submit();
}
})
}
</script>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script type="text/javascript" language="javascript"
src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
@endsection
@section('styles')
<link href='https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.min.css'>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css">
@endsection
my destroy function in the user controller is:
public function destroy($id)
{
if (!Auth::check()) {
return redirect('login');
} elseif (Gate::denies('cpanel')) {
abort(403, 'action not allowed!');
} else {
User::destroy($id);
return redirect('cpanel')->with('successMsg', 'User Deleted !');
}
}
my route is:
Route::resource('/cpanel', UserController::class)->middleware(['auth', 'verified']);
what Am I missing?
wordpress loading very slow after moving to production server
I have developed a WordPress website, and I have to host with some local service providers, after deploying the website over a secured VPN connection and trying to open it after deploying, the website is very slow, it takes from 3 – 4 minutes to load
we communicated with the service provider many times and they always confirm that the Network and Infrastructure do not have any problems, we checked also the code and it does not have a problem, it does not even show any errors in the console
I do not have any clue to follow
the behavior that happens is the following :
- type URL and press Enter
- Open the inspect to view Network Tab
- The Network does not show any loading links for about 2 Min and then starts loading for about 1 Min
I do not know why it takes so long time before start loading the URLs
Can anyone advise if you face such problems, please?
Amadeus FXR/R code implementation using php api
Amadeus FXR/R OR FXP/R is given by different Flights to get discount prices and baggage up-gradation using Amadeus software. How can we implement these codes in PHP API or get discount prices if apply?
I need Amadeus php API code implementation example
Error in Laravel “Call to undefined method AppModelsBlog::getContent()”
I’m getting an error when rendering a model Blogs
My errors:
Call to undefined method AppModelsBlog::getContent()
Can you suggest what is the cause of the error.
Model code given below
<?php
namespace AppModels;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;
use AppModelsCategories;
class Blog extends Model
{
public $table = "blogs";
protected $fillable = [
'id',
'category_id',
'title_ru',
'title_ua',
'slug',
'img',
'img_min',
'url',
'duration',
'annotation_ru',
'annotation_ua',
'description_ru',
'description_ua',
'meta_ru',
'meta_ua',
'keywords_ru',
'keywords_ua',
'views',
'type_record',
'schedule',
'published',
'created_at',
'updated_at'
];
public function category()
{
return $this->belongsTo(Categories::class);
}
public function scopePublished($query)
{
return $query->where('published', true);
}
}
This code helps to call the model Blog.
I can’t call my PHP MVC model classes to my site
The function I use to include my model files system/libs/load.php
public function model($fileName)
{
include "app/model/" . $fileName . "_model.php";
return new $fileName();
}
this is how i call my model file.
public function again()
{
$models = $this->load->model("index");
}
I get this error when I open the browser:
currently unable to process this request

How to color seperate parts of an SVG
I have a list of different colors and a SVG.
I’d like to pick a color and when i click on a specific part of the SVG, have only that part colored.
EXAMPLE:
colors: https://i.stack.imgur.com/77PTF.png,
original svg: https://i.stack.imgur.com/QMG4O.png,
colored svg: https://i.stack.imgur.com/XXFHr.png.
(1, 2, 3 are just to highlight the different parts to you, the coloring was done on Paint3D.)
(StackOverflow considers the links as code so i had to quote them, sorry for the inconvenience.)
I’m not sure how to go about it, i’ve found some PHP libraries such as imagick, imagickdraw and php-svg but none seem to do the trick.
Any help will be appreciated, doesn’t have to be in PHP, i’m open to any solution.
Thanks.
Facing Error – php artisan serve not working in Laravel
This is Ahmad Raza.
I am trying to view my website on localhost but when i run php artisan serve command I’m facing this error.
In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user ‘imperial_main’@’localhost’ (using password: NO) (SQL: selec
t * fromredirectionswherefrom= http://127.0.0.1/ limit 1)
In Exception.php line 18:
SQLSTATE[HY000] [1045] Access denied for user ‘imperial_main’@’localhost’ (using password: NO)
In PDOConnection.php line 40:
SQLSTATE[HY000] [1045] Access denied for user ‘imperial_main’@’localhost’ (using password: NO)
PS D:xampp7.1.3htdocsbackup-imperialride_ae>
My .env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY==
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=test
DB_PASSWORD=8mVNzfHR~*@s
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
My database
I want to view my website on localhost. plz, help me to figure out this problem and guide me on how can i solve this. I’ll be very thankful to you


