« first day (812 days earlier)      last day (4127 days later) » 

12:13 AM
@hakre :D
 
@PeeHaa Yes, it's just that this does not work :/ ($li->xpath('ancestor::li[1]/@id')?:[0])[0]
 
Does not work hoe?
 
I got it: list($parent) = $li->xpath('ancestor::li[1]/@id') ? : [0];
I wanted to provide a default value if there is no parent id
 
aaah
 
D:\Dropbox\Dropbox\WorkNetbeans\PHP-PHP>php.bat benchmark.php
float(0.78716611862183)

D:\Dropbox\Dropbox\WorkNetbeans\PHP-PHP>php.exe benchmark.php
float(0.00040006637573242)
 
<?php

$start = microtime(true);
for ($i = 0; $i < 1000; $i++) {}
$end = microtime(true);
var_dump($end - $start);
 
for ($i = 0; $i < 1000; $i++);
@ircmaxell I always had the feeling that batch files are running more slow than exe files ;)
 
I'm gonna blame Windows instead. Clearly that's the problem.
 
I need casting in list. (no we need an AST parser for PHP internally)
list((string) $parent) = $li->xpath('ancestor::li[1]/@id') ? : [0];
 
list($parent) = (string) $li->xpath('ancestor::li[1]/@id') ? : [0];
Probably doesn't work, but...
 
12:24 AM
everyone: hello, I'm glad we're Friday. If you're in a different timezone sorry
 
There is no Friday in UNIX timestamp :P
 
got a hard week and just realized I'm off this weekend.
 
hai guys
i need help with php
basically, i want my css script to adjust the margins based oon the width of the window
 
that has nothing to do with php =P
 
12:30 AM
yes it does
 
PHP can not detect the width of the browser window.
 
ok
how about this
i want a million bocks
 
Bock is a strong lager of German origin. Several substyles exist, including maibock or helles bock, a paler, more hopped version generally made for consumption at spring festivals; doppelbock, a stronger and maltier version; and eisbock, a much stronger version made by partially freezing the beer and removing the water ice that forms. Originally a dark beer, a modern bock can range from light copper to brown in colour. The style is very popular, with many examples brewed internationally. History The style known now as bock was a dark, malty, lightly hopped ale first brewed in the 14th...
 
Are you a muslim?
 
naah .. just alcoholic
 
12:32 AM
:D
 
@javawarrior ADHD
 
he's gone already
on a different note .. the damned GCC is still compiling
 
12:48 AM
since when is it possible to add answers to closed questions?
0
Q: Tools and tips to increase productivity in PHP & JS

sharp12345I started doing PHP/JS in notepad, then moved on to notepad++, then netbeans, and later I discovered PHP debugging. Moving up the ladder through those tools have helped me allot, allot of things can now be done in less time, I can't remember how many times I have done var_dump/print_r in the mid...

I experienced that already some days ago IIRC.
 
@hakre wtf!?!?!
 
flagged ..
 
There's an intentional grace period of a few minutes post-close. You can easily just un-disable the submit button if you have a draft in progress...
 
Akvavit or aquavit (; ; also akevitt in Norwegian) is a traditional flavoured spirit that is principally produced in Scandinavia, where it has been produced since the 15th century. Akvavit gets its distinctive flavour from spices and herbs, and the main spice should (according to the European Union) be caraway or dill. It typically contains 40% alcohol by volume. Etymology The word aquavit is derived from Latin aqua vitae, "water of life." The word whisky is derived from uisge beatha, the Goidelic equivalent of this phrase. Likewise, clear fruit brandy is called "eau de vie" (Frenc...
@Charles xend frameworx is your xriend in xhx programmixing
oh, winterbash is gone. all the hats are lost :/
my sweet cat.
 
@hakre xXx?
 
1:00 AM
My new favorite word is now programmixing - best done on SO :) ^_°
 
Anonymous
@hakre i need a little help, ORDER By RAND() is not working in PDO? am i missing something
 
