« first day (798 days earlier)      last day (4153 days later) » 

9:00 PM
@igorw any relationship or strict rules derived from conventions in psr-0?
 
PSR-0 is only about class and class file naming.
 
And filesystem structure
 
Anonymous
I am trying to format with `
 
@Charles right, but there are common translations to package naming and repo naming.
 
Anonymous
9:01 PM
but not working for some reason @PeeHaa
 
Just press ctrl+k
 
Anonymous
$id = 5;
try {
$conn = new PDO('mysql:host=localhost;dbname=myDatabase', $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare('SELECT * FROM myTable WHERE id = :id');
$stmt->execute(array('id' => $id));
while($row = $stmt->fetch()) {
print_r($row);
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
 
@dyelawn Yeah, but those don't necessarily need to translate directly into a service mapper / loader name.
 
Anonymous
@DaveRandom please check it now
 
Anonymous
@PeeHaa thanks
 
9:02 PM
And please either use indentation or stop using tabs
Use spaces like real men do
 
@PeeHaa spaces are flippin annoying
 
@PeeHaa twack
 
what's wrong with tabs?
 
are we really having this discussion? if so, please call me when it's over.
 
9:03 PM
How would I prevent php code in a form's textbox from messing up the value?
 
:) Neh. I also really doesn't feel like explaining why everybody should just stfu and use spaces :D
 
would I use htmlentities?
 
nvm
 
@DemCodeLines htmlspecialchars() please
 
@dyelawn as per symfony.com/doc/current/cookbook/bundles/best_practices.html the best practice is to prefix the extension alias, which defaults to the bundle name lowercased with underscores. i.e. AcmeFooBundle => acme_foo
 
Anonymous
9:04 PM
@DemCodeLines yes.
 
@igorw i read that page twenty minutes ago. i guess i can't read
 
Anonymous
Wow, I am not the total newbie in this room anymore.
 
TABS ARE GREAT FOR INDENTATION AND CAPS ARE GREAT FOR TYPING
 
Anonymous
@PeeHaa can you help out with the PDO problem
 
@TheCOMPLETEPHPNewbie you pinged him again
 
9:09 PM
@Lusitanian @PeeHaa did somebody just say Makefile?
 
@igorw lol
 
Anonymous
I need help. @Lusitanian that is why. If he was sitting beside me, it would've been a lot worse than pinging
 
what preventative measures can one take to account for potential conflicts between bundles that do not follow the best practices recommendation for using the bundle alias as a prefix?
 
"not working" is not an error message nor a problem description
6
 
Anonymous
true
 
9:13 PM
Okay, which one of you jokers created .
 
Anonymous
Actually if the user is not getting error message, the
 
Anonymous
"not working" part can be a "problem description"
 
@TheCOMPLETEPHPNewbie No, it can not be. The description of that problem is "returns neither results nor errors."
 
@Charles Only 72 questions. If you really want to get rid of it it can be gine within minutes ;)
 
@PeeHaa Yeah but effort and I have a hangover.
 
9:15 PM
@PeeHaa I'm starting to remove them
 
use better bundles. got it
 
@dyelawn currently there are no safeguards against this. mostly it's based on the "don't be an asshole" rule.
 
@PeeHaa eh got lazy and now i don't want to continue...i got rid of 3 of the 72 (:
 
:p
 
9:18 PM
Anyone up for a Wordpress question?
1
Q: Post2Post refusing to show linked posts

Madara UchihaI'm trying to construct a catalog page, made out of products and product-categorys. I have set up both post types, and set up a connection between them in functions.php (Using the Posts2Posts plugin. The problem I'm having, is that in my catalog-page.php, I can't see the connected pages (I can s...

 
@MadaraUchiha i love things that i might actual be able to answer
 
@dyelawn Give it your best shot :)
25 reputation and a cookie awaits you
 
@MadaraUchiha why is product-category a post type and not a taxonomy?
 
@dyelawn Because I am very very new to wordpress, and I have no idea what a taxonomy is.
Can a taxonomy have its own page, with information and product listing though?
 
yes
 
9:25 PM
@dyelawn I will read about it. Consider writing a full answer (by full, I mean what's wrong with the current approach, what do you suggest, what are the advantages of your solution over the previous approach, and a short usage example).
 
register_taxonomy('product-category', 'products');
 
If you do, you'll get upvotes and glory, plus the bounty I'm planning to put on it :D
 
@MadaraUchiha good deal, forgot there was about a question and not a chat thread.
 
user1880576
Hello everyone! :)
 
Does anybody know a good resource for learning oauth?
 
@lawm The official docs
@GAD Jello
 
...for a complete newbie?
 
@lawm Run. Run far, far away.
OAuth is a brainscrew.
Especially the three-legged variety.
 
9:50 PM
@lawm Are you looking into implementing it or just using it? Also what version?
Also 2: what @Charles said. It's horrible
 
I would not unleash OAuth onto someone new to development.
 
@PeeHaa So are there any alternatives? (this is probably a #facepalm question)
 
@lawm WHat is it you are trying to do?
 
@PeeHaa Just use it for a web app or something
A 'log in w/ google' button
 
@lawm For login you don't need oauth
You need openid
 
9:52 PM
Ah ok
Whats the difference if there is any?
 
Huge giant difference.
 
user1125394
@NikiC meh this last blog article is great but endless
 
Open ID is "this is me."
 
OpenID is for using webservices to login to other webservcies. oAuth is for accessing data from webservices from another service
 
OAuth is "this is me and here is a token that you can use to access my information on this site"
 
9:53 PM
Okay thanks
 
@Charles what if i want to acquire and use all of their personal information?
 
So If I wanted to use the google drive API I would use oAuth?
 
@dyelawn You would be a super-villain?
 
But just a google login to store say a gmail email or a twitter username would be openID.
 
@lawm Yeah. However, there is almost certainly already going to be a library you can use to take care of the stupidity for you.
 
9:54 PM
@Charles Any good github links?
Or good google search queries?
 
@Charles you say super-villain, i say oAuth implementation
 
@dyelawn Taxonomies seems solid, thank you
 
ohh thanks
 
Have you given up on writing that answer? :P
 
9:55 PM
but I mean like google, FB, Twitter login
 
@dyelawn Six of one, half-dozen of the other.
 
Anonymous
@MadaraUchiha can you help me with PDO connection problem?
 
@MadaraUchiha wait wait wait. i've been typing an answer this whole time. i need those points to supplement what i'm about to give away in my own bounty
 
@lawm The same is true for all of those cases as well -- someone will have written something to do it, so you'd may as well find it. Sometimes even officially.
 
9:56 PM
@dyelawn The user has to allow the sharing of data. So if somebody allows it they deserve it
 
@TheCOMPLETEPHPNewbie I can sure try.
 
Janrain seems good
but I am unsure of relying on 3rd party
 
Janrain is pretty much the canonical implementation
 
@dyelawn =) Take your time
 
@PeeHaa "i don't have time to read this bulleted list of things that i'm giving a nameless, faceless entity access to"
 
9:57 PM
Yup they deserve it :)
 
Anonymous
$id = 5;
try {
    $conn = new PDO('mysql:host=localhost;dbname=myDatabase', 'root', 'test');
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $conn->prepare('SELECT * FROM myTable WHERE id = :id');
    $stmt->execute(array('id' => $id));
    while($row = $stmt->fetch()) {
        print_r($row);
    }
} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}
 
Anonymous
I need to separet the code from the connectino and exception

$stmt = $conn->prepare('SELECT * FROM myTable WHERE id = :id');
$stmt->execute(array('id' => $id));
while($row = $stmt->fetch()) {
print_r($row);
}
 
@TheCOMPLETEPHPNewbie, so what's actually going wrong here? That code looks fine.
... so what's the problem?
No, really.
Just separate the code.
 
Anonymous
I need this to be seperate:

  $stmt = $conn->prepare('SELECT * FROM myTable WHERE id = :id');
    $stmt->execute(array('id' => $id));
    while($row = $stmt->fetch()) {
        print_r($row);
    }
 
Is margin-top the only way to center a textbox that comes after its label?
or the text before it?
 
10:00 PM
So separate it.
There is no magic here.
 
Anonymous
IF i separet the code it won't work.
 
@TheCOMPLETEPHPNewbie Won't work how?
We agreed that "Won't work" isn't a valid error message.
 
"Won't work" is meaningless. Tell us what is actually going wrong.
 
Hello, I am trying to decipher some Zoomify code and I am a little confused. Where is fopen("php://input" ,"rb") looking for a file?
 
Anonymous
10:01 PM
I need to establish a permanent db code ind include in whenever I make queries. But, the code always has to be in the middle of the connection and the excetion.i
 
@DemCodeLines You mean verticaly center?
 
Anonymous
I have hard time seperating it
 
@DemCodeLines Unanswerable without context as we do not know your layout. Chances are you need to post a question. That and HTML + CSS != PHP
 
Yes, vertically center
 
@TheCOMPLETEPHPNewbie tell him in an ordered list of comments what your objective is
 
10:01 PM
There is nothing else in the layou
 
@DemCodeLines Have you tried vertical-align?
 
Username <input ...../ >
on the textbox?
 
@TheCOMPLETEPHPNewbie You need a ready PDO object, to be used wherever you want
So have one ready, and make sure to inject it wherever you need it.
 
@atomSmasher that is reading from the request body, or if in CLI context from STDIN
 
@DemCodeLines vertical-align is often a very misunderstood CSS property
 
Anonymous
10:04 PM
@MadaraUchiha when I used to connect with mysql I used to put the database connection like the mysql_connect in a seperate file and just include it, and it works. But, in the case of PDO I included the connection file, and it won't work.
 
@igorw ok thank you
 
People often think it would magically throw elements to the top, bottom or center.
 
Anonymous
How do I create that object?
 
Anonymous
There is NO tutorial about it anywhere @MadaraUchiha
 
@TheCOMPLETEPHPNewbie Normally
    $conn = new PDO('mysql:host=localhost;dbname=myDatabase', 'root', 'test');
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn now contains the object you need... All you need is to use it
 
Anonymous
10:05 PM
I know, but... I tried that once, and I don't know why it didn't work out. I will try it now again.
 
Anonymous
Yes, I know why it did not work. What about the exception? @MadaraUchiha
 
@TheCOMPLETEPHPNewbie You wrap it in a try/catch block, like you normally would.
It's perfectly acceptable to have several try/catch blocks in your code. It doesn't have to be a single, master one.
 
Anonymous
This is a full try and catch connection script.

try {
$conn = new PDO('mysql:host=localhost;dbname=myDatabase', 'root', 'test');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt = $conn->prepare('SELECT * FROM myTable WHERE id = :id');
$stmt->execute(array('id' => $id));
while($row = $stmt->fetch()) {
print_r($row);
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
 
Anonymous
How to you extract the

$stmt = $conn->prepare('SELECT * FROM myTable WHERE id = :id');
$stmt->execute(array('id' => $id));
while($row = $stmt->fetch()) {
print_r($row);
}
 
Anonymous
part?
 
Anonymous
10:08 PM
Because the query should always be in the middle of the connection and exception
 
DI
SoC
 
@dyelawn TLA, LOL?
 
@TheCOMPLETEPHPNewbie Who told you that?
 
@TheCOMPLETEPHPNewbie FFS, just wrap it around another try/catch!
 
The query doesn't have to be in the middle of the connection and exception
The entire point of PDO being OOP, is that you can practically do whatever you want with it
 
10:10 PM
@Charles Dependency Injection, Separation of Concerns
 
It's not procedural
 
@dyelawn Yes, I know, was making fun of the acronyms :p
 
/* s self */
 
cv-pls: Backlog (mirror) | Meaning | Chrome/Firefox Addon | Cat Content | Snippets: MySQL | Reference: Errors | Operators
8
 
@MadaraUchiha Why do you spell it Mysql, not MySQL? :-P
 
10:14 PM
* realizes one can only facepalm one's self
 
@ShaquinTrifonoff In the last 3 seconds too :D
 
@ShaquinTrifonoff mysql Doesn't deserve those capital letters :)
 
Anonymous
@MadaraUchiha what about when making a function? the $conn does not get any rources from the external db.php file
 
@TheCOMPLETEPHPNewbie In that case, you would pass the PDO object as one of the arguments
function select_people(PDO $connection, array $terms) {
And you call it by using:
try {
  select_people($conn, array(...));
}
catch (PDOException $e) {
  //Error handling here
}
Note that the try/catch is around the function call, and not inside of the function itself
You want to be able to deal with those exceptions at the right time. The function itself doesn't care whether there was an error, the one executing it does.
 
10:19 PM
try { // like everything } catch(Exception $e) { echo 'Welp, I guess something\'s broken.'; }
 
Anonymous
I understand about passing arguments, but what exactly is the array(...) part? I did not learn that.
 
Anonymous
try {
    $conn = new PDO('mysql:host=localhost;dbname=ddd', 'root', 'test');
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}



function clients($conn){

$id = "1";
 $stmt = $conn->prepare('SELECT * FROM clients WHERE id = :id');
    $stmt->execute(array('id' => $id));
    while($row = $stmt->fetch()) {
        print_r($row);
    }

	}



	echo clients();
 
Anonymous
That is the whole code.
 
Anonymous
So, what is the array in this context?
 
Hypothetical.
 
10:22 PM
@TheCOMPLETEPHPNewbie BTW, this connection code is a bit better:
try {
    $conn = new PDO('mysql:host=localhost;dbname=ddd', 'root', 'test', array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}
 
@ShaquinTrifonoff +1
 
Anonymous
thanks @ShaquinTrifonoff but, is is getting that connection inside a function is the problem.
 
I never understood the hatred for emulated prepares.
 
@Charles wut?
 
@PeeHaa Everyone's always going on about how PDO emulated prepares are horrible and should always be turned off. I never understood the argument.
 
user1125394
10:25 PM
@PeeHaa PDO::ATTR_EMULATE_PREPARES => false (above code)
 
@Charles So you don't see why prepared statements are used all together?
@cyril I know what it is :)
 
function clients($conn){
	$id = '1';
	$stmt = $conn->prepare('SELECT * FROM clients WHERE id = ?');
	$stmt->execute(array($id));
	$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
	print_r($rows);
}
echo clients($conn);
 
user1880576
 
@PeeHaa The average query doesn't need the benefit that server-side prepared statements provide.
 
The entire idea of using prepared statements is send the query to server and send the values separately to server
 
10:27 PM
@TheCOMPLETEPHPNewbie it seems like you want to "FINISH THIS RIGHT NOW" with a ctrl + c and a ctrl + v. save yourself so much time in the future by spending a little more time right now. read: en.wikipedia.org/wiki/Dependency_injection
 
@Charles You mean besides the security part?
 
@PeeHaa Doesn't matter if you've set your charset encoding properly, right?
 
if you're feeling really motivated, maybe phpunit.de/manual/current/en
 
I don't trust it really doesn't
 
Anonymous
I am new to PHP @dyelawn so, I don't have to worry about that now.
 
10:28 PM
@PeeHaa Your lack of trust isn't unfounded, given the idiocy of the GBK exploit, for example.
Maybe I'm just too used to being able to control the environment from top to bottom.
 
Anonymous
@ShaquinTrifonoff Thank you, the script worked. But, I am always obliged to pass the argument?
 
@TheCOMPLETEPHPNewbie i am new to php; i've been trying to learn for almost 2 years now.
 
@TheCOMPLETEPHPNewbie Yes yes and very yes. The alternatives are worse. Please do read up on DI.
 
@TheCOMPLETEPHPNewbie Yes, unless you use globals, which is generally frowned upon :P
 
10:30 PM
if i read those things when other people linked to them in this room, i'd be a lot farther along
 
Anonymous
Man. That will make it difficult passing another arguments for the function. Anyone knows a good link about passing arguments in PHP?
 
user1125394
next step: classes
 
@cyril He's at least 3 moths too early for that.
 
Anonymous
Why is using constants a good idea for defining database credentials?

 define('HOST','localhost');
 define('DB','ddd');
 define('USER','root');
 define('PASS','test');
 
user1125394
worse
 
10:38 PM
@TheCOMPLETEPHPNewbie it's not.
 
Anonymous
I learned it from a tutorial, but I could not quite understand it. I mean, constants can not be changed, but so is the plain script?
 
user1880576
 
@TheCOMPLETEPHPNewbie was it a lynda.com tutorial, or just one of the tutorials that copied the lynda.com exercise files?
 
Anonymous
it was lynda.com
 
Dec 16 at 19:47, by The COMPLETE PHP Newbie
I don't know which planet some of the people in this forum are from. They say SEO is a myth and lynda.com has bad tutorials?? I think, you guys have been codding to much getting detached from reality ... no offence
 
10:41 PM
@TheCOMPLETEPHPNewbie Let me give you an example.
 
user1125394
@TheCOMPLETEPHPNewbie normally you put constants in an external config file
 
You have a function, connect_to_database(); which returns a PDO object.
 
@TheCOMPLETEPHPNewbie i'll give you better videos for a mere $29.95 a month (or $10 less than whatever it is their subscriptions cost now)
 
Nobody likes templates. When everyone realized that, everyone made a language to be the "C++ done right". Now we have many languages. — Kerrek SB 3 mins ago
 
But the function fails, you get a 500 error. What can be the problem?
Is it a bug in the function? An error on your part? Can you tell?
Fact is, you can't. You can never tell without looking at the logs
If, for example, you've attempted to call that function, before defining your constants, your function will fail
And the code itself (before running it), will not give clear indication.
However, if you function looked more like this: connect_to_database($host, $database_name, $username, $password);
Things would get a whole lot simpler.
Yes, you'll need to pass in the parameters, instead of having those magical constants floating around
But then, it's very clear what's wrong when you don't pass the correct parameters
Also, you can't confuse yourself and call the function before defining the arguments.
 
Anonymous
10:46 PM
Ok, I have decided to pass in the parameters, I hope the arguments do not conflict with functions native argumnets.
 
@TheCOMPLETEPHPNewbie What the hell are functions native arguments?
0
Q: How can I get the thumbnail from a WP_Post object?

Madara UchihaI'm trying to Loop over a bunch of pages under a certain taxonomy. The looping part works great, and I get all of the pages I need (nicely wrapped in WP_Post objects). However, now I'm facing a different kind of problem. I want to include the page's thumbnail as set in the editor. I've tried any...

If anyone knows ^
 
Anonymous
Well, I pass another arguments if the function displays news from a category, I send the category type with argument like echo category('Politics');
 
Anonymous
function category($name){
$name = \\....
}
 
@TheCOMPLETEPHPNewbie Great, where are you worrying about conflicts?
 
Anonymous
So, now I have more than 1 argument to pass for category, or so it seems
 
10:48 PM
@TheCOMPLETEPHPNewbie out of curiosity, why did you change the $name parameter of the defined() and define() methods of Mr. Skoglund's code?
 
Anonymous
I am not sure how to classify and how many arguments can be passed, what to be worried for all inside the () parameter
 
Anonymous
@dyelawn define was the database, because I saw it done one in a tutorial and wandered why
 
Anonymous
 define('HOST','localhost');
 define('DB','ddd');
 define('USER','root');
 define('PASS','test');
try {
    $conn = new PDO('mysql:host='..';dbname='.ddd.'', ''.USER.'', ''.PASS.'', array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
} catch(PDOException $e) {
    echo 'ERROR: ' . $e->getMessage();
}
 
Anonymous
^@dyelawn I was asking why we needed to use that ^
 
Anonymous
As far as I think about it, the only time define(); comes in handy is when customizing error outputs for super globals like $_FILE[]
 
Anonymous
10:52 PM
I am a little right?
 
@TheCOMPLETEPHPNewbie unless the exercise files have changed (which they likely haven't, bc "psh, why pay that guy to write new files when we can just rake?") you changed 'DB_USER' to 'USER'
among other things
my question is why
 
Anonymous
That was just an example
 
@TheCOMPLETEPHPNewbie ok. it's just important that you know that changing various lines of code that you've gotten your hands on is not writing code
 
Anonymous
I know @dyelawn That, is why I embrace my name :)
 
Anonymous
on a side note, does anyone know why I didn't earn points for my contribution?

http://stackoverflow.com/questions/14006399/show-message-after-login-php/14006417#14006417
 
Anonymous
10:56 PM
I don't understand, I though I gave the best answer
 
@TheCOMPLETEPHPNewbie ok, next question: do you think you could have read en.wikipedia.org/wiki/Separation_of_concerns or en.wikipedia.org/wiki/Dependency_injection in the time that you've spent discussing this with me without a single contribution from another person in the room? (about 10 min, btw)
 

« first day (798 days earlier)      last day (4153 days later) »