Search found 590 matches

by chorn
Thu Apr 11, 2019 10:44 pm
Forum: PHP coding => General
Topic: Replace null in jsonencoded array
Replies: 2
Views: 66

Re: Replace null in jsonencoded array

you can just array_walk() or array_walk_recursive() over the array to change certain values.
by chorn
Mon Apr 01, 2019 10:25 pm
Forum: mySQL & php coding
Topic: Need help - password hashing with sha 256
Replies: 5
Views: 239

Re: Need help - password hashing with sha 256

Code: Select all

$query = $pdo->prepare('select passwordhash from users where user = ?');
$query->execute([$username]);
$user = $query->fetch();

if(password_verify($password, $user['passwordhash'])){ OK... }
by chorn
Mon Apr 01, 2019 6:06 am
Forum: mySQL & php coding
Topic: Need help - password hashing with sha 256
Replies: 5
Views: 239

Re: Need help - password hashing with sha 256

if password = $password, I can log into the page with passwords that arn't hashed.
So the password you store in the database is just not hashed, you have to verify your hasing process, have a look at all variables with var_dump().
by chorn
Mon Apr 01, 2019 5:20 am
Forum: mySQL & php coding
Topic: Need help - password hashing with sha 256
Replies: 5
Views: 239

Re: Need help - password hashing with sha 256

Your code is incomplete to test. Also you are lackign a definitive error description. Here's a short working example <?php $user = 'test'; $pass = 'test123'; $hash = hash('sha256', 'test123'); $pdo = new PDO('sqlite::memory:', '', ''); $pdo->query('create table users(user text, password, text)'); $i...
by chorn
Wed Mar 27, 2019 11:11 pm
Forum: PHP General
Topic: Dynamically display images in a container depending on page height
Replies: 7
Views: 261

Re: Dynamically display images in a container depending on page height

I would do something like giving a serverside list of possible images to javascript and then let it calculate how many/which images are to be displayed.
by chorn
Tue Mar 26, 2019 5:34 am
Forum: PHP General
Topic: Dynamically display images in a container depending on page height
Replies: 7
Views: 261

Re: Dynamically display images in a container depending on page height

PHP is serverside and knows nothing about any height a browser is rendering.
by chorn
Wed Feb 27, 2019 2:09 am
Forum: PHP General
Topic: How to change a date via a variable
Replies: 3
Views: 304

Re: How to change a date via a variable

there's a shorter, more flexible and human readable way with the DateTime class, e.g.

Code: Select all

<?php

$date = new DateTime('2014-06-01 14:00:00');
print_r($date);

$date->modify('+1 hours');
print_r($date);

$date->modify('+12 minutes');
print_r($date);

$date->modify('+123 years');
print_r($date);
by chorn
Sun Feb 03, 2019 10:34 pm
Forum: PHP General
Topic: contact form - check ip blacklist
Replies: 2
Views: 171

Re: contact form - check ip blacklist

At least i don't see you using the service anywhere. You can create simple GET request with file_get_contents() on an URL and get a string back. as it seems to be JSON, you can parse the result with json_decode().
by chorn
Wed Jan 30, 2019 10:56 pm
Forum: PHP coding => General
Topic: Hiding passwords
Replies: 6
Views: 362

Re: Hiding passwords

If you can configure where the domain of your projects leads to, you should use a sub-directory as the entry point and place all other files obove this directory, e.g. /files /config db.php <-- store password here /www index.php <-- set your domain to this point so even if the webserver struggles, n...
by chorn
Tue Jan 29, 2019 2:39 am
Forum: PHP coding => General
Topic: Comparing two arrays and extracting values
Replies: 6
Views: 373

Re: Comparing two arrays and extracting values

That makes no sense for me. If you're using SQL you have build-in sorting funtionality with ORDER BY. But that collides with your NC-value, because that's not a number, so your table layout may be wrong. If you want to "ignore" these values, just set an apprpriate WHERE condition.
by chorn
Tue Jan 29, 2019 2:34 am
Forum: PHP coding => General
Topic: PDF files from PHP mail function not opening
Replies: 1
Views: 153

Re: PDF files from PHP mail function not opening

why dont you use some wrapper like PHPMailer? It's really straigth forward and deals with a lot of problems very well.
by chorn
Fri Jan 25, 2019 4:47 am
Forum: PHP coding => General
Topic: Comparing two arrays and extracting values
Replies: 6
Views: 373

Re: Comparing two arrays and extracting values

So you got a list of needed functions, did you try any?
by chorn
Fri Jan 25, 2019 4:14 am
Forum: PHP coding => General
Topic: Comparing two arrays and extracting values
Replies: 6
Views: 373

Re: Comparing two arrays and extracting values

What does "top 5" mean, any sorting by number?

array_combine
ksort
array_keys
array_values
array_sum

https://secure.php.net/manual/en/ref.array.php
by chorn
Tue Jan 22, 2019 4:42 am
Forum: PHP coding => General
Topic: Parsing a json
Replies: 14
Views: 649

Re: Parsing a json

just have a look at print_r($datas) and you see "tables" is previously contained by another key. Tip: you're missing something from your first code. Protip: you may want to use array_column() instead.
by chorn
Tue Jan 22, 2019 2:34 am
Forum: PHP coding => General
Topic: Parsing a json
Replies: 14
Views: 649

Re: Parsing a json

[tables] => Array ( [0] => stdClass Object ( [tableName] => Unique League Table [table] => Array ( [0] => stdClass Object ( [teamName] => Liverpool on each item from "tables" you have a key "table" which you can iterate over again and read the key "teamName" foreach($datas['tables'] as $table){ for...
by chorn
Tue Jan 22, 2019 2:17 am
Forum: PHP coding => General
Topic: Parsing a json
Replies: 14
Views: 649

Re: Parsing a json

If you print_r($Datas) you see there's a key called "tables" you could iterate over with foreach().
by chorn
Tue Jan 22, 2019 1:10 am
Forum: PHP coding => General
Topic: Parsing a json
Replies: 14
Views: 649

Re: Parsing a json

Then post an example with var_export.
by chorn
Tue Jan 22, 2019 12:44 am
Forum: PHP coding => General
Topic: Parsing a json
Replies: 14
Views: 649

Re: Parsing a json

Just post a valid example.
by chorn
Tue Jan 22, 2019 12:10 am
Forum: PHP coding => General
Topic: Parsing a json
Replies: 14
Views: 649

Re: Parsing a json

vasomik wrote:
Tue Jan 22, 2019 12:00 am
and print_r($decoded) that gived me the whole array!
No it does not, just tested:

https://3v4l.org/3etl2

or your example is invalid.
by chorn
Mon Jan 21, 2019 11:51 pm
Forum: PHP coding => General
Topic: Parsing a json
Replies: 14
Views: 649

Re: Parsing a json

that's no JSON, at least the quotes for the keys are missing.
by chorn
Thu Jan 17, 2019 11:31 pm
Forum: PHP coding => General
Topic: How to read incoming csv text data to PHP page and display it
Replies: 3
Views: 264

Re: How to read incoming csv text data to PHP page and display it

so you have a solution now, is there any problem left?
by chorn
Mon Jan 14, 2019 11:26 pm
Forum: PHP coding => General
Topic: date_diff
Replies: 3
Views: 280

Re: date_diff

Use the DateTime class, it has a diff-function.
by chorn
Sun Dec 30, 2018 5:56 am
Forum: PHP coding => General
Topic: A Laravel app that implements a JSON API
Replies: 1
Views: 224

Re: A Laravel app that implements a JSON API

Step 1: Download Laravel.
by chorn
Sun Dec 16, 2018 11:56 pm
Forum: PHP coding => General
Topic: How to install PHP Open Source like Wordpress
Replies: 1
Views: 265

Re: How to install PHP Open Source like Wordpress

do it as the documentation says.