« first day (1996 days earlier)      last day (2967 days later) » 

6:01 AM
that's probably what we should do, these are tiny units, very cheap to compile, very simple to compile, they reoccur (and possibly are reusable in the way we probably think they are) ...
it would be very php if you autoloaded a file and it already had a compiled representation ready to execute ... very php ... that could be possible ...
maybe not ready to execute in some cases ... but we could have already done half of the work is what I'm saying ...
it might also be terrible ... but every other way that has been tried is either terrible (zend) or has no real benefit for real code (hhvm) ...
it would generate pretty horrible code ... I think ... but who is looking at that, it would do it fast and it would fit better, I think ...
 
@Joe yeah, that's the way to go…
 
anyone here good at javascript, since the js room doesn't want to help it seems
 
6:17 AM
Morning all, say I want to edit a user, what could be an approach to doing so? Right now I am displaying all users in the database into a table, and on the same row I have delete and edit buttons (imgur.com/vzePuEV) now what I want is, when I click the edit button I want it to redirect me to another page (got that) and in there I just want it to display the username and give me a field to edit the username. I got this for that imgur.com/9XvXHAu
buuut can't really figure out the sql part of it
 
bad idea
 
so I want it to display the username where it says Edit User: imgur.com/9XvXHAu
I got this so far: pastebin.com/VbEfThpU
 
basically when I click the edit button it takes the id and the username and passes it on to editUser function
I get undenified index when I try using this <h1>Edit User: <?php echo $_POST["username"];?></h1>
 
6:28 AM
@Spiderix DON'T OPEN AND CLOSE THE PHP ENGINE LIKE THAT
it slows down processing
 
How else would one display Edit User: "Username here"
 
echo
 
You see in this image imgur.com/9XvXHAu I want it to show Username after the Edit User:
 
echo html not display it normally
do you know anything about php?
 
Very little
or well I know some but not much
 
6:31 AM
echo everything once you open php
 
hmm
 
use echo "$variable"; it will output the variables
 
but how does it know where to find the username variable?
 
single quote treats the variable as a string
you put it in the normal spot
 
hmm I tried this <h1>Edit User: <?php echo '$username = ["username"]';?></h1>
but that just displays this $username = ["username"]
 
6:34 AM
use the input tag
 
and then in the value I put the php stuff?
 
yes try this echo"text $variableName text";
 
mysqli and pdo prevent that
 
Oh I am not inputting anything at the moment
+ I use filter for the inputs
right now I am simply trying to display the username next to Edit User: imgur.com/9XvXHAu
 
6:39 AM
post this in php:
$testvar='testing';
echo "text $testvar text";
 
@acoder his code $db->query("UPDATE users SET username ='$username' WHERE id = '$id'"); explain to me how that is preventing SQL injection?
 
cryptic, what do you think of my project access: github.com/Jquery-PJAX/PJAX/blob/master/php/example.php
@crypticツ any ideas for the pjax function i'm building?
 
@acoder it says this Edit User: text testing text
 
that's how you get the variables out
 
But this part here $username='username' how do I actually tell it to take the username that is on the same row as the Edit button as seen here imgur.com/YEmZe0U
that's where I am stuck
 
6:43 AM
@crypticツ any ideas on the pjax function i'm building?
$row['username']
 
hmm gives me Array to string conversion in <h1>Edit User: <input type="hidden" name="username" value="' . $row['username'] . '"/></h1>
 
@acoder doesn't matter, neither protects from SQL injection out of the box. Read what I linked to.
 
yuck, try:
echo "<h1>Edit User: <input type="hidden" name="username" value=\'$row['username']\'/></h1>"
if i have slashes correct
 
why escape? Just use '
 
6:48 AM
isn't it quicker processing?
 
also the double quotes should be single for the attributes
 
hmm, it still does not grab the username from the table
 
print_r($row);
 
sec, I will upload my two files to pastebin
 
is it there?
 
6:51 AM
I get this Array ( [0] => username )
I think it is this part $row=['username'];
 
then you can use $row['0']
 
Wes
youtube.com/watch?v=moAZ3AsyhLU warning, explicit language
 
everyone should ask @Wes for help.
7
 
hmm nothing happens
 
$row[0]
 
6:53 AM
Array ( [0] => 0 )
Same thing
 
why doesn't it have a name attached?
 
what you mean?
 
Wes
@crypticツ ?
 
so far I got this

$row=[0];

echo '<h1>Edit User: <input type="hidden" name="username" value=\"$row[0]\"/></h1>';
 
@Spiderix pastebin your code.
 
6:54 AM
ok sec
 