10
A: Doing a while / loop to get 10 random results

tereškoPlease, stop using ORDER BY RAND(). Just stop. This operation has complexity of n*log2(n), which means that the time spent on query would grow " entries | time units ------------------------- 10 | 1 /* if this takes 0.001s */ 1'000 | 300 1'000'000 | ...

 
@TheCOMPLETEPHPNewbie Which PHP version are you using? I think it's not available in all PDO versions.
(just joking, let's see if you notice that :P)
@tereško thx
 
Anonymous
i am using 5.3.5 PDO works fine, just the rand is the only problem. Is there any alternative
 
you should upgrade
 
1:06 AM
Oh lol he's ignoring the person saying helpful things
 
especially since there actually have been major update for at 5.3.6 (for PDO) and 5.3.10 (for crypt())
@DaveRandom i wouldn't be surprised
 
Yes, actually it was a joke with the version, but 5.3.5 looks moot anyway. However the SQL is independent to PDO, PDO passes the SQL to the database server, so there is nothing special with PDO whether or not there is RAND() or DNAR() or whatever you want.
 
Anonymous
i am using nokia 800 to check this site now, which means typing on the tiniest qwerty keybord ever.. And refreshing the site to chech new post. So it means i need the answer bad
 
7 mins ago, by tereško
10
A: Doing a while / loop to get 10 random results

tereškoPlease, stop using ORDER BY RAND(). Just stop. This operation has complexity of n*log2(n), which means that the time spent on query would grow " entries | time units ------------------------- 10 | 1 /* if this takes 0.001s */ 1'000 | 300 1'000'000 | ...

 
Anonymous
people i need help. There must be a rand or something equivalent. Plus, i did not know php had was that far upgraded, only started learning php 4 months ago. Now, any ideas about getting rand to work would be awesome.thanks
 
1:15 AM
@TheCOMPLETEPHPNewbie Dude, have you read that answer linked above (twice)?
 
it's actually for non-trivial case
 
@TheCOMPLETEPHPNewbie Man you must have a hard time. Check Mysql manual, RAND() should work. But as tereško wrote, RAND() is expensive and he shows alternative in answer. So take it or leave it.
 
Anonymous
thanks, i just saw it now. I did not notice before.
 
Anonymous
my god, all of that code just to get a rand?? I will just update php tomorrow. Thanks anyway
 
no
all that code is to generate a list of random results
you can find a lot simpler code example here : stackoverflow.com/a/9796879/727208 , thought it is actually extensively explained in the linked article
 
1:31 AM
A lot of the MDN docs surrounding internet standards (html, js, css etc) are really comprehensive to an almost excessive degree. So why can't they document their own internal stuff sensibly?
Also, side note, MDN is one of the least searchable sites ever
 
Is this some weird caveat that exists that I've never heard of? I use UTF-8 w/o BOM and I can set cookies fine. stackoverflow.com/questions/14167514/…
 
Nowhere close to the abomination that is MSDN, but still awful.
 
@DaveRandom Comparing it with MSDN is just terrible of you
 
@cryptic Sorry, didn't read the link. No, what that OP is saying is bullcrap.
@PeeHaa I know, I'm sorry. I shall punish myself.
 
Good you should :)
 
1:34 AM
No more beer for 3 minutes.
 
That's a to harsh punishment
 
@PeeHaa In an uncharacteristic bit of convenience, it turns out that DOM pretty print comes out in exactly the right format for the "serialised" RDF (in terms of spacing, line breaks etc) - do you think this behaviour can be relied on?
 
hi @cryptic!
lol that question about the ANSI works, UTF-8 notworks cookies.
 
@DaveRandom Sounds like that seriali**z**ed form is not entirely pulled out of somebody's ass. Whether it can relied on... I'm hesitant to say: sure trust it whatever :)
crap MD doesn't do his shit :(
Think MD is from the UK
 
