PHP unlink() files after it is added to ZipArchive

I am adding multiple files to a ZipArchive each file has a unique name.

Controller:

$zip = new ZipArchive();
$zip->open($zipPath, ZipArchive::CREATE | ZipArchive::OVERWRITE);
$filesToClose = $this->advancedService->addFiles($files, $zip);
$zip->close();

foreach ($filesToClose as $file) {
    fclose($file);
    unlink(stream_get_meta_data($file)['uri']);
}
// return response

Service:

// addFiles function
foreach ($files as $file) {
    $fileName = 'FILE_'.$file->getId().'.'.$file->getExtension();

    $tempFile = tmpfile();
    $content = file_get_contents('uriFromSdk');
    fwrite($tempFile, $content);
    $zipArchive->addFile(stream_get_meta_data($tempFile)['uri'], $fileName);

    $filesToClose[] = $tempFile;
}

return $filesToClose;

In controller I get this error:

stream_get_meta_data(): supplied resource is not a valid stream resource

The main problem is I can not close or delete any file before $zip->close(), How can I unlink the files from the server ?

Keep in mind fclose() doesn’t throw this error, only the stream_get_meta_data().

Thanks.

Its showing me a syntax error, please guide [duplicate]

Error image

session_start();
if (!isset($_SESSION['unique_id'])) {
    header("location: login.php");
}
?>

<?php include_once "header.php"; ?>
<body>
    <div class="wrapper">
        <section class="chat-area">
            <header>
                <?php
                include_once "php/config.php";
                $user_id = mysqli_real_escape_string($conn, $_GET['user_id']);
                $sql = mysqli_query($conn, "SELECT * FROM users WHERE unique_id = {user_id}");
                if (mysqli_num_rows($sql) > 0) {
                    $row = mysqli_fetch_assoc($sql);
                }
                ?>
                <a href="users.php" class="back-icon"><i class="fas fa-arrow-left"></i></a>
                <img src="php/images/<?php echo $row['img'] ?>" alt="">
                <div class="details">
                    <span><?php echo $row['fname'] . " " . $row['lname'] ?></span>
                    <p><?php echo $row['status'] ?></p>
                </div>
            </header>
            <div class="chat-box">
                <div class="chat outgoing">
                    <div class="details">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                    </div>
                </div>
                <div class="chat incoming">
                    <img src="img2.png" alt="">
                    <div class="details">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                    </div>
                </div>
                <div class="chat outgoing">
                    <div class="details">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                    </div>
                </div>
                <div class="chat incoming">
                    <img src="img2.png" alt="">
                    <div class="details">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                    </div>
                </div>
                <div class="chat outgoing">
                    <div class="details">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                    </div>
                </div>
                <div class="chat incoming">
                    <img src="img2.png" alt="">
                    <div class="details">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                    </div>
                </div>
                <div class="chat outgoing">
                    <div class="details">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                    </div>
                </div>
                <div class="chat incoming">
                    <img src="img2.png" alt="">
                    <div class="details">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
                    </div>
                </div>
            </div>
            <form action="#" class="typing-area">
                <input type="text" placeholder="Type a Sandesh...">
                <button><i class="fab fa-telegram-plane"></i></button>
            </form>
        </section>
    </div>

</body>
</html>

I am making a real-time chat app using this video as reference-https://www.youtube.com/watch?v=VnvzxGWiK54. In the chat.php part I am getting an error in saying : Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘}’ at line 1 in C:xampphtdocsSandesha codingnepalchat.php:16 Stack trace: #0 C:xampphtdocsSandesha codingnepalchat.php(16): mysqli_query(Object(mysqli), ‘SELECT * FROM u…’) #1 {main} thrown in

Plez guide what to do.

Condition is evaluated as true even though it is false [duplicate]

I’ve set the header User-Allowed-Tracking to false with the ModHeader Extension and ran my code with x-debug:

const USER_ALLOWED_TRACKING = "HTTP_USER_ALLOWED_TRACKING";

...

public function userAllowedTracking()
{
    if (isset($_SERVER[self::USER_ALLOWED_TRACKING]) 
           && $_SERVER[self::USER_ALLOWED_TRACKING] == true) {
        return true;
    }
    return false;
}

Screenshot:

enter image description here

You can see that the header exist and is indeed set to “false”, so the condition should be false.

If I change it to this, then it works:

public function userAllowedTracking()
{
    if (isset($_SERVER[self::USER_ALLOWED_TRACKING]) 
           && $_SERVER[self::USER_ALLOWED_TRACKING] == "true") {
        return true;
    }
    return false;
}

