« first day (2714 days earlier)      last day (2459 days later) » 

00:12
Documentation lacks a warning about file_put_contents() – #76132
 
2 hours later…
02:12
huge mistake! – #76133
02:57
执行结果不同 – #76134
03:59
Hello
I have a beginner problem, but cannot find the mistake in PDOStatement.
This is my query
$query = "INSERT INTO employer (company_name, website, contact_person, phone_no, company_email, address, district, state, country, zip_code
job_summary, req_qualification, sex, age_limit, experience, job_location, key_skill, func_key_skill, non_func_key_skill, salary_package)
VALUES (:compName, :website, :contactPerson, :phNo, :compEmail, :fullAddr,
:dist, :state, :country, :zipCode, :jobSumm, :reqQual, :sex, :ageLimit, :experience, :jobLoc,
:keySkill, :fuctKeySkill, :nonFunctKeySkill, :salPackage)";
And these are the bind variables
$stmt_employer = $pdo->prepare($query);
$stmt_employer->bindParam(':compName', $compName);
$stmt_employer->bindParam(':website', $website);
$stmt_employer->bindParam(':contactPerson', $contactPerson);
$stmt_employer->bindParam(':phNo', $phNo);
$stmt_employer->bindParam(':compEmail', $compEmail);
$stmt_employer->bindParam(':fullAddr', $fullAddr);
$stmt_employer->bindParam(':dist', $dist);
$stmt_employer->bindParam(':state', $state);
$stmt_employer->bindParam(':country', $country);
$stmt_employer->bindParam(':zipCode', $zipCode);
I'm getting



PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in /opt/httpd-2.4.29/htdocs/gblex-imported/src/dbops.php:319
Stack trace:
#0 /opt/httpd-2.4.29/htdocs/gblex-imported/src/dbops.php(319): PDOStatement->execute()
#1 /opt/httpd-2.4.29/htdocs/gblex-imported/src/employer.php(16): DBOps->create_or_update_employer('register', Array)
#2 {main}
> $stmt_employer->bindParam(':exprience'
missing an e?
o/
 
1 hour later…
05:12
Issue with Isset – #76135
Wes
Wes
05:43
holy maccheroni the snow
o/ morning Wes
how to genetare auto increment numbers as like this 001,002,003 for seperate users while registering a form... i want to give unique numbers for various users using autoincrement numbers like 001,002,003..so on. but incase if 001 already given to 1 user the increment will start from 002 please help me how to do this?
Wes
Wes
06:11
$newNumber = str_pad($number + 1, 3, "0", STR_PAD_LEFT);
06:35
Is SO chat going really slow for anyone else these past days?
Wes
Wes
06:46
works for me
07:03
:/ It must be my internet
I can't believe people here are still discussing if debugging is a good or bad thing to do
Wes
Wes
lol
I mean... there's a blog post that's titled 'why debugging is the worst habit in software development'
think about total beginners...
I think I've never been this annoyed about a generalization
Wait what is the alternative?
the author says at the beginning that he doesn't mean debugging is bad and shouldn't be used... but even the title is conflicting
he says if you're debugging you have a problem within the 'mental model' of your code
if you have a clear mental model and have tests then debugging is completely unnecessary, according to his post
07:19
@Wes thanks ...Its working now
Wes
Wes
this is another visual debt thing
@Ekin Surely not even he believes that :P
he says debugging is a waste of time, literally in the post
says also it increases the costs
can you give a link, please?
it is written in turkish, but here kurumsaljava.com/2018/03/20/…
07:22
moin o/
\o morning
@Ekin oh. well. can't read. but thanks.
yeah, if I cared enough I'd translate but... I don't see any value
but this made me see how a portion of developers think here. some people even said 'wow this should be thought in universities'
and I don't like it at all
morning
@Ekin that is an odd argument to make. even with tests and a clear mental model of what the code should do, you can have bugs.
07:27
indeed
some other arguments said you can't debug in certain environments
some confuses debugging overall with only the use of a debugger
some said if you're debugging you didn't read logs... or there are no logs
but debugging is the only fun thing about programming )))
Wes
Wes
@mega6382 masochist spotted
@Ekin I challenge him to debug a distributed system with just some tests and his mind
IMO, claiming debugging is a bad habit ignores system theory and it also ignores that debugging is also a learning tool. You don't start with a clear mental model, or rather, you might have a clear idea of what your code is supposed to do, but that doesn't mean the implementation will do that right from the start.
yes u r right
07:35
Agreed
@Gordon
the author says you have two situations where you need a debugger; 1) when writing new code (for which he thinks clear mental model and tests are what you only need) 2) obtaining already written code
2# is when he says debugging is a waste of time and resources
and that the programmer should just split the code into more readable and understandable portions
Oh, how I wish I could just download some code from the internet and immediately understand how it works
says one can add tests into it instead and add new log lines
why would I need to add new log lines? Doesn't that contradict what he says about having a clean mental model?
07:41
what a lot of crap
reading all that, I asked what he considers as 'debugging activity' but that was totally disregarded, didn't get a reply... instead he started sharing replies to him that agree on the matter
If I can step debug through the code, I get a much better idea of the code flow than by adding some log lines. I mean, step debugging is literally one log message per line of code
Wes
Wes
imho anything relying on the programmer's ability to keep everything in their mind is not going to work. also that seems a lot of effort for no benefit.. let the bugs be and fix them as they come...
@Wes he apparently also falsely assumes that just having enough tests will account for all the bugs.
Wes
Wes
lol that's never going to be a thing
08:00
solitudinarian a person who seeks solitude; recluse.
!!dad
!!uptime
Why do crabs never give to charity? Because they're shellfish.
Did you hear the one about !false It's funny coz it's true.
╔═══════════════════════════════════════════════════════════════════╗
║ [2 days, 16 hours, 18 minutes and 17 seconds] without an accident ║
║                    since [2018-03-19 15:42:40]                    ║
╚═══════════════════════════════════════════════════════════════════╝
he's lagging.
yeah there was a timeout exception
And he didn't star the either.
08:05
you can't star your own post
@Ekin No but it like pins(hollow star) the message or whatever
it is pinned?
ah it was Gordon, hmm
But it wasn't before, I think Gorden did it.
amphp/http-server is very much ready for release. Please review and report any API inconsistencies or other things you find.
6
how can you see that I pinned it?
@kelunik this should be pinned too.
@mega6382 done ;-)
ah. didnt know that.
hi why I can't run in 3v4l.org there is no output,is this under maintainance ?
is there other alternative ?
@jemz Try eval.in
It doesn't have many features, but it gets the job done.
08:18
ok thanks
@jemz Also, it supports multiple languages, so you will have to select PHP and version from the list.
ok2
I tested now my php script
I want to accept date format mm-dd-yyyy,m-d-yyyy