1:40 AM
Yeh, he knows what he's doing
:-P
I was planning to recursively iterate the tree to output it but I'll f*ck it off for now and we'll see what happens.
 
@DaveRandom This should be no problem, it's XML.
 
Hakre has spoken! At least we have someone to blame now ;)
damn language settings
 
@hakre No it isn't. It's mozilla's ridiculous mechanism for signing an update manifest file, which is not whilespace agnostic. Which sort of makes sense because you have to be able to compare with an absolute string, but the docs switch back and forth between various xml+rdf representations, it's very confusing.
Obviously you are technically correct, but in this specific case I need to be able to rely on the redundant whitespace.
 
Can anybody help me with the following question? stackoverflow.com/questions/14166859/…
 
w00t? Are you realy sure? AFAIK there is a XML RDF representation so you should not need to worry about all this.
 
1:48 AM
I didn't know much about RDF before yesterday, it transpires there are several way to represent it in XML because it's not coupled to XML
 
@DaveRandom Please note this: Additionally there is no declaration of the namespace prefixes used. - you have them in yours, don't you?
 
Oh ffs
 
for fun's sake? :)
 
@hakre Any solutions to that that don't involve a regex replace to pad out some whitespace? I'm pretty sure that if I remove the declaration attributes from the root el that DM will (correctly) start putting them on namespaced els, hang on let me check
 
@DaveRandom Well, regex is not that bad. Here is some template code for the grey-zone, it works all pretty fine and dandy, probably extend it a little for a post-processor: stackoverflow.com/a/14094543/367456
you might want to add something for the attributes inside the tagnode. or put the starttag node apart - or both.
 
1:58 AM
@hakre Meh, the whole thing's in a container el - I was thinking just saveXML() in the context of that node and prepend/append the root el, then regex replace to pad the leading whitespace out by two places. Don't really need a parser I don't think. Unless you think otherwise?
 
@DaveRandom I just thought (quickly) because of you wanted to remove namespace attributes. If you are concerned about whitespace indenting with XML out of saveXML(), there is this answer: stackoverflow.com/a/8615485/367456
 
Ow wait hang on, the <RDF:RDF> tag is not in the serialised version anyway, I can just do codepad.org/wGMWeC80
 
And if you want to take care of the full output, there is always this way you can extend to your full needs (re-using DOMDocument as data-structure): stackoverflow.com/a/8631974/367456#
@DaveRandom Ah, now I understand. Looks like something fine, just exporting the node, not the root element.
 
Yeh, glad you looked at it though, I totally missed that little nuance
 
hey revisions also changed
 
2:19 AM
@PeeHaa How so? Not seeing any diff
 
@DaveRandom The diff buttons?
 
0
A: PHP PDO Insert Using Loop

hakreFor loops, do this (PDO or other database client libraries that support prepared statements): prepare the SQL INSERT query. bind the variables. loop your array against the bind variables, execute once per iteration. Profit. For a PDO based example on an array with data to insert into some ta...

 
@PeeHaa Wait, what? You mean like on SO post revisions or somewhere else?
 
@PeeHaa Oh duh I was looking at a post with only tag edits
 
2:26 AM
:)
 
@PeeHaa I take it the server will be running on PHP>=5.4.8 ?
 
latest stable from remi
[peehaa@pieterhordijk ~]$ php -v
PHP 5.4.10 (cli) (built: Dec 19 2012 11:45:14)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
 
transactions would be a good idea when inserting lots of rows
 
Winner
OPENSSL_ALGO_SHA512 was only added in 5.4.8 :O
 
Ah nice
 
2:36 AM
excuse me
is the winterba.sh event already gone to the upper bar?
 
@JosuaMarcelChrisano It's over :)
-16
Q: So long hats, and thanks for all the fish!