@Wes sorry, threw you under the bus.
 
Wes
ah, i have too many users ignored :B
 
lol, he's clearing the data
 
@Wes no you don't
 
wes can i pick your mind on something pjax related?
 
6:56 AM
Ok, this is my edit user page pastebin.com/FLmCMjuk and this is my UserModel, in it is a Edit User button pastebin.com/PJTFnJrs
 
Wes
@PaulCrovella at some point you will be talking to yourself only
 
@Spiderix @acoder both of you need to read secure.php.net/manual/en/language.types.string.php
 
there will be such peace
 
Cryptic, right now the security is not priority, I want the functional stuff out of the way then focus on senetizing the SQL
 
@PaulCrovella can i pick your mind?
@Spiderix use either pdo, or mysqli
 
6:59 AM
I use PDO
 
@Spiderix don't sanitize your password, there is no need to unless for some awful reason it's being printed out. You sanitize the password you end up changing the password and thus the hash you generate will be wrong.
 
pdo has it built in then
when you bind i believe it does it
 
also use password_hash() for generating your password hash.
 
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$password = ('password');
but, can we focus on my question :D I will do the cleaning later
 
You need to read the manual before you do all of this. You're spending more time guessing how the language works, opposed to actually being productive on learning it once and for all. secure.php.net/manual/en/index.php
 
7:02 AM
Understandable but I simply don't have the time at the moment.
 
So you'd rather put up an insecure site?
 
it is an assignment, it is not going out to the public
 
I don't help help vamps
 
but my approach is, do what is required and then focus on fixing up the security
 
Oh, so you're having us do your homework.
 
7:03 AM
we don't help with homework
 
no, I am having you explain how I pull a username to be showed next to Edit User:
because I tried echoing it and it won't echo it
 
cryptic, since it's homework can i get your view?
 
if you read the manual like you're suppose to, then you would have been done long ago.
@acoder sure
 
That is very true I assume
 
7:06 AM
there is videos on it also
@crypticツ like it so far?
 
@acoder I don't know what I'm looking at. There is just a jquery function and then a PHP function copied to multiple files.
 
and notice I simply asked for an approach not how to do my homework...
 
are you familiar with pjax?
pdo, and mysqli will do it
 
@Spiderix when you don't understand how strings works in PHP and are asking for nearly a half hour how to echo something correctly, then you're not asking for an approach, but ultimately having others fix it for you, thus doing it for you. I linked to the relevant PHP docs page on strings, so you can understand how interpolation works. I suggest you read it so you can move on to your next step.
 
yes I read that and I did make my own implementation and then I said that it didn't work
 
7:16 AM
$row=[0];
echo '<h1>Edit User: <input type="hidden" name="username" value=\"$row[0]\"/></h1>';
What do you see wrong with both those lines?
 
I am not using that anymore, changed to something else
 
done
 
cryptic problem with row is it will always display 0?
or it will display array 0
what I am trying to is, instead of 0 to grab the username which is on the same row as the edit button
 
@Spiderix technically it's valid PHP as it is creating an array with the value of 0, but afaik you're trying to set $row to the fetched database row.
 
7:21 AM
like for my delete button I did this:
echo '<td>
<form method="POST" action="/deleteUser">
<input type="hidden" name="id" value="' . $row['id'] . '"/>
<input type="submit" value="DELETE" name="deleteUser"/>
</form></td>';
and then in my deleteUser function I did this $id = $_POST["id"];
yes cryptic, in my other file I do the fetching
like here for example $row = $result->fetchColumn();
 
Then why are you not doing it the same way?
 
But I am already doing it in my UserModel.php
I was thinking to grab it from there and send it to my editUser form
if that makes sense
 
i'm out
 
so eventually what I was trying to achieve is, once you click the edit button it passes the username to the edit form
and that's where coder tried explaining it to me
 
Why are you outputting a hidden input tag in your h1 tag in the first place?
 
Wes
7:27 AM
$previousCountOfBaz = $bag->add($baz, $howMany = 5); // will return 4 as 4 $baz were in the bag
vs
$newTotalCountOfBaz = $bag->add($baz, $howMany = 5); // if 4 $baz were already in the bag, will return 9
 
I am not? I got this in my h1 tag <h1>Edit User:<?php echo $username["username"];?>/>
 
monrin
 
sec, username ment to say row*
 
@Wes why violate CQS?
 
I have written an application that is based on modules for it's functionality so features can be added or removed easily i built this with laravel how can i reuse the same project structure for multiple applications ? currently composer.json is kopy.io/fHxt0 i want to make separate composer repository but also keep laravel updated
 