But why is the condition true in the first code?

How to get Next record or previous record Laravel

I want to get the next participant if i press next button sort by category and sort by gymnast tag

here my code to get first users

$selectparticipant = Magmodel::where('IDEVENT', '=', $id)
              ->where('SESSION', '=', $selectsession)
              ->where('GROUP', '=', $selectgroup)
              ->orderBy('Category', 'ASC')
              ->orderBy('TAG', 'ASC')->first();

i want it get second record if i press next

here my code to get next participant

$selectparticipant = Magmodel::where('IDEVENT', '=', $ied)
              ->where('SESSION', '=', $selectsession)
              ->where('GROUP', '=', $selectgroup)
              ->where('gymnastmag.TAG', '>', $ps->TAG)
              ->orderBy('Category', 'ASC')
              ->orderBy('TAG', 'ASC')->first();

but it will not show the next record if it has different Category but smaller tag

here my database

enter image description here

i want it show Bon first when i press next show Johny,
when press next again show Ryan,
when press next again Show Lucas,
when press next again show Abraham,
when press next again show Lucky,
when press next again show Bernard,

can someone please help me with next and prev function

Using get_the_ID() in a Shortcode Causes JSON and PHP Errors in Guttenberg

Using a WordPress plugin suite called Toolslet, I’ve been building a content template to dynamically display Woocommerce order information.

I’ve written a shortcode that works perfectly outside of Guttenberg to display the order information for the current order in the loop:

/*** Shortcode to return any aspect of a Woocommerce order ***/
/* Accepts parameters 'id' and 'token':
/* 'id' = If ID is blank current loop item ID is used otherwise it needs to be a class ID
/* 'attribute' = The Woocommerce order array item wanted.  Defaults to order ID */

function get_order_info($atts) {

  //Set the default $atts values
  defaults = array(
    'id'        =>   get_the_ID(),
    'attribute'     =>   'id'
  );

  //Apply default atts if none have been set
  $atts = shortcode_atts( $defaults, $atts );

  //Get the WC_Order object for the current order in the loop
  $order = wc_get_order( $atts['id'] );

  //Get the order data
  $order_data = $order->get_data();

  //Return whichever order data item is requested
  return $order_data[$atts['attribute']];

}
add_shortcode("order_info", "get_order_info");

But trying to use this in a content template (a post that is reused to display information for any post in a custom post type) causes Guttenberg to display:

Updating failed. The response is not a valid JSON response.

And PHP throws this error:

Call to a member function get_data on bool

Both of these errors are the result of this line of code:

$order_data = $order->get_data();

As I understand it, the PHP error is saying that get_data() is returning a boolean, ie FALSE, which means that it’s not getting the order ID correctly. However is saving and getting the order ID because working on the front end and trying to dump and of the following displays the correct ID:

$defaults['id'];
$atts['id'];
get_the_ID();

I’ve seen similar questions on here, but they all focus on the ID not being present when it clearly is here.

Cake PHP 2 beforeSave callback not modifying request

I need to modify the $this->request->data before it’s saved via my model’s saveAssociated method, but it’s not modifying the data to save, I can verify this because if I do it directly in the controller it works.

My model ApplicationVersionFive attempt:

<?php
App::uses('HttpSocket', 'Network/Http', 'HttpResponse');

class ApplicationVersionFive extends AppModel
{
    public $name = 'ApplicationVersionFive';

    public $hasMany = array('RedirectVersionFive','ApplicationPromotionVersionFive', 'ApplicationApiLinkVersionFive');

    public $hasOne = array('ApplicationResponseVersionFive','ApplicationPaydayVersionFive','ApplicationInstallmentVersionFive','ApplicationSecuredVersionFive','ApplicationDebtmgmtVersionFive','ApplicationReclaimVersionFive', 'ApplicationPaydayIcicleHashVersionFive');

        /*
        ** Perform something before a model saves
        ** https://book.cakephp.org/2/en/models/callback-methods.html#beforesave
        */
        public function beforeSave($options = array()) {
                $this->data['ApplicationVersionFive']['ApplicationVersionFive'] = $this->data['ApplicationVersionFive']['Application']
                
                // continue with save attempt
                return true;
        }
}

In my controller I’ve tried both methods:


// NOT WORKING: this should pass data to `beforeSave` and then map it
$resultVersionFiveModel = $this->ApplicationVersionFive->saveAssociated($this->request->data);