amanaP lanaC A nalP A naM AWhen I get back to Stack Overflow next week the hats will be gone, and we will be back to our normal scheduled routines. Just wanted to have this opportunity to say -- so long. Anybody want to make some hat related haikus?

 
the hats wasn't saved to my profile?
 
The hats are gone
> After January 4th, the sites go back to normal and all hats disappear. This is meant to be a fun end-of-year celebration, not a permanent addition to the site.
 
ouchhhh
Thank You @PeeHaa
 
np :)
I'm off. The booze doesn't really help with my cold. I see ya all tomorrows
 
2:45 AM
@PeeHaa lol, nice one for going to bed.
gn8 all
 
Does anyone here have fx17 on osx?
 
I am in 10th position on winterbash leader-board
 
i have an EC2 question. I setup a new instance and LAMP on that instance. I assigned an Elastic IP to that instance but I can't seem to access my web server. Am I missing something?
 
3:29 AM
@8ch8ch I think you should ask it to SF or SU
 
ok i will thanks
 
4:02 AM
body:active {
    // healthy
}
 
@ShaquinTrifonoff Hello
 
@ShaquinTrifonoff How is that chatbox so far?
 
I haven't worked on it since we last talked, sorry :/
 
@ShaquinTrifonoff :<
@ShaquinTrifonoff Can we setup the site in the new domain then?
 
4:15 AM
sure
 
Why hats? It seems Stack Exchange developers follow a Valve-styled philosophy :p
 
4:49 AM
first chat post. Hello. Stoked just hit 300 rep today.
 
@donlaur Hi
 
Trying to figure out the best way to get badges. Just get them as they happen or try to shoot for a few in mind.
 
you can do whatever. I see many people review and review to get 2-3 gold badges.
happens after 10k though.
As a new user better to figure out how to answer best.
 
 
2 hours later…
hi nill
 
7:05 AM
mornign
 
7:16 AM
How do I flag this user's PHP questions where he is asking pretty much the same thing thing in each one? stackoverflow.com/users/1944374/peter
I''ve already marked his newest as duplicate, but he's asked it 4 times already.
 
Hi AshuMehta, shall we continue our discussion here?
 
8:08 AM
i need help
i need HELP
@Charles Hey
 
*sigh*
You don't have to ask whether someone is here or can help. Just tell us your problem. If anybody can and wants to help, they will.
 
ok
<?php
include 'connect.php';

mysql_connect($mysql_host,$mysql_user,$mysql_password) or die("cannot connect");
mysql_select_db($mysql_database) or die("CANNOT SELECT DB");
while($row = mysql_fetch_array(mysql_query("SELECT * FROM usernames")))
{
echo $row['USERNAMES']." ".$row['PASSWORD'];
echo "<br/>";
}
$myusername = $_POST['username'];
$mypassword = $_POST['password'];
$myusername = stripslashes($myusername);
$mypassword=stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
 
C'mon man, read the room intro. Just do it. Do it
oh goodie, I haven't c&p'd this one in here before.
WARNING! Your code contains an SQL injection vulnerability -- you are passing raw, unfiltered, unvalidated user input directly into an SQL string. SQL injection is very easy to fix. Consider switching to PDO or mysqli so you can use prepared statements with parameterized queries.
 
$myusername = stripslashes($myusername);
$mypassword=stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword=mysql_real_escape_string($mypassword);
did you not read that?
 
Oh, there's a little "click here for more" link.
The chat is not designed for giant code dumps.
 
8:13 AM
haha :p
 
So what's the question.
 
anyway, there's only one username and password in the database
but when i run the script, it OVERFLOWS with text of the users password, and no username
 
One of those two statements can not possibly be correct then.
Either there's one row or there are lots of rows.
Pop open your table browser of choice and make sure.
(i.e. phpMyAdmin)
Or do you mean that the password is ZOMGHUGE?
 
no
there's only one
but i created it through php
 
8:17 AM
Change the line to echo $row['USERNAMES']." ".strlen($row['PASSWORD']);
How are you creating and storing the password?
 