7:31 AM
moin
 
Wes
@tereško i do follow CQRS, but you know, it does no harm returning something useful if you can
 
so i can simple do composer create-project myproject and the structure gets installed
 
I think you might be missing a point there
 
Wes
as many things in programming, these "principles" don't always have to be interpreted as religions @tereško
 
@Wes the latter
 
Wes
7:41 AM
@PaulCrovella i thought as well it would be more useful to return that, then i checked guava and they return the previous count instead. returning the previous value is useful most of times but it's a bit stupid here.
 
@Wes it's analogous to array_push which returns the new total.. deviate from that if you've got a good reason, but I'd treat it as the default choice
 
Wes
i mean considering the purpose of bags it is more likely you want to know the new total rather than the previous count. but it's not that one is wrong and the other is right
also in both cases you can do ($bag->add($a, 5) +/- 5) to obtain the other value
 
hence the appeal to consistency with something similar
 
Wes
indeed, but i tend to trust design of guava more than php's :P
i'll leave a @TBD
 
7:57 AM
Morning
 
Why do regulars here almost always spell morning wrong?
like mrnging
 
Wes
because they write it before they had a coffee
 
Thanks, @Wes
 
Wes
lol
 
8:31 AM
Mornininings
buh Caturday!
 
romnin
 
I'm building an audio player using javascript and jquery along with html/css, if I want to pack it all into a wordpress plugin that has an admin page that allows the user to easily upload mp3's php is my best choice right? I mean it's my only choice for building a wordpress plugin?
 
php is my best choice?
It's your only choice for making a wp plugin
 
yeah thats what I thought
 
like you can use js, html, css but the core for the plugin is written in php
 
8:48 AM
yeah I see, that's what I was coming to the understanding of as I do more research
It should be fairly simple. I just need to upload a file on the admin page, and then have that inject some code into the page where the player is
maybe add some functionality like ordering the songs etc
and then have the player be embedded by shortcode
 
yea, sounds reasonable
 
php function names are such cancer
rfc: php custom function aliases
 
9:37 AM
Damn this Chai latte is good
 
hello
i want to save file in a folder
in php
but unable to save a file
here is my code
$dir="logs_time";
	if (is_dir("$dir")){
		if ($dh = opendir($dir)){

			$f="am.txt";
			$fi=fopen($f,"w+");



		}
log_time is my folder where i want to save am.txt
 
file_put_contents(__DIR__.'/log_time/am.txt, 'Hello World');
 
@Ekin o/
 
fopen not works why? @RonniSkansing
 
I dunno what you expect that code to do @SajjadKhan but its incomplete and does not really make sense.
Like your use opendir, but never use the results for anything
you do a fopen, but never use the resource
 
9:47 AM
@Danack all your problems are caused by trying to find classes that don't exist within the scope of the SourceLocator
 
@RonniSkansing agree
 
I'm not sure the best way of handling it; there's a couple of options I guess; 1) throw an exception to say "can't reflect XXX because not found" or whatever (useful feedback) or 2) make a "placeholder" reflection or something (probably not so useful, obscures the problem I think), unless you can think of someting else
 
@SajjadKhan if you want to use fopen, take a look at fwrite and etc php.net/manual/en/function.fwrite.php
 
Ani
Hey guys, May I ask you to help me with import query within PHP? Here's my thread.. I still have no answer, but I need to finish this today =) Thanks i advance
NOTE: the print is just for test. I actually need to run the commented out query in the While loop

http://stackoverflow.com/questions/36377525/php-array-iteration-in-loop-and-put-fetched-results-in-a-table-with-mysql/
 
@Ani homework?
 
Ani
10:01 AM
@Patrick Yes, more like a university project that I have to present tomorrow morning :( And this is the very last thing i need to do and I am terribly stuck. I know it is sth very easy, but I don't see it
 
@Asgrim throwing a specific exception is almost certainly correct. But it is too early for me to English words for it.
Talking of which, naming things is hard, edition 249; A tool for downloading code from github and then doing a trivial analysis on it - name suggestions please, as currently it is going to be called 'John'.
 
@Danack James
 
@Patrick I was reading your no framework tutorials last night, and I found a typo ;-) in the chapter of inversion of control in line 38....
 
@Saitama do a PR?
 
10:13 AM
I will stay out of it then, but for the record - using direct language on the internet (like, "did you see that PR?") is normally preferred over dropping subtle hints...
 
Oh alright :(
 
good morning ladies ;)
 
Anonymous
It is the worst case for syntactic sugar I've seen in a while.
 