if ( preg_match('/^[0-9]{2}-[0-9]{2}-[0-9]{4}\z/', $date) ) {
    echo "true";
} else {
    echo "false";
}
can you please help me
@jemz why? not a single country uses that format en.wikipedia.org/wiki/Date_format_by_country
08:28
@jemz You should try to use only 1 format and a more universal format too, like YYYY-MM-DD but here is something that might help you regex101.com/r/b3naP7/1
Thank you @mega6382
Morgen
Hi, what's the difference between empty($author['name']) and $author['name']=='' as a condition when checking a submitted form?
!!docs empty
[ empty() ] Determine whether a variable is empty
08:42
@Jeeves I've read it. I'm just not sure why we do that. One guess I can make is that if the user leaves some form fields unfilled it still has the '' value. Is that the reason we use empty?!
To avoid unnecessary errors?
Empty does more than == ''.
> A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.
Wes
Wes
morgen
so in addition to doing a loose comparison it also checks whether the variable exists in the first place.
Wes
Wes
too bland? it's supposed to be an atom
@PeeHaa
you starting a religion?
2
Wes
Wes
08:47
maybe, that'll stick @PaulCrovella
manateeism
Wes
Wes
christ i forgot gordon is here
christ won't help you with that
@Gordon This is my problem. You say it doesn't generate a warning if variable doesn't exist and then you say it checks whether the variable exists in the first place. Maybe I need to know the difference between a warning and a FALSE ?
@Wes it doesn't look like an atom to me. I saw an eye encircled by a star.
08:49
i see a mix between star trek logo, a star and a rocket
Wes
Wes
as you can imagine if i actually made it look like an atom (or the common representation of it) it would look like a million logos that all look the same
nice @Patrick :D
@Patrick yes, that as well
@Wes I think, something similar might have been on USSR nukes
Wes
Wes
lol
... everyone's a critic, I know, it's terrible
08:52
It's the difference between

php > var_dump( $author['name'] == '' );
PHP Notice: Undefined variable: author in php shell code on line 1
bool(true)

and

php > var_dump( empty($author['name']) );
bool(true)

