« first day (3382 days earlier)      last day (1791 days later) » 

user10141648
00:25
Hi, can someone help me?
user10141648
I'm trying to learn MVC
user10141648
I can store users now with this function:
public function store()
{
App::get('database')->insert('users', [
'email' => $_POST['email'],
'firstname' => $_POST['firstname'],
'lastname' => $_POST['lastname'],
'street' => $_POST['street'],
'streetnumber' => $_POST['streetnumber'],
'postalcode' => $_POST['postalcode'],
'country' => $_POST['country']
]);


return redirect('users');
}
user10141648
how do I for example check if $_POST['email'] contains a '@' with the function . strpos...
Do I do this in this function or somewhere else?
@Merdin You probably want to do it somewhere else. Let store() store things and validate() an validate things.
SRP
user10141648
can you now make a validate function for me as an example?
00:32
Really?
user10141648
For example my last 2 sentences in my last post
user10141648
I mean like, I don't understand how it works
Why don't you try doing that yourself?
@Merdin The best path to understanding is doing.
Start. Fail. Rinse. Repeat.
user10141648
I understand that
user10141648
00:34
I mean like.
I make the function validate() do I then call the function in store() ?
user10141648
Before it is getting inserted
@Merdin Think about it. What do you want to happen if it's not valid?
What do you want to have happen if it is?
If it's valid... do you want to A) store it, B) not store it, C) run around with your arms flailing about aimlessly?
You have 30 seconds.
user10141648
That is not the part I don't understand.
I don't understand how I'm going to make a validate() function and how it then checks if everything I asked for is checked if it is correct and then store it.
@Merdin But you do. You just said so.
11 mins ago, by Merdin
how do I for example check if $_POST['email'] contains a '@' with the function . strpos...
Do I do this in this function or somewhere else?
user10141648
Yeah but I mean like.
I tried to do that strpos thing in the function store() and it didn't even work there.
00:39
"didn't work" is not a useful metric by which to debug things.
In order to fix a problem you must be able to identify 2 key characteristics: 1) What is the intended behavior, 2) What is the actual observable behavior.
That's the only way to draw 1 and 2 closer together.
Here's a hint. You want help with broken code. Show us broken code.
user10141648
I will try it again
user10141648
wait a sec
Otherwise, my ability to read your mind is currently offline.
In addition to @Sherif 's advices: codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question Great article also here.
Evening.
In a perfect world we'd all be just smarter question interpreters... but ya know
user10141648
00:45
Fixed it B)
Look at that. Trial by error is still alive and well afterall.
user10141648
Thank you tho
user10141648
will look into the things you send
@Merdin It's a really important read for every beginner: gist.github.com/srgoogleguy/a1d1a3404e964e0776f0539177a20f19
user10141648
Thank you ! :)
00:49
If I could make my junior devs frame that in a 5x10' poster and hang it over their desks I would.
user10141648
hahaha
I'm just gonna reframe this tweet because it should still matter :D
Secret Joe alt confirmed.
;)
It's a valiant point. PHP is the only OS project I know of that doesn't actually bother organizing financial support for its arteries.
Well, major OS project anyway
 
1 hour later…
user10141648
02:21
@Sherif u there?
maybe
user10141648
https://github.com/Merdin/The-PHP-Practitioner-Full-Source-Code

I can't really figure out how to make a deletion work.
core->database->QueryBuilder.php is the function
app->controllers->UsersController.php is where the function is used
app->views->users.view.php is where the delete button is
app->routes is where the routes are made
user10141648
Fatal error: Uncaught Error: Class 'App\Core\Exception' not found in /Users/merdin/Documents/code/PHP-OOP/core/Router.php:67 Stack trace: #0 /Users/merdin/Documents/code/PHP-OOP/index.php(9): App\Core\Router->direct('users/delete/2', 'GET') #1 {main} thrown in /Users/merdin/Documents/code/PHP-OOP/core/Router.php on line 67
user10141648
I think I need to make something work (function) which can do something with :user_id
user10141648
I tried a lot of things, so maybe there is some wrong code (like a typo) in there
user10141648
02:30
The function is not what I'm really worrying about now, the thing is that it doesn't go to /users/delete/2
user10141648
it can't find /users/'delete'
Sounds like you forgot to alias \Exception
user10141648
where
Right there.
Read the error message.
> Fatal error: Uncaught Error: Class 'App\Core\Exception' not found
user10141648
Fatal error: Uncaught Exception: No route defined for this URI. in /Users/merdin/Documents/code/PHP-OOP/core/Router.php:67 Stack trace: #0 /Users/merdin/Documents/code/PHP-OOP/index.php(9): App\Core\Router->direct('users/delete/1', 'GET') #1 {main} thrown in /Users/merdin/Documents/code/PHP-OOP/core/Router.php on line 67
02:34
Well, that's a completely different error.
user10141648
same error, just added the \ in front of exception
No, that's an entirely different error from the one you pasted above.
All you'd have to do to prove that is read it.
user10141648
$router->post('users/delete/:user_id', 'UsersController@delete');