// WORKING: if I manually build it up here then it saves
$test = [
    'ApplicationVersionFive' => $this->request->data['Application']
];
$resultVersionFiveModel = $this->ApplicationVersionFive->saveAssociated($test);

How can I get my beforeSave to map my data so I can simply pass $this->request->data to it?

How can I cofigurate TCA for a table of contents “type=’inline'” and add a new table in database in TYPO3?

I create a new extension with “Sitepackage Builder” and I want to add a content element. I could display a wizard and some fields in Backend. Show this: enter image description here

I added an inline, but if I click the button “Create new”, then an error Error undifined comes up like this: enter image description here

At first, I created a new table tx_carousel_klassenfahrt_item and added an attribute tx_carousel_klassenfahrt_item in the table tt_content in ext_tables.sql:

CREATE TABLE tt_content (
    tx_carousel_klassenfahrt_item int(11) unsigned DEFAULT '0',
);

CREATE TABLE tx_carousel_klassenfahrt_item (
    uid int(11) unsigned NOT NULL auto_increment,
    pid int(11) DEFAULT '0' NOT NULL,

    tt_content int(11) unsigned DEFAULT '0',
    item_type varchar(255) DEFAULT '' NOT NULL,
    layout varchar(255) DEFAULT '' NOT NULL,
    header varchar(255) DEFAULT '' NOT NULL,
    header_layout tinyint(3) unsigned DEFAULT '1' NOT NULL,
    header_position varchar(255) DEFAULT 'center' NOT NULL,
    header_class varchar(255) DEFAULT '' NOT NULL,
    subheader varchar(255) DEFAULT '' NOT NULL,
    subheader_layout tinyint(3) unsigned DEFAULT '2' NOT NULL,
    subheader_class varchar(255) DEFAULT '' NOT NULL,
    nav_title varchar(255) DEFAULT '' NOT NULL,
    button_text varchar(255) DEFAULT '' NOT NULL,
    bodytext text,
    tx_preis varchar(255) DEFAULT '' NOT NULL,
    image int(11) unsigned DEFAULT '0',
    link varchar(1024) DEFAULT '' NOT NULL,
    text_color varchar(255) DEFAULT '' NOT NULL,
    background_color varchar(255) DEFAULT '' NOT NULL,
    background_image int(11) unsigned DEFAULT '0',
    background_image_options mediumtext,

    tstamp int(11) unsigned DEFAULT '0' NOT NULL,
    crdate int(11) unsigned DEFAULT '0' NOT NULL,
    cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
    deleted smallint unsigned DEFAULT '0' NOT NULL,
    hidden smallint unsigned DEFAULT '0' NOT NULL,
    starttime int(11) unsigned DEFAULT '0' NOT NULL,
    endtime int(11) unsigned DEFAULT '0' NOT NULL,
    sorting int(11) DEFAULT '0' NOT NULL,

    sys_language_uid int(11) DEFAULT '0' NOT NULL,
    l10n_parent int(11) unsigned DEFAULT '0' NOT NULL,
    l10n_diffsource mediumblob NULL,

    t3ver_oid int(11) unsigned DEFAULT '0' NOT NULL,
    t3ver_id int(11) unsigned DEFAULT '0' NOT NULL,
    t3ver_wsid int(11) unsigned DEFAULT '0' NOT NULL,
    t3ver_label varchar(255) DEFAULT '' NOT NULL,
    t3ver_state smallint DEFAULT '0' NOT NULL,
    t3ver_stage int(11) DEFAULT '0' NOT NULL,
    t3ver_count int(11) unsigned DEFAULT '0' NOT NULL,
    t3ver_tstamp int(11) unsigned DEFAULT '0' NOT NULL,
    t3ver_move_id int(11) unsigned DEFAULT '0' NOT NULL,
    t3_origuid int(11) unsigned DEFAULT '0' NOT NULL,

    PRIMARY KEY (uid),
    KEY parent (pid),
    KEY t3ver_oid (t3ver_oid,t3ver_wsid),
    KEY language (l10n_parent,sys_language_uid)
);

My PHP-files in TCA are these:

in /Configuration/TCA/Overrides/tx_carousel_klassenfahrt_content_element.php

<?php
defined('TYPO3') or die('Access denied.');

// Add Content Element
if (!is_array($GLOBALS['TCA']['tt_content']['types']['carousel_klassenfahrt'] ?? false)) {
    $GLOBALS['TCA']['tt_content']['types']['carousel_klassenfahrt'] = [];
}