@Simon.B
@wes the star is drawn in one line, so it's a pentagram
Wes
Wes
at least it's not upside down
I know a lot of people that would prefer it to be upside down
@Gordon Okay, thank you very much.
@Wes Its not an atom thats a pentagram
@mega6382 I just said that
08:56
oh, didn't see that. :/
Wes
Wes
okay guys. i have eyes too
> as you can imagine if i actually made it look like an atom (or the common representation of it) it would look like a million logos that all look the same
but it's not that i am happy with it
@Wes now I finally get why you've been drawing squids and manatees for amp. you didnt want it to look like yet another elephpant.
Are those lines separate vector shapes? Cool that you got it to all line up nicely with the curves
Wes
Wes
it's pretty trivial to do that. it's just 5 circles
I am so very sorry @Wes. I just enjoy it too much. I don't mean it though. Really. <3 mucho.
08:59
@Wes You can try rounding the edges, that might work.
here you go, logo made easy: ✬
@PaulCrovella Yeah, now that's efficient work.
Wes
Wes
i tried 6 points star and it actually looked like a religion logo :B
Should permissions be checked before or in the service layer?
Before, in the route.
What language do you hate the most and why is it Java?
09:10
Java is fine
@Wes needs more aquatic animals
@PaulCrovella ah shit, my brain hurts. Is that perl?
your brain hurts.. that should answer your question
09:24
@kelunik Thx, fixed. Another reminder that preventing abusers is hard
Anonymous
morns
\o
pathetic
Anonymous
09:37
Any recommendations for a QR library? Thinking this github.com/chillerlan/php-qrcode up to now
Anonymous
though he/she does use tabs instead of spaces..
mornin
@JayIsTooCommon you're not indent-fluid?
3
@Leigh shit, is that really a thing?
Anonymous
@Leigh certainly not. Pure binary.
09:41
I use different indents depending on the language I'm working with... just because of general convention
PHP 4 spaces, JSON 2 spaces, C tabs, Go tabs
eeeeeew
Anonymous
fiend
I just let the IDE decide )))
Especially the two spaces are icky
Yea how do you feel about that, the engine you use to run your 4x space parsing... all of the source code uses tabs
09:43
nobody ever said they felt good about using it
09:58
@Leigh indent-fluid? that's a euphemism for bipolar, right?
@Gordon I mean, happy to talk about my mental illness if you want, but it wasn't supposed to be that, no
ambi-spacer
@mega6382 PHP Storm is the worst for that. Why isn't there a "use whatever indentation is already used in this file, and don't ask/warn me about it" setting?
@jjok because you'll run into a file that uses both and it'll have to kick your ass on principle
Whenever I see a file that is improperly indented, I press alt+shit+f to set the indentation per my configuration. )))
Anonymous
10:04
does it also remove your extra brackets?
nope, but it does format the brackets accordingly. )))
alt+💩+f
haahahhaha
/s/shit/shift
@Jeeves So, every programmer is a solitudinarian?
10:30
@JayIsTooCommon Why do you care?
Anonymous
@kelunik it was a joke centered around tabs being satan poop :)
stream_socket_get_name should enclose IPv6 in brackets – #76136
@JayIsTooCommon I guessed that, but wanted to respond either way. :P
Anonymous
:B
10:44
It's been a while since I found something in this codebase that's made me cringe so much I wanted to share it...
trait ReportError
{
    public static function staticException(\Exception $exception, array $data = null, $severity = null)
    {
        if (method_exists(__CLASS__, 'getInstance')) {
            $instance = self::getInstance();
            $instance->reportError($exception, $data, $severity);
@Leigh Then goto mars;
Trying
@Leigh but why
I didn't write it
I inherited it
I discovered some errors not being reported, and here it is, some bullshit
I mean... is there nothing in it that does anything useful that gives a hint what they were on about?
10:56
morning slabs of meat
5
o/
@tereško hello, my broccoli friend
I really don't know, because they're calling self::staticException from an instantiated object... it's actually making me angry, I now have to audit where this piece of crap is used
10:58
@Leigh At least it's self and not static.
@Leigh audit is a big a word for "right-click" > "find usages"
@Gordon ctrl+click
But then I have to visit every usage and see how it's used
oh, thanks. I didnt know you could do that
@Leigh That is for finding definition, not finding usages.
@mega6382 try it on a definition
11:06
Just found out about sudo !!, happiest day of my life. :B
:)
<?php

$error = array(
'qwerty1' => 1,
'qwerty3' => 3
);

array_splice($error, 1, 0, array('qwerty2' => 2));

print_r($error);

?>

Result is Array ( [qwerty1] => 1 [0] => 2 [qwerty3] => 3 ), how do i get it

Array ( [qwerty1] => 1 [qwerty2] => 2 [qwerty3] => 3 ) ?
@mega6382 you can also do !cat to find the last cat command etc, ! is special
@Ekin I really need to learn more about these
me too
Wasting so much time up-arrowing through lots of history ^^
@Ekin Thanks, this day just keeps on getting better. I too really need to read up on all these. :)
yeah, takes a while to get used to I guess but reeally useful
I dunno why I'm just hearing about this today
!make is my new favourite thing ...
@Arthur Try this 3v4l.org/hVrLo looks ugly but gets the job done.
11:17
You are now subscribed to ! facts
:-)
@mega6382 It does both
@Leigh yeah, @PaulCrovella mentioned it, didn't know before. Thanks
@mega6382 Thanks man!
Wes
Wes
noons
heyo o/
@NikiC Ctrl-R changed my life :D
12:09
Hello, would just like to ask, when connecting to a database to make a query, i have used mysqli_query in the past at uni, but online I also saw mysql_query, is this something new?, should I use mysql_query over mysqli_query?
!!docs mysql_query
Please, don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.
Wes
Wes
busted
@SShah consider using pdo if you can
@SShah mysql_query is the older version it is very insecure. you should rather use mysqli_query the i stands for improved. And also, I would recommend using PDO
Wes
Wes
mysql_query is the old version of mysqli_query, must not use it, it's insecure and it was removed in php7
12:12
ok thankyou, so I shall stick to what I was taught at uni which was mysqli if its still supported and secure.
Wes
Wes
yes, that or PDO
We need a clippy: "I see you are trying to use mysqli. Want to try something sane and use PDO instead?"
4
Sorry, was just reading through the PDO tutorial, its been 2 years since I last used mysqli at uni, so I dont mind using PDO, but I am still more familiar with mysqli so cant make up my mind
is PDO more secure then mysqli, or is it just simpler?
@SShah Both will do the job and both will be secure when used correctly
Ok, I guess i should stick with mysqli then, since I also still have the text book which I used at uni, to first learn it
12:21
@SShah Learning PDO will give you a familiar interface for interacting with a whole suite of database systems. php.net/manual/en/pdo.drivers.php
I know security is a major concern, and because I am doing this all on my own, is there some good resources to find out what are things i can do to better secure my db or php code, or should I worry about it at a later stage of development?
It obviously wont help with the intricacies between them, but at least you wont need to learn a new PHP API
Wes
Wes
/me is writing a simple parser. i have no idea what i am doing. if you know of simple parsers i could use please let me know
also if you want to help with suggestions please do
@Wes like a stateful parser for a DSL?
Wes
Wes
i don't even know how i should call it @Leigh i just couldn't find anything that worked
12:23
From memory, the aerys websocket parser is a decent example, I could be mis-remembering though
A generator where you send new bits of buffer, and it yields parsed messages
Or maybe it was the amp process RPC example... I can't remember, I've seen one somewhere
Wes
Wes
i need something super simple