Anyone shared a folder across development projects? I've got two close projects I want to factor out code into a common (or "shared") folder.
But I never did this and wonder for example about the wording and some practical experience would be nice.
 
@Saitama merged
 
10:21 AM
My initial idea was to have a folder named "shared" next to "src".
 
@samayo please use nicer language than that.
Also:
 
Anonymous
@Danack Yeah, you're right. It is the shittiest RFC I have ever seen.
 
@Danack bookmarked
 
@Patrick :)
 
10:26 AM
@samayo Be nice
 
Anonymous
@Danack It's not that, it's just annoying to see all these RFCs which are just rudimentary get proposed every single day.
 
Anonymous
But I guess that's how the rfc has evolved into ...
 
@samayo calm down mate
 
Anonymous
I'm calm :)
 
Anyone has experience with sharing code between two projects but not using composer for that (so that a directory is mirrored for example)?
 
10:29 AM
@samayo I suggest turning off the computer and going outside for a bit. Without wanting to get too 'meta' you seem to have a habit of being nasty to people who you haven't spoken to before. It's not appropriate behaviour in general and particularly not in this room.
@hakre Putting the two projects in one source control is the best solution if at all possible...
 
@hakre =) why not the composer way?
 
Anonymous
@Danack Nope. I've never been nasty to anyone. Maybe you've confused me with @tereško ..
 
@Danack They once were but then split. They even has lost their branching ancestor (here in git).
@RonniSkansing because I'd like to sync more easily. The code is effectively part of both projects but I'd like to deduplicate better.
Like for example I have started to extract code that now has parameters / variables at the places that did differ. Now these artifacts could be shared between the two projects.
It just was not clear what would differ in the future so there was a decision to just split first.
I now would like to minimize the negative effects of that procedure. The decision had it's benefits as now it's easy to see where actual differences appear while retaining working versions.
 
@hakre how about putting it in a folder and putting the path into the include_folders thing
like pear packages
 
@RonniSkansing Yes, at least I hope I can have two times the same root-namespace within PSR-0/4 autoloaders in composer?
 
10:34 AM
@hakre putting them back under one repo, even if they are kept separate within that repo for the time being, is almost certainly the right thing to do...
./project1/
./project2/
./shared/
 
But then how do I easily do a checkout? Like let's say project2 is cloned, not yet is shared.
 
how about 3 repors. project 1 and 2 both have project 3 as a submodule
 
git submodules, I have been thinking about that as well.
IIRC they would allow to continue development within project1 or 2 and then push changes over to shared when stabilized.
But then I'm wonderung how a directory layout within project1 or 2 would look like.
 
./project1/shared (is submodule)
 
10:37 AM
@samayo You are now.
Please stop.
 
@hakre I am not really sure how it works with having two root same root spaces.. let me know how it works out
 
@RonniSkansing ok, I'll give this a try. I will mock that first and if it works introduce it as a git submodule. That should be possible then.
 
11:13 AM
@samayo there is a method to my madness
 
Anonymous
11:27 AM
@tereško I feel your pain now :)
 
Anonymous
Does anyone know how to save a file downloaded via cURL?
 
Anonymous
Using the url as the name.
 
Anonymous
while read -r url
do
   sleep 3
   i=$(($i + 1))
    curl -o "$url" "songs/$url"
done < "mp3_src"
 
Anonymous
That is not doing what it is supposed to do.
 
12:04 PM
Hey guys, I am trying to load in the name, and filepath of an image into a table in my DB however I am failing hard. pastebin.com/WmVkkBzG is my source code, also this is homework, so no direct solutions please :)
also my table is called images with the following columns: id, imagename and filepath
 
@Spiderix do you think people here are psychic? No one is going to help you if you don't post the actual error or error message.
2
 
Anonymous
@Spiderix while you are at it, please consider using a library like mine samayo/bulletproof to upload/store images.
 
haha, very true. This is the following error: pastebin.com/YA8DqLPd
@samayo As it is homework we are not allowed to use external libraries
but I have bookmarked it for future use, when I am doing something of my own.
The upload to the folder works as intended, it just fails on inserting the name and filepath into the database
 
Anonymous
Well, how about it you replace line 13 - 15 with . .
 
Anonymous
$statement = $db->prepare('INSERT INTO images (imagename) VALUES (?)');
$statement->execute([$name]);
 
Anonymous
12:16 PM
but even if this is a homework, you should be able to make the image upload a little bit secure ..
 
yea, I will senetize it in a moment
@samayo ok that worked indeed, but I just noticed my other error :D I have no variable that stores my filepath lol
 