// Add content element PageTSConfig
TYPO3CMSCoreUtilityExtensionManagementUtility::registerPageTSConfigFile(
    'rasanidesign_klassenfahrt',
    'Configuration/TsConfig/Page/ContentElement/Element/CarouselKlassenfahrt.tsconfig',
    'Content Element: Carousel Klassenfahrt'
);

// Add content element to selector list
TYPO3CMSCoreUtilityExtensionManagementUtility::addTcaSelectItem(
    'tt_content',
    'CType',
    [
        'Carousel Klassenfahrt',
        'carousel_klassenfahrt',
        'content-bootstrappackage-carousel',
        'rasanidesign_klassenfahrt'
    ],
    'carousel',
    'after'
);

// Assign Icon
$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes']['carousel_klassenfahrt'] = 'content-bootstrappackage-carousel';

// Configure element type
$GLOBALS['TCA']['tt_content']['types']['carousel_klassenfahrt'] = array_replace_recursive(
    $GLOBALS['TCA']['tt_content']['types']['carousel_klassenfahrt'],
    [
        'showitem' => '
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.headers;headers,
                tx_carousel_klassenfahrt_item,
            --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel.options,
                pi_flexform;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:advanced,
            --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.appearanceLinks;appearanceLinks,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
                --palette--;;language,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
                --palette--;;hidden,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
                categories,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
                rowDescription,
            --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
        '
    ]
);

// Register fields: front side header
$GLOBALS['TCA']['tt_content']['columns'] = array_replace_recursive(
    $GLOBALS['TCA']['tt_content']['columns'],
    [
        'tx_carousel_klassenfahrt_item' => [
            'exclude' => 1,
            'label' => 'Create item',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_carousel_klassenfahrt_item',
                'foreign_field' => 'pid',
                'foreign_table_field' => 'tt_content',
                'appearance' => [
                    'collapseAll' => 1,
                    'expandSingle' => 1,
                ],
            ],
        ]
    ]
);

in /Configuration/TCA/tx_carousel_klassenfahrt_item.php

<?php

if (TYPO3CMSCoreUtilityExtensionManagementUtility::isLoaded('lang')) {
    $generalLanguageFile = 'EXT:lang/Resources/Private/Language/locallang_general.xlf';
} else {
    $generalLanguageFile = 'EXT:core/Resources/Private/Language/locallang_general.xlf';
}