$m = $traverser->match("/?[a-zA-Z]+");

if(strlen($m) > 0){
    $traverser->eat($m)
}
but i have no idea how it actually should work
basically just that, a method that advances n characters, and another to peek forward
or am i doing it wrong?
right now i'm tokenizing the string but it's not working well. need to advance char by char
mornin all
Can someone please tell me why narrowing return type works in PHP7.1 and is not working in PHP7.2 regardles to the example 3v4l.org/QufgA ?
Wes
Wes
here's another one :P
@brzuchal that bug is being reported like weekly
bug/missing implementation
@LeviMorrison is probably working on it
@Wes thanks, is there a bug report?
Wes
Wes
12:39
can't find it
morning
Wes
Wes
\o
\o
@PeeHaa one of the super user chats has a clippy that comes up at random... it can be annoying
Wes
Wes
we have !!comic tho
12:42
oh, right
3 messages moved to Trash
Please update config.guess and config.sub – #76137
Wes
Wes
!!comic neutral I see you are trying to use mysqli. Want to try something sane and use PDO instead?
@Wes But isn't that broken?
Wes
Wes
sure it is, it's made in php
ssl error
12:44
mixed content?
probably expired certs? @PeeHaa
PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1.
Wes
Wes
how do you use ssl and keep sanity guys
oh right
!!todo add ssl
@Wes What is this "sanity" you speak of?
@Wes goto has a time and a place, and stateful parsers is one of them
Wes
Wes
it's like all people do is making sure ssl works these days @MadaraUchiha
@Wes Actually, I use Let's Encrypt for most of my public stuff
Wes
Wes
like, you have no content but fack yes it's served over secure connection
And it works pretty great, no hassle.
12:48
@Wes I think I found it bugs.php.net/bug.php?id=75385
@Wes do you have a clearer example of what you're trying to parse?
Wes
Wes
exactly
@Leigh generic stuff, code-ish looking
like html, etc
Wait, are you trying to handle TLS inside of PHP?
@MadaraUchiha there's an acme client written in php
@mega6382 Wait until you learn about git checkout -
@Tiffany While that is technically true it has no bearing on what I asked
12:51
@MadaraUchiha ew.
@FlorianMargaine Don't you "ew." me, I'm not the one doing it :D
you mentioned it...
@MadaraUchiha is that like cd - ?
@Wes Ok, definitely want stateful. Maintain a state that is what the parser currently wants, or is allowed to occur, when you find something change the state. Your main parse loop can switch based on current state.
(only for branches)
12:57
Advanced parsers will use a big matrix of current vs allowed
@Ekin Yup
awesome, thaanks
Also works with git merge and git rebase
Wes
Wes
@Leigh dunno what that is :( i just feel that's a good way to go, it's easy to read, etc
i figured i just need ->match(regex) ->eat(char count) ->getOffset() and ->setOffset()
these two would help restoring a the state to a previous offset if i end up not-eating stuff
Not sure why you'd want to not eat
12:59
yeah, food is awesome
Wes
Wes
maybe i don't
I just had ice cream
are we on facebook again?
Wes
Wes
i read that advancing in a parser is called "eating characters"
is that wrong?
consuming input/character
13:02
yeah, you consume a stream
Wes
Wes
i read that too
"eating" is... not really common
Wes
Wes
listen, it's not that i write parsers every day
unless... pizza
@Wes we forgive you
Wes
Wes
13:12
@pmmaga lol yes
self::parsePizza($streamOfPizza)
definitely consume one bite at a time nods
... I edited a question, fixed some grammar and formatting, the author took my credit and my edit was rejected :/
It's a cruel world out there, stay here, where it's warm, and we have giant bean bags and beers
indeed
@Tiffany If you had over 2K rep you wouldn't have that problem.
13:27
@mega6382 there aren't many questions I can answer, but I can correct English.
@Tiffany It shows that you have 15 edits approved only had 2 suggested edits rejected that's not so bad.
@Tiffany You know you can earn Rep from edits for upto 2K, so you don't really have to answer questions. :)
which is what I'm doing, which is why I'm a little miffed the author took my credit, because that's rep I could use :P
c'est la vie
@Tiffany Your edit just came into my queue, should I reject it or accept it?
well, I'm biased
the "i'av" irked the shit out of me
Well, I am gonna force accept it.
13:34
Does, not returning status code in apis like 200,401 etc is good thing to do?
I can see a couple of my edits as superfluous, but they make more sense in English than what OP had. Particularly the last sentence which just repeated itself with a negative.
And i.e. doesn't mean "in example" like a lot of people think it does. It translates to "that is" from latin. E.g. means "for example."
I'm pedantic :D
@Tiffany OK, and here is a tip, when editing don't just focus on 1 thing but go through the whole thing and fix all grammatical and formatting issues, and other things i.e. removing useless text or tags. And make sure that the "Edit Summary" reflects all your changes.
Because there are a lot of reviewers who reject minor changes however accurate those might be.
Like myself, I have accepted only 196 edits and rejected 381.
@mega6382 That's what I usually try to do. There are probably a couple edits I've slipped up. I try to summarize all of my changes, but sometimes I can't think of the right word for a change I made. In the last case, some of it was grammar, but most of it I think was making the English read more naturally.
But there are many autopilot reviewers who just approve everything in their path.
Wes
Wes
3v4l.org/UkcnY aehm, why doesn't this work?
13:46
@Wes cause ^ means from the beginning.
Wes
Wes
i am using $offset
> Using offset is not equivalent to passing substr($subject, $offset) to preg_match() in place of the subject string, because pattern can contain assertions such as ^, $ or (?<=x).
Can i use mysqli to echo the default column headings in the db, with the results?:
Wes
Wes
thanks :B i feel i'm being trolled more than usual today
@mega6382 thanks
13:48
@Wes try coding in Xcode, your week will be filled with trolling
while($row = mysqli_fetch_array( $r, MYSQLI_ASSOC))
{
$name = $row['Name'];
}
Instead of having to define this, i just want it to output the whole table as is in the db, with the headings?
Wes
Wes
@mega6382 that makes the offset thing completely useless
thanks for nothing php :B
@Wes Not necessarily
> Alternatively, to avoid using substr(), use the \G assertion rather than the ^ anchor, or the A modifier instead, both of which work with the offset parameter.

« first day (2714 days earlier)      last day (2459 days later) »