Search found 205 matches

by Michalio
Sun Aug 07, 2022 10:53 pm
Forum: PHP coding => General
Topic: PDO Error Check
Replies: 1
Views: 11

Re: PDO Error Check

Add at the top of the file: <?php error_reporting(NULL); ini_set('display_errors', 0); it will hide all errors, but you will able to check them on the error log. You can upgrade that a little bit: <?php if ($_ENV['SERVER_ENVIRONMENT'] === 'production') { error_reporting(NULL); ini_set('display_error...
by Michalio
Sun Aug 07, 2022 10:43 pm
Forum: PHP coding => General
Topic: store some data in server memory to be used between scripts and sessions?
Replies: 3
Views: 29

Re: store some data in server memory to be used between scripts and sessions?

ACPu is supported by php8, the old module for acp-bc was removed in php8
by Michalio
Sun Aug 07, 2022 1:11 pm
Forum: PHP Installation
Topic: No https wrapper gets loaded
Replies: 1
Views: 25

Re: No https wrapper gets loaded

What the error log said? Maybe the openssl extension file not exists or have different name so it can not be loaded
by Michalio
Sun Aug 07, 2022 1:09 pm
Forum: PHP coding => General
Topic: store some data in server memory to be used between scripts and sessions?
Replies: 3
Views: 29

Re: store some data in server memory to be used between scripts and sessions?

It may be difficult to do that only in php, you can try to use other software to archive that, for example: 1. You can use a redis service 2. You can try to use sqlite with the file located in memory (if I remember it on linux it is on the /dev/shm) 3. You can write your own in-memory database using...
by Michalio
Sun Aug 07, 2022 12:40 pm
Forum: PHP coding => General
Topic: $_GET
Replies: 1
Views: 21

Re: $_GET

This is a variable, not function, use:

Code: Select all

$_GET['name']
by Michalio
Fri Aug 05, 2022 12:32 am
Forum: PHP coding => General
Topic: Space before and after period...
Replies: 2
Views: 53

Re: Space before and after period...

For make the code more clean I can suggest to add space before and after the dots, when you concating the strings. But the code can be without space, with space, even with new line before or after, that code looks weird but it will works: include __DIR__ . ' /../Templates/' . $templateFileName ;
by Michalio
Fri Aug 05, 2022 12:28 am
Forum: PHP coding => General
Topic: The meaning of a controller.
Replies: 1
Views: 25

Re: The meaning of a controller.

Not exactly, controller exists in many architectures like MVC, but generally the controller is a dedicated class that handle requests from the user and using other classes (like services, repositories, validators, etc), for example: namespace App\Something\Controller; use Something...; public class ...
by Michalio
Mon Aug 01, 2022 11:15 pm
Forum: CSS
Topic: Three divs on one line inside another div 100% width
Replies: 2
Views: 72

Re: Three divs on one line inside another div 100% width

Use flex <div class="parent"> <div class="full-width">1</div> <div>2</div> <div>3</div> </div> .parent{ display: flex; } .parent .full-width{ flex-grow: 1; } You can read a great guide to flex here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
by Michalio
Mon Aug 01, 2022 6:14 am
Forum: PHP coding => General
Topic: How to get saved data from option select?
Replies: 1
Views: 76

Re: How to get saved data from option select?

you need to generate something like this: <option value="1">category 1</option> <option value="2" selected>category 2</option> so you need to iterate your array to render each element and put the right value in attribute and the label in the <option> body. Then you need to add a ...
by Michalio
Mon Aug 01, 2022 6:06 am
Forum: PHP coding => General
Topic: Php to convert excel to pdf
Replies: 3
Views: 147

Re: Php to convert excel to pdf

is wamp 3.2.3 using php 5.3? this version is very old and you should not use it.
can you show you php code that you tested? can you attach also the logs?
by Michalio
Sat Jul 30, 2022 11:53 am
Forum: PHP coding => General
Topic: Need code to not only see one # href site, but how to show more than one.
Replies: 1
Views: 40

Re: Need code to not only see one # href site, but how to show more than one.

You can create an array with all websites with the name and url pattern where will be a place for token.
Then you can iterate by the array and show all or only selected (by parameter in the url or something) website
by Michalio
Sat Jul 30, 2022 10:56 am
Forum: PHP coding => General
Topic: Include header, main, footer
Replies: 6
Views: 94

Re: Include header, main, footer

The old school was when the whole html was in the page for example for login page and when you want to make small change then you should edit many files, because the code was repeated in many places. That was very bad architecture. Then someone invented the DRY (Don't Repeat Yourself) pattern, to ex...
by Michalio
Sat Jul 30, 2022 10:27 am
Forum: PHP coding => General
Topic: Unable to copy row from one database to another on same server
Replies: 1
Views: 37

Re: Unable to copy row from one database to another on same server

Add

Code: Select all

echo $sql;
to check the sql query is valid and use parameter binding:
https://www.php.net/manual/en/mysqli-stmt.bind-param.php
by Michalio
Sat Jul 30, 2022 3:54 am
Forum: PHP coding => General
Topic: Include header, main, footer
Replies: 6
Views: 94

Re: Include header, main, footer

The simples way to implement the way that I mentioned is create the function in te file that is included: function renderPage(string $pageHtml, string $template = 'main') { // This file contains the html <head> ony that is used for each pages, you can put there any data from session or other global ...
by Michalio
Sat Jul 30, 2022 3:37 am
Forum: PHP coding => General
Topic: create a file tree from a zip file
Replies: 4
Views: 58

Re: create a file tree from a zip file

So you just want to print the tree, it will be easy. First you should iterate by each file $file=nameofzip.zip'; $zip = new ZipArchive; $zip ->open($file); for( $i = 0; $i < $zip->numFiles; $i++ ){ $stat = $zip->statIndex( $i ); Then you can print the file path, but it will not be a tree echo $stat[...
by Michalio
Fri Jul 29, 2022 12:54 pm
Forum: PHP coding => General
Topic: create a file tree from a zip file
Replies: 4
Views: 58

Re: create a file tree from a zip file

You need to iterate by each file in the zip as you did, but you need to create a tree from the $stat['name'].
Hoe the tree should look like? For example the file dir1/dir2/file.txt shoule be in $tree['dir1']['dir2']['file.txt']?
by Michalio
Fri Jul 29, 2022 12:47 pm
Forum: PHP coding => General
Topic: Include header, main, footer
Replies: 6
Views: 94

Re: Include header, main, footer

The better way is using any templare engine. For example the twig can extend templates. For example you can create a html template with the head, the menu and the footer and put some empty block for content, then you can create a new template in ex. for login page that contains only the html for log...
by Michalio
Fri Jul 29, 2022 11:03 am
Forum: JavaScript
Topic: Get DOB from age
Replies: 3
Views: 135

Re: Get DOB from age

The date input requires the yyyy-mm-dd format so you can use:

Code: Select all

function getDOBFromAge(age) {
    const date = new Date();
    date.setFullYear(date.getFullYear() - age);
    return date.toISOString().substring(0, 10).split('.').join('-');
}
by Michalio
Fri Jul 29, 2022 2:45 am
Forum: JavaScript
Topic: Get DOB from age
Replies: 3
Views: 135

Re: Get DOB from age

It is partially impossible, because you don't know the day and month, you can for example assume that today is someones birthday: function getDOBFromAge(age) { const date = new Date(); date.setFullYear(date.getFullYear() - age); return date.toISOString().substring(0, 10); } const dob = getDOBFromAge...
by Michalio
Tue Jul 26, 2022 1:16 pm
Forum: PHP Installation
Topic: Setting the PHP version at boot time
Replies: 8
Views: 373

Re: Setting the PHP version at boot time

The php-fpm is a service so you need to start it:

Code: Select all

sudo service php8.1-fpm start
Then the apache will be able to connect with the php server
by Michalio
Sun Jul 24, 2022 12:00 am
Forum: PHP coding => General
Topic: Get selected drop down
Replies: 2
Views: 125

Re: Get selected drop down

Code: Select all

if($row['Pathology']==$row['Pathology']);
It will be allays true, and the semicolon is not needed, I think you need this:

Code: Select all

if($row['Pathology']==$Pathology)
by Michalio
Fri Jul 22, 2022 4:29 am
Forum: PHP coding => General
Topic: PHP Editor
Replies: 4
Views: 144

Re: PHP Editor

Try to use
https://github.com/wapmorgan/PhpDeprecationDetector
I have used something similar when I upgraded php from 5.3 to 7.2 on some legacy app.
by Michalio
Thu Jul 21, 2022 12:47 am
Forum: PHP coding => General
Topic: PHP Editor
Replies: 4
Views: 144

Re: PHP Editor

I google it and the zdsoft is an perl and php editor, so I am not clear what exactly you are asking.
I can suggest to you vscode as an IDE, there is also an thread about the best IDE, so you can try other ones to find that one which will be best for you
by Michalio
Wed Jul 20, 2022 8:09 am
Forum: CSS
Topic: Tilt a DIV in fexa. 45 degrees.
Replies: 2
Views: 187

Re: Tilt a DIV in fexa. 45 degrees.

Can you attach the image that you mentioned?
Probably you will need to use

Code: Select all

transform: rotate(45deg);
But you need to set the width and height properly
by Michalio
Tue Jul 19, 2022 9:08 am
Forum: HTML Basics
Topic: Open a PDF file in a HTML document.
Replies: 1
Views: 232

Re: Open a PDF file in a HTML document.

Use pdf.js
https://pdfjs.express/blog/how-to-use-pdf-js