return [
    'ctrl' => [
        'label' => 'header',
        'sortby' => 'sorting',
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'cruser_id' => 'cruser_id',
        'title' => 'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item',
        'type' => 'item_type',
        'delete' => 'deleted',
        'versioningWS' => true,
        'origUid' => 't3_origuid',
        'hideTable' => true,
        'hideAtCopy' => true,
        'prependAtCopy' => 'LLL:' . $generalLanguageFile . ':LGL.prependAtCopy',
        'transOrigPointerField' => 'l10n_parent',
        'transOrigDiffSourceField' => 'l10n_diffsource',
        'languageField' => 'sys_language_uid',
        'enablecolumns' => [
            'disabled' => 'hidden',
            'starttime' => 'starttime',
            'endtime' => 'endtime',
        ],
        'typeicon_column' => 'item_type',
        'typeicon_classes' => [
            'default' => 'content-bootstrappackage-carousel-item',
            'header' => 'content-bootstrappackage-carousel-item-header',
            'call_to_action' => 'content-bootstrappackage-carousel-item-calltoaction',
            'image' => 'content-bootstrappackage-carousel-item-image',
            'text' => 'content-bootstrappackage-carousel-item-text',
            'text_and_image' => 'content-bootstrappackage-carousel-item-textandimage',
            'text_and_image_carousel_klassenfahrt' => 'content-bootstrappackage-carousel-item-textandimage',
            'background_image' => 'content-bootstrappackage-carousel-item-backgroundimage',
            'html' => 'content-bootstrappackage-carousel-item-html'
        ]
    ],
    'interface' => [
        'showRecordFieldList' => '
            hidden,
            tt_content,
            header,
            header_layout,
            header_class,
            subheader,
            subheader_layout,
            subheader_class
            bodytext,
            image,
            text_color,
            background_color,
            background_image,
            carousel_klassenfahrt_relation
        ',
    ],
    'types' => [
        '1' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                header;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:header.ALT.html_formlabel,
                nav_title,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            '
        ],
        'header' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                --palette--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.header;header,
                nav_title,
                text_color,
                link,
                --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:tabs.background,
                background_color,
                background_image,
                background_image_options,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            '
        ],
        'text' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                --palette--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.header;header,
                nav_title,
                bodytext,
                text_color,
                --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:tabs.background,
                background_color,
                background_image,
                background_image_options,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            '
        ],
        'call_to_action' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                --palette--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.header;header,
                nav_title,
                bodytext,
                button_text,
                link,
                --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:tabs.background,
                background_color,
                background_image,
                background_image_options,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            '
        ],
        'image' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                header;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:header.ALT.html_formlabel,
                nav_title,
                image,
                link,
                --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:tabs.background,
                background_color,
                background_image,
                background_image_options,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            '
        ],
        'text_and_image' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                --palette--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.header;header,
                nav_title,
                bodytext,
                text_color,
                image,
                link,
                --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:tabs.background,
                background_color,
                background_image,
                background_image_options,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            '
        ],
        'text_and_image_carousel_klassenfahrt' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                --palette--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.header;header,
                nav_title,
                bodytext,
                tx_preis,
                text_color,
                image,
                link,
                --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:tabs.background,
                background_color,
                background_image,
                background_image_options,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            '
        ],
        'background_image' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                header;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:header.ALT.html_formlabel,
                nav_title,
                background_color,
                background_image,
                background_image_options,
                link,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            '
        ],
        'html' => [
            'showitem' => '
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,
                header;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:header.ALT.html_formlabel,
                nav_title,
                bodytext;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:bodytext.ALT.html_formlabel,
                --div--;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:tabs.background,
                background_color,
                background_image,
                background_image_options,
                --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.visibility;visibility,
                --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,
                --palette--;;hiddenLanguagePalette,
            ',
            'columnsOverrides' => [
                'bodytext' => [
                    'config' => [
                        'enableRichtext' => false
                    ]
                ]
            ]
        ],
    ],
    'palettes' => [
        '1' => [
            'showitem' => ''
        ],
        'access' => [
            'showitem' => '
                starttime;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:starttime_formlabel,
                endtime;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:endtime_formlabel
            '
        ],
        'header' => [
            'showitem' => '
                header,
                header_layout,
                header_class,
                --linebreak--,
                subheader,
                subheader_layout,
                subheader_class,
                --linebreak--,
                header_position,
            '
        ],
        'general' => [
            'showitem' => '
                tt_content,
                item_type;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType_formlabel,
                --linebreak--,
                layout,
            '
        ],
        'visibility' => [
            'showitem' => '
                hidden;LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item
            '
        ],
        // hidden but needs to be included all the time, so sys_language_uid is set correctly
        'hiddenLanguagePalette' => [
            'showitem' => 'sys_language_uid, l10n_parent',
            'isHiddenPalette' => true,
        ],
    ],
    'columns' => [
        'tt_content' => [
            'exclude' => true,
            'label' => 'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.tt_content',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'foreign_table' => 'tt_content',
                'foreign_table_where' => 'AND tt_content.pid=###CURRENT_PID### AND tt_content.{#CType} IN ('carousel','carousel_small','carousel_fullscreen')',
                'maxitems' => 1,
                'default' => 0,
            ],
        ],
        'item_type' => [
            'label' => 'LLL:' . $generalLanguageFile . ':LGL.type',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'items' => [
                    [
                        'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.item_type.header',
                        'header',
                        'content-bootstrappackage-carousel-item-header'
                    ],
                    [
                        'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.item_type.text',
                        'text',
                        'content-bootstrappackage-carousel-item-text'
                    ],
                    [
                        'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.item_type.calltoaction',
                        'call_to_action',
                        'content-bootstrappackage-carousel-item-calltoaction'
                    ],
                    [
                        'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.item_type.image',
                        'image',
                        'content-bootstrappackage-carousel-item-image'
                    ],
                    [
                        'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.item_type.textandimage',
                        'text_and_image',
                        'content-bootstrappackage-carousel-item-textandimage'
                    ],
                    [
                        'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.item_type.textandimage',
                        'text_and_image',
                        'content-bootstrappackage-carousel-item-textandimagecarouselklassenfahrt'
                    ],
                    [
                        'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.item_type.backgroundimage',
                        'background_image',
                        'content-bootstrappackage-carousel-item-backgroundimage'
                    ],
                    [
                        'LLL:EXT:bootstrap_package/Resources/Private/Language/Backend.xlf:carousel_item.item_type.html',
                        'html',
                        'content-bootstrappackage-carousel-item-html'
                    ],
                ],
                'default' => 'header',
                'authMode' => $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'],
                'authMode_enforce' => 'strict'
            ],
            'l10n_mode' => 'exclude',
        ],
        'hidden' => [
            'exclude' => true,
            'label' => 'LLL:' . $generalLanguageFile . ':LGL.hidden',
            'config' => [
                'type' => 'check',
                'items' => [
                    '1' => [
                        '0' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:hidden.I.0'
                    ]
                ]
            ]
        ],
        'starttime' => [
            'exclude' => true,
            'label' => 'LLL:' . $generalLanguageFile . ':LGL.starttime',
            'config' => [
                'type' => 'input',
                'renderType' => 'inputDateTime',
                'eval' => 'datetime',
                'default' => 0
            ],
            'l10n_mode' => 'exclude',
            'l10n_display' => 'defaultAsReadonly'
        ],
        'endtime' => [
            'exclude' => true,
            'label' => 'LLL:' . $generalLanguageFile . ':LGL.endtime',
            'config' => [
                'type' => 'input',
                'renderType' => 'inputDateTime',
                'eval' => 'datetime',
                'default' => 0,
                'range' => [
                    'upper' => mktime(0, 0, 0, 1, 1, 2038)
                ]
            ],
            'l10n_mode' => 'exclude',
            'l10n_display' => 'defaultAsReadonly'
        ],
        'sys_language_uid' => [
            'exclude' => 1,
            'label' => 'LLL:' . $generalLanguageFile . ':LGL.language',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'foreign_table' => 'sys_language',
                'foreign_table_where' => 'ORDER BY sys_language.title',
                'items' => [
                    [
                        'LLL:' . $generalLanguageFile . ':LGL.allLanguages',
                        -1
                    ],
                    [
                        'LLL:' . $generalLanguageFile . ':LGL.default_value',
                        0
                    ]
                ],
                'allowNonIdValues' => true,
            ]
        ],
        'l10n_parent' => [
            'displayCond' => 'FIELD:sys_language_uid:>:0',
            'exclude' => 1,
            'label' => 'LLL:' . $generalLanguageFile . ':LGL.l18n_parent',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'items' => [
                    [
                        '',
                        0
                    ]
                ],
                'foreign_table' => 'tx_carousel_klassenfahrt_content',
                'foreign_table_where' => 'AND tx_carousel_klassenfahrt_content.pid=###CURRENT_PID### AND tx_bootstrappackage_carousel_item.sys_language_uid IN (-1,0)',
                'default' => 0
            ]
        ],