mysql
phpmyadmin
 
Using what function call(s)?
Please don't say PASSWORD
 
huh?
i posted the code above
 
MySQL's internal password function is called PASSWORD and it's insecure as all hell.
Okay, let's rewind.
Problem: the password field is lots of text and this is unexpected
 
why like while($row = mysql_fetch_array(mysql_query("SELECT * FROM usernames"))) ?
 
8:19 AM
Correct?
 
can any one suggest best software design patterns book for php
 
@gowri you can check zend framework code
 
@gowri That's the wrong question to ask. The right question is "which design patterns are actually worth using in PHP." That's only a question that can be answered through general knowledge of design patterns and experience working in PHP. A non-trivial number of "design patterns" are silly / useless in PHP because they are designed to work around deficiencies in other languages.
 
So you are says zend framework explaines more than book
 
No, ZF just happens to (ab)use them to get the job done.
 
8:22 AM
@Charles :-p
 
ok
so here is what happens
i run this code
<?php
include 'connect.php';

mysql_connect($mysql_host,$mysql_user,$mysql_password) or die("cannot connect");
mysql_select_db($mysql_database) or die("CANNOT SELECT DB");
while($row = mysql_fetch_array(mysql_query("SELECT * FROM usernames")))
{
echo $row['USERNAMES']." ".$row['PASSWORD'];
echo "<br/>";
}
$myusername = $_POST['username'];
$mypassword = $_POST['password'];
$myusername = stripslashes($myusername);
$mypassword=stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
 
I feeling blind when some one says some design pattern for example "Observer pattern"
 
i get a 50 second delay
 
@gowri Oh goodie, Observer. Observer sucks. Link 1:
The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems. The Observer pattern is also a key part in the familiar Model View Controller (MVC) architectural pattern. In fact the observer pattern was first implemented in Smalltalk's MVC based user interface framework. The observer pattern is implemented in numerous programming libraries and systems...
 
That's why designed to learn all design patterns
 
8:25 AM
@javawarrior because you are using query in loop
2
 
Link two:
 
where?
 
11
Q: How is SplSubject/SplObserver useful?

drrcknlsnThe Standard PHP Library includes what some resources call a reference implementation of the Observer pattern, by way of the SplSubject and SplObserver classes. For the life of me, I can't figure out how these are very useful with no way to pass actual events or any other information along with ...

 
oh i see
it's better
 
@gowri You can literally type any design pattern name into Wikipedia and get a decent article on the topic. It happens that Observer is a thing I played with recently, in the form of a bounty on the question I linked. Observer, as implemented in the canonical form, is freaking useless. Congrats, today you have learned something! :)
 
8:26 AM
@NullPointer thanks it's solved
 
@javawarrior yours welcome ...
 
Oh dude, how did I miss that.
 
Thank you
 
Yeah, you really want to check the result of mysql_query. It can return true or false instead of a statement handle, and that's *bad.
 
Bye all!
 
8:27 AM
@gowri And through the power of wikipedia,
Design Patterns: Elements of Reusable Object-Oriented Software is a software engineering book describing recurring solutions to common problems in software design. The book's authors are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides with a foreword by Grady Booch. The authors are often referred to as the Gang of Four, GoF, or Go4. The book is divided into two parts, with the first two chapters exploring the capabilities and pitfalls of object-oriented programming, and the remaining chapters describing 23 classic software design patterns. The book includes examples in C++ an...
 
@javawarrior also dont forget to use pdo or mysqli instead mysql_*
 
most of them suggesting "Head First Design Patterns"
But i feel its described with java
 
@gowri head first series is worst book to read imo
 
Man, I miss the day when list questions were good.
4
 
imo?
 
8:32 AM
in my opinion
 
Thanks you saved $30
Do you have list of patterns that should i learn
 
Another problem
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/u891835225/public_html/checklogin.php on line 14
Wrong Username or Password
 