Anonymous
You can add that, or use something like require __DIR__ . '/path/to/images' . $image or something similar.
 
I have a global variable called IMAGE_DIR and then I simply say . '/' . $name
 
Anonymous
Yes
 
Anonymous
You should worry about security though, b/c your script has more holes than a Swiss cheese
 
12:23 PM
haha
 
Lol
 
Ok, I made this variable $filepath = "IMAGE_DIR . '/' . $name";
and then $statement = $db->prepare('INSERT INTO images (imagename, filepath) VALUES (?,?)');
$statement->execute([$name], [$filepath]);
 
Anonymous
$statement->execute([$name, $filepath]);
 
gonna check if I get any errors
Aaaa nice spot
Nice, that worked indeed
now I should be able to call it down and display it
thanks for the help :)
 
Anonymous
:)
 
12:29 PM
morng
 
morning? it is 14:31 here, time goes too fast
 
I just woke up so it's morning enough to me
 
good morning then :)
 
it's always morning on so chat
 
@littlepootis no, total-knowledge.com/~ilya/mips/ugt.html /cc @Spiderix
 
12:41 PM
haha thank you @Danack
UGT timezone, I like that.
 
1:20 PM
eyy :D
 
1:43 PM
hey guys quick question
haven't touched PHP since 2012, has anything drastically changed?
 
!!package nikic/fastroute
 
[ nikic/fast-route ] Fast request router for PHP
 
Hej guys, I am using onClick="validateUser()" on my login button but how can I also make it possible that you can simply press the ENTER button? This is my button <button type="button" onClick="validateUser()">Login</button>
 
Don't bind events inline
 
What is the alternative called?
 
1:44 PM
Use proper .addEventListener()s
 
Ok thanks @PeeHaa I will check it out
 
np
 
!!package rdlowrey/auryn
 
[ rdlowrey/auryn ] Auryn is a dependency injector for bootstrapping object-oriented PHP applications.
 
@someFolk I'd suggest checking that out.
 
1:46 PM
@Danack We need a !!tell command to prevent having to run a command and ping afterwards
 
is just having more stuff after the command allowed?
!!package rdlowrey/auryn - @Peehaa i.e. everything after the hyphen
 
[ rdlowrey/auryn ] Auryn is a dependency injector for bootstrapping object-oriented PHP applications.
 
Not right now. I think some rewrite is needed to allow it
 
@Danack mm? check out what?
 
hindsight 20/20 and such
 
1:48 PM
ah that works - just tell people that hyphen is separator, and allow anything after it?
 
It doesn't work for all commands. Some commands I check the number of paramters and bail out when it's incorrect
 
@PeeHaa You do, I don't. :P
 
I know :P
I also don't do it for all
It's just one of those things I have waited with before it started too smell too much
I'm going to check whether !!tell @Danack !!command params is easy to do without having to rewrite it all
 
Ok, I did this

<script>
document.getElementById("loginButton").addEventListener("click", validateUser());
</script>

and my button
<button id="loginButton"type="button">Login</button>
however, when I insepect the page it says Uncaught TypeError: Cannot read property 'addEventListener' of null
 
You have to add the code after the element is added to the dom
 
1:52 PM
I think just making a hyphen be an end of parsing marker, would fit in naturally with the chat-like nature of the commnds.
 
does the script come after the butrto
Ah, figured, thanks!
 
Also drop the parens
You are always calling the function now instead of on callback
 
!!admin list - no one would be foolish to give me admin powers would they?
 
tereško, Ronni Skansing, Joe Watkins, kelunik, bwoebi, Félix Gagnon-Grenier, Florian Margaine, DaveRandom, Danack, Levi Morrison, NikiC, Gordon
 
MuaHaHaHa.gif
 
1:53 PM
:P
 
@Danack they gave me admin access
 
!!admin list
 
@littlepootis I'm sorry Dave, I'm afraid I can't do that
 
1:55 PM
@Jeeves Why is list restricted?
 
TIL I'm Dave, thanks @Jeeves
 
^ kids these days
 
@tereško you are a admin in where? this room?
 
@kelunik Because... :P
I could allow it yeah
 
@Shafizadeh naah, I just have full access to the bot .. which I don't even use
 
1:56 PM
I see
 
Does the bott tell jokes?
like if you typed !!home then it says something Homer would say
homer*
 
@Spiderix I think you can try (test) it
 
I have no idea how to use bots on this chat
!!homer
:'(
 
@Spiderix d0h!?
 
What if Jeeves starts dating Cap?
 
1:59 PM
:')
 

« first day (1996 days earlier)      last day (2967 days later) »