...

I think the relation between the table “tt_content” and “tx_carousel_klassenfahrt_item” doesn’t work and my code in TCA are also incorrect…

Could anyone help me with this? I want to show up my fileds and save data in my database (in the table tx_carousel_klassenfahrt_item”.

This is my imagine of the backend after setting: enter image description here

Thank you in advance.

How to keep values inside input fields after generating table while using php post method?

I’m trying to figure out how to keep values of input elements inside the boxes after php generates table. Code is listed below.

 <form action="zadatak_12-4.php" method="post">
        <label for="nA">Prvi broj: </label>
        <input type="number" id="nA" name="nA">
        <label for="nB">Drugi broj: </label>
        <input type="number" id="nB" name="nB">
        <button type="submit" >Generiraj</button>
    </form><br>

Php

<?php
    $nA =-1;
    $nB =-1;
    if(isset($_POST['nA'])) $nA = $_POST['nA'];
    if(isset($_POST['nB'])) $nB = $_POST['nB'];
    
    if(!is_numeric($nA)) $nA = -1;
    if(!is_numeric($nB)) $nB = -1;

    if(($nA != -1)&&($nB !=-1))
    {
        $odBroj = $nA; $doBroj = $nB;
        if($nB > $nA) { $odBroj = $nB; $doBroj = $nA;}
            $pom  ="<table class='tablica'>";
            $pom .="<tr><th>Broj</th><th>Kvadrat</th><th>Alert poruka</th></tr>";
            
            for ($i = $odBroj; $i >= $doBroj; $i--)
            {
            $pom .= "<tr><td>".$i."</td><td>".($i*$i)."</td><td><span class='glumiLink'>Poruka</span></td></tr>";
            }
            $pom .="</table>";
        } else {
            $pom  ="<p>Pogrešno uneseni ili nedefinirani parametri!</p>";
        }
    ?>

Call a function with multiple default value in PHP

How to call a function with multiple default value in PHP ?

I have a function like below

public function get( $action = 'find', $query = 'top' ) {
      //more code
}

What will happen if I call above function like below (with one value) ?

get('map') {
      //more code
}

Tamil Unicode not rendering DOMPDF

I download Bamini font and try to download pdf. I got ??????????????? for tamil words.

$html='<!DOCTYPE html><html>
<style>
@font-face {
    font-family: "Baamini";           
    src: url("baamini.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
} 
 body{
    font-family: "Baamini";            
}
</style>';
$html.='<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>';
$html.='<body><table style="border:1px solid;" width="100%"><tr><td colspan="2" align="center" style="border-bottom:1px solid;">';
$html.='<h3 style="font-family: Baamini;">சமூக நல அமைப்பு  <h3>';
$html.='<h5>தொடர்பு எண் : ##########</h5></td></tr></table></body></html>';
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream();

create crud as wordpress in core php with mysqli

im trying to create page as wordpress where when user click on add new page, blank form in show with publish button and when user fill data and click on publish button, form in page remains with fill data create by user but button publish button is change to update button same as in wordpress now when i change form field data and click on update button, page get refresh and blank form is displayed but form data are updated in database successfully and update are not show in form instead, blank form is shown…. how can i keep data in form after clicking update button…

im trying acheieve as wordpress create page:
wordpress pages style

code for inserting value in databas and defining varibale $last_id for
storing last ID generate for updating value

global $last_id;

if(isset($_POST['create_page'])){
    $post_title = $_POST['title'];
    $post_parent = $_POST['parent_page'];
    $post_author = $_POST['author'];
    $post_status = $_POST['status'];
    $post_date = date('d-m-y');
    $post_image = $_FILES['page_image']['name'];
    $post_image_tmp = $_FILES['page_image']['tmp_name'];
    $post_tags = $_POST['page_tags'];
    $post_content = $_POST['page_content'];

    move_uploaded_file($post_image_tmp, "../images/$post_image" );

    $post_parent = $_POST['parent_page'];

    
        $query = "INSERT INTO pages(`parent_id`, `page_title`, `author`, `post_date`, `page_image`, `page_content`, `page_tags`, `post_status`) VALUES ('{$post_parent}','{$post_title}','{$post_author}','now()','{$post_image}','{$post_content}','{$post_tags}','{$post_status}')";

        //$create_page = mysqli_query($connection,$query);
        
        //storing last id generated in variale $last_id
        if (mysqli_query($connection,$query)) {
            $last_id = mysqli_insert_id($connection);
        }

}

Now we got last enter id with $last_id, with the help $last id check for empty ID, if ID is empty then generate Empty form else get from with ID reference value in Form

so,if Id is empty generating empty Form

if(empty($last_id)){
?>
<div class="form-group">
    <label for="">page title</label>
    <input type="text" class="form-control" name="title" >
</div>
<div class="form-group">
    <label for="">parent page</label>
    <select name="parent_page" id="">
        <option value="">no parent</option>
        <?php 
            $query = "SELECT * FROM parent_page";
            $parent_page = mysqli_query($connection,$query);
            while($rows = mysqli_fetch_assoc($parent_page) ){
                $page_id = $rows['page_id'];
                $page_title = $rows['page_title'];
        ?>
        <option value="<?php echo $page_id; ?>"><?php echo $page_title; ?></option>
        <?php }?>
    </select>
</div>
<div class="form-group">
    <label for="">author</label>
    <input type="text" class="form-control" name="author" >
</div>

<div class="form-group">
    <label for="">page status</label>
    <input type="text" class="form-control" name="status" >
</div>
<div class="form-group">
    <label for="">page image</label>
    <input type="file" class="form-control" name="page_image">
</div>
<div class="form-group">
    <label for="">page tags</label>
    <input type="text" class="form-control" name="page_tags" >
</div>
<div class="form-group">
    <label for="">page content</label>
    <textarea name="page_content" class="form-control" cols="30" rows="10"> </textarea>
</div>


   <div class="form-group">
    <input type="submit" class="btn btn-primary" name="create_page" value="publish">
</div>

But If $last_id is not empty then get value in form with id reference

<?php
}else{
//echo $id2 = $last_id;
    
    
$data['page_title'] = $data['page_title'] = $data['post_status'] = $data['page_tags'] =  $data['page_content'] = '';

$sql = "select * from pages where child_id='".$id2."'";
$result = mysqli_query($connection,$sql);
 if(!$result){
                die('QUERY Failed' . mysqli_error($connection));
            }

if ($result->num_rows > 0){   
while($data=mysqli_fetch_assoc($result))  {

?>

<form action="" method="post" enctype="multipart/form-data">
    <?php echo "<h1> im main id $last_id</h1>"; ?>
    <div class="form-group">
        <label for="">page id 12</label>
        <input type="text" class="form-control" name="id" value="<?php echo $last_id;?>">
    </div>
    <div class="form-group">
        <label for="">page title 12</label>
        <input type="text" class="form-control" name="title" value="<?php echo $data['page_title'];?>">
    </div>
    <div class="form-group">
        <label for="">parent page 12</label>
        <select name="parent_page" id="">
            <option value="">no parent</option>
            <?php 
                $query = "SELECT * FROM parent_page";
                $parent_page = mysqli_query($connection,$query);
                while($rows = mysqli_fetch_assoc($parent_page) ){
                    $page_id = $rows['page_id'];
                    $page_title = $rows['page_title'];
            ?>
            <option value="<?php echo $page_id; ?>"><?php echo $page_title; ?></option>
            <?php }?>
        </select>
    </div>
    <div class="form-group">
        <label for="">author 12</label>
        <input type="text" class="form-control" name="author" value="<?php echo $data['author'];?>">
    </div>
    <div class="form-group">
        <label for="">page status 12</label>
        <input type="text" class="form-control" name="status" value="<?php echo $data['post_status'];?>">
    </div>
    <div class="form-group">
        <label for="">page tags 12</label>
        <input type="text" class="form-control" name="page_tags" value="<?php echo $data['page_tags'];?>">
    </div>
    <div class="form-group">
        <label for="">page content 12</label>
        <textarea name="page_content" class="form-control" cols="30" rows="10"> <?php echo $data['page_content'];?></textarea>
    </div>
    <div class="form-group">
        <input type="submit" class="btn btn-primary" name="update" value="update">
    </div>
</form>
<?php 
} } }

Now we have got form with field value right after publishing pages and changing Publish button to Update button which will help us to update our query

Now again with help of $last_id will we be updating our form data:

if(isset($_POST['update'])){
$post_id = $_POST['id'];
$post_title = $_POST['title'];
$post_parent = $_POST['parent_page'];
$post_author = $_POST['author'];
$post_status = $_POST['status'];
$post_date = date('d-m-y');

$post_tags = $_POST['page_tags'];
$post_content = $_POST['page_content'];


$post_parent = $_POST['parent_page'];

$query = "UPDATE pages SET page_title = '{$post_title}', author = '{$post_author}', page_content = '{$post_content}', page_tags = '{$post_tags}', post_status = '{$post_status}' WHERE child_id = '{$post_id}' ";

$create_page = mysqli_query($connection,$query);

 if(!$create_page){
    die('QUERY Failed' . mysqli_error($connection));
}
}

now when click on update button update query is run successfully but after page get refresh i get blank form instead of update data in form but data is succesully update in database but im unable to display update data back in form like in wordpress.

My Goal is to creat new page same as wordpress and displaying data on same form as well as updating data on same form and displaying back updated data back in same form without page refresh

using acf_form in front, how to display the product fields and metadata of woocommerce products?

I am creating a form in front-end by ACF to submit products by user as a vendor and save the submitted form as a new product.

this is the code I am using it:

$options = array(
'post_id' => 'new_post',
'post_title' => true,
'post_content' => true,
'new_post'      => array(
  'post_type'       => 'product',
  'post_status'     => 'draft'
 ),
'field_groups' => [$my_field_group_id_created_in_acf],
'form' => true,
 'return' => '%post_url%',
'html_submit_button'    => '<input type="submit" value="%s" />',
'updated_message' => 'Product Created',
'submit_value' => 'Submit Product'

);

acf_form($options);

The output form has title field, content editor, and ACF group fields, but the price field, or other meta data of product(such as regulare price, category, tags and etc) not appears in the form!
How can I display other own product fields or other custom metadata (not related by ACF) in the form for submitting?

how to get last query in codeigniter 4?

This is my current code:

public function index()
{
    $db = ConfigDatabase::connect();
    $builder = $db->table($tbl);
    
    $data = [];

    $cols = "{$tbl}.*";
    $builder->select($cols);

    $data = $builder->get()->getResult();
    $asd = [
        'message' => $builder->getLastQuery(),
        'data' => $data,
    ];
    return $this->respond($asd);
}

but it returns error

"message": "Call to undefined method CodeIgniter\Database\MySQLi\Builder::getLastQuery()",

if I changed $builder->getLastQuery() into $builder->db->getLastQuery() it returns this error instead

"message": "Cannot access protected property CodeIgniter\Database\MySQLi\Builder::$db",