what you getting in query ?
is query success in that case i think not
 
@gowri Front Controller. Adapter. Singleton, but never, ever ever use it. Singleton exists because other languages don't have globals, and globals are bad.
@javawarrior "supplied argument is not a valid MySQL result resource" => mysql_query returned a boolean value. If it's false, then there was an error. Check mysql_error.
This is, incidentally, what I warned you about :)
 
@Charles: Thanks, I not going to use these patterns as you said. But I while i work in framework like symfony2. They used many dsesign patterns
But most of the time i can't understand from code. So each time I am going for tutorial in between my project work
IF have good idea about design patterns , I feel I can make things quick
 
8:40 AM
@gowri I think you're touching on a critical problem with that statement.
A "design pattern" is just a fancy name applied to a frequently occurring idea expressed as code.
You do not need to know these patterns like the back of your hand.
They are not going to help you in most day to day development tasks.
 
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''usernames' WHERE USERNAME='' AND PASSWORD=''' at line 1Wrong
 
user652649
morning every1
 
It's not going to be some big breakthrough. You aren't going to get some big revelation or sudden flash of understanding.
Mornin' @wes.
 
@Charles it's like that everytime
 
@javawarrior What's the actual SQL being used?
Argh, not the whole thing!
Just the SQL itself.
 
8:44 AM
i don't understand
$sql = "SELECT * FROM 'usernames' WHERE USERNAME='$myusername' AND PASSWORD='$mypassword'";
 
Yes, that.
So, there are two things to quote in SQL: identifiers and values.
They use different quotes.
Values are enclosed in single quotes.
In normal SQL, identifiers are enclosed in double quotes, but MySQL is special and doesn't do that by deafult.
However, thankfully identifier quoting is optional unless the identifier conflicts with a keyword.
tl;dr remove the single quotes from around the table name.
 
user652649
someone knows why paypal has dozens of different APIs? x.com, paypal.com... hours of reading and i still don't know from where i should start
 
@wes Half being schizophrenic, half not being able to afford breaking backwards compatibility?
Hey, that sounds like PHP!
 
YAY
It's solved
yes, finally solved
 
@javawarrior For now. You really should switch to PDO before it's too late. :p
 
8:49 AM
@Charles awesome man
idk what pro is
*pdo
 
user652649
damned backward compatibility
 
PHP Data Objects, one of the two modern ways to access MySQL through PHP.
 
i'm fine
 
user652649
@Charles do you have ever worked with paypal's APIs?
 
8:51 AM
@javawarrior Na, you aren't fine. You're learning PHP. mysql_ is going away. Now is the time to learn it the correct way, from the ground floor.
@wes Never the actual Paypal ones. Did a bit of work with Payflow Pro a long time ago, but I've forgotten pretty much all of it.
 
user652649
@javawarrior php.net/mysqli
 
mysqli is evil. Okay, not evil. Just misguided. Whoever designed the prepared statement interface is a jerk.
Mutter mutter binding by reference mutter mutter.
 
user652649
@Charles I never seen anything so absurd like the paypal's code that I'm reading
 
@wes Doesn't surprise me in the least.
 
user652649
everything is in the global scope, with variable names without any prefix
 
user652649
8:55 AM
the examples also refer to .jsp files... lol
 
Lemme see if I can dig up a thing, you'll love it.
 
user652649
dozens of engineers, and in 2013, they still don't have a proper library
 
user652649
ok.. about what? lol
 
I was actually about to post the officially recommended Payflow Pro PHP library, but upon review it's actually not too horrible. For some reason I remember it being a horror story that made me write a two paragraph rant in the commit message.
I don't like putting PHP4-era code in the ERP system that we process eight figures worth of stuff through in a year.
I think that the past month of answering questions has done something horrible to my ability to smell bad code. I'm not sure I like this.
Maybe I should just go back to fixing people's bad tagging.
 

« first day (812 days earlier)      last day (4127 days later) »