I don't know how to make the :user_id part work
user10141648
What is ":user_id" called in php in this scenario?
user10141648
placeholder / token ?
02:41
A string?
user10141648
no man, nvm
user10141648
i need to figure out how that route works
03:00
@Sherif some people need an example to help them understand how something works (I am one of those people), it doesn't have to be sophisticated, just something quick
user10141648
exactly ^
... and yet they managed to do it all on their own
There's a certain sense of satisfaction you can't get from being handed an answer
it depends on if I have a point of reference to work from already
if it's something I have an idea on, or have something in front of me that is enough info for me to work from, then yes, I can probably figure it out on my own
user10141648
if you understand how it works but can't figure out what to do to make it work, then an example is really helpfull
if it's a concept completely foreign to me and google isn't helping, then an example helps tie it together
03:09
yet, examples don't actually lend any understanding whatsoever.
people learn differently, man
what may not work for you, works for someone else
I'm giving you my perspective on how I learn stuff
All they do is allow you to think by reverse engineering the working solution. It's the thinking part that got you to understanding.
Feel free to lie to yourself all you want though.
my brain just doens't work that way, sorry
Our brains all work the same.
I have autism, it affects how I learn stuff
03:11
We just have to learn how to use them more effectively.
you can't fit a square peg into a round hole
Good thing I'm not trying to.
yes, you are
I'm pretty sure I know what it is I'm doing. I'm the one doing it.
user10141648
If it wasn't true what @Tiffany is saying, then he / we wouldn't say it
03:13
you're saying that what works for you, must work for everyone, our brains aren't the same
You wish to impress upon me that you know how to learn better by telling me how to teach you in a certain way. I posit, if you knew how to learn better you'd already be better learned.
I see this is going nowhere
user10141648
That is not true.
user10141648
Some people learn words by just reading it over and over. And some people need to learn 5 words at a time
Rote memorization is a methodology not a strategy.
Your brain is actually capable of something called spatial-memory which is far superior to rote memorization, for example.
user10141648
03:15
Well, if you aren't here to help. Then you rather just leave :)
It makes no difference the person to use either methodology. They are equally as effective across all human brains.
user10141648
Thanks for your time.
Rote memorization is always slower and less effective, if even relatively variable across the population. Whereas spatial memory association is always faster and more effective in the short term, if even relatively variable across the population.
@Merdin I've been here for years helping millions. You are always free to turn down help. I am free to help how I choose.
03:36
Achieving perfection is quite a goal/task.

@Merdin UsersController@delete expects GET parameter. Check your view file if you provide it there.
user10141648
The problem is that in my route it can't read :user_id (i think)
user10141648
thats where I'm stuck
user10141648
if i make a router to just /users/delete then it works
user10141648
problem is the int after /users/delete/%
user10141648
At work i use the slim framework and then you do the following;

$router->get('users/delete/:user_id', function($user_id) use ($app) {
// code

};
user10141648
03:39
but then it is more used as a controller
Try with "/users/delete?id=<?php echo $user->id;?>" to check does it work in way how method expects it.
 
5 hours later…
09:13
Tech Nightmares - Waking up thinking you'd ran up an 8 million dollar bill on AWS on a clients account.
"Ima bout to wreck this mans whole career"
 
7 hours later…
16:18
Morngins
17:14
Hello
 
2 hours later…
19:08
@DaveRandom You seen dan lately by any chance?
19:39
@PeeHaa no, I have his number though if you need to contact him
Dm'd it to you
(On twatter)
 
1 hour later…
21:00
Minor Service Outage | API Requests has Partial Outage | Notifications has Partial Outage
Minor Service Outage | API Requests has Partial Outage | Notifications has Partial Outage | Gists has Partial Outage
Incident on 2020-01-19 21:06 UTC | API Requests has Partial Outage | Notifications has Partial Outage | Gists has Partial Outage
21:23
Incident on 2020-01-19 21:06 UTC | API Requests has Partial Outage | Notifications has Partial Outage
Incident on 2020-01-19 21:06 UTC |
All issues have been resolved!
21:42
Does anyone know why a simple $conn = new mysqli('localhost', 'root', '', 'my_db'); would be causing a 504 gateway time out in the browser? At least things I should start checking for? Fresh php/mysql/nginx install.
21:53
Probably a timeout connecting to the DB
Would make sense at least as a place to start
@DaveRandom tnx

« first day (3382 days earlier)      last day (1791 days later) »