« first day (955 days earlier)      last day (4009 days later) » 

12:07 AM
anyone use Yii?
 
12:49 AM
Hello, I am Galstaff, sorcerer of LIGHT!
 
@Danack seems legit
 
I cast 'magic missle'.
 
What' the errror in the following code
<?php

if(isset($_SESSION['firstName']) )
{
echo $_SESSION['firstName'] ;
}

else
{
session_start();
$_SESSION['firstName'] = "John";
}

?>
 
$_SESSION is populated in session_start(); probably.
 
i think i am not outputting anything to browser before starting new session , so that should work !
 
12:55 AM
No - you have to call session start on each page.
session_name(SESSION_NAME);
session_start();
Then read from $_SESSION
 
session_start();
if(isset($_SESSION['firstName']) )
{
echo $_SESSION['firstName'] ;
}

else
{

$_SESSION['firstName'] = "John";
}
// Or even better just:
session_start();
echo isset($_SESSION['firstName']) ? $_SESSION['firstName'] : "John";
@Cody ^
 
So I am not starting session at the top of page , That's only the problem ??
 
"$_SESSION is populated in session_start();"
There are no values in (and you can't store values in) the magic variable $_SESSION unless you've called session_start.
 
1:17 AM
Sometimes I really wish PHP had things like __toArray() and you could control object comparison with == & ===.
 
I'm having serious trouble. I need to link to an image from two different pages (index.php and admin/index.php) and two scripts (scripts/upload.php and scripts/image_list.php) using the very same URL. And I haven't the slightest idea how.
 
@Ariane just use an absolute path i.e. starting with a slash
 
I had been using DOCUMENT_ROOT, but that doesn't work in HTML img src. In the same way, PHP doesn't recognize URLs starting with a slash to be starting at the domain root
 
[img src='/images/image.png' /]
PHP isn't parsing the path - you're sending it to the users browser.
 
@Danack That works in HTML but not in PHP scripts.
as in, include('/some/url.php');
 
1:29 AM
yeah - but you're not doing include('/images/image.png'); are you?
 
Nope, but I need PHP to understand the path, because it's the same that'll be used by the upload and image list scripts for the use images in TinyMCE.
@Danack Let me show you the code that's a problem.
If I set the directory to '../images/content/', then the administrator can see the file in the editor. But when they insert it on the page, users only see the alt attribute. Vice versa is I set it to 'images/content/'.
 
Why can't you use /project_final/... ?
 
Because PHP doesn't understnad it, right?
 
../../../../ ?
 
if it works for the include files why wouldn't it work for the is_open and other file functions?
@Happyninja SLASHIES!
@Ariane You would need to separate the filename as PHP understands it, and the filename that is sent to the users browser in the img tag, but you have to do that anyway.
 
1:39 AM
@Danack It doesn't. In the includes I mostly used DOCUMENT_ROOT. Also, using /projet_final/images/content/ does worse than make the images unviewable, it crashes the plugin.
Uhm, weeeeell. How? I don't get to choose the SRC.
 
@Danack Oh, but I'm silly. Javascript!
 
@Ariane You're returning the image src via . utf8_encode($file)
. '", "'
. utf8_encode($directory.$file) ?
 
@Danack I didn't code this function, I received it from the teacher. I don't understand it fully.
But yeah, even though Javascript can do the job, it'd be nice if I didn't have to do that. This is a pretty simple matter.
 
So what you're returning in utf8_encode($directory.$file) is used as the src image path in the users browser?
 
1:45 AM
@Danack I would believe so but can't assure you. All I know is that if it's valid from the admin page's point of view, then the src becomes what I typed in the config variable.
 
Sorry I'm not being much help but let me try one more time. You've got to separate what path PHP is using for images, from the URL that users are sent.
"If I set the directory to '../images/content/', then the administrator can see the file in the editor. But when they insert it on the page, users only see the alt attribute. Vice versa is I set it to 'images/content/'."
 
Yes, I understand. But how, considering the script only sends one thing?
 
The URL should always be the same - an absolute URL like "/images/content/" (though I can't tell exactly what it should be for your setup.
This is where the script sends the value to the browser?
'["'
. utf8_encode($file)
. '", "'
. utf8_encode($directory.$file)
. '"]
yes ?
 
You know better than I. oo'
 
Well I'm guessing just send:
'["'
. utf8_encode($file)
. '", "'
. utf8_encode("/images/content/".$file)
. '"]
 
1:50 AM
I don't really understand that long concatenation
I'll try this.
 
First.
Do you understand what it does?
 
Yeah, I think. Now that you've done this.
But sadly, hope shattered.
wait, let me try twice before saying it doesn't work
@Danack
From the admin page, in the field "Image URL, there is /projet_final/images/content/cuisine.jpg (good). BUT if I check the code, still in the editor, that's a lie and the actual src is '../images/content/cuisine.jpg'.

On the user's page, it has the wrong src as well.
 
Well, if it's doing that, then it's either:
a) Caching the page.
b) Getting the value from somewhere else.
The quick one to try is press shift+F5
 
@Danack
$directory = '../images/content/'; // Use your correct (relative!) path here
That's where it's taking it from, since it's the only valid value I can put
 
but you replaces $directory.$file with "/images/content".$file didn't you?
 
1:59 AM
@Danack Yes. Maybe it recalculates it from the directory it opened?
 
I can't really tell from here. Is that code your copied and pasted in both of your scripts? i.e. is it duplicated or do you call it from a function?
 
It's called by TinyMCE
only present once
Oh, say
I think I may have an idea
Yeah, I think I can do it the barbaric way
Run a big replace on $output before it's echoed.
 
yiz
hey Jack
 
sup
 
how do i do the close vote tag?
 
yiz
2:06 AM
don't panic, I am not here to ask some dumbass perl cgi questions :p
 
@Ariane Hmm - well I need sleep anyway - but you should figure out where the ../images is coming from if it's actually still being generated, as you should understand the bug first before fixing it.
 
@Happyninja you don't have enough rep
 
@Happyninja {tag:cv-pls} with square brackets I think
 
@Jack damn
 
2:07 AM
@Happyninja but you can install the cv-pls extension anyway.
 
@Danack To be honest since I've been fighting with all this for over 30 hours in the last 48 hours, I'll go with the barbaric method.
 
It's just a tag - it doesn't do anything.
 
look to the right side of the chat >.>
 
well nn.
 
$output=str_replace('../images','/projet_final/images',$output);
Here, violent method.
 
@Ariane ah you're a frenchie :) frenchies should be sleeping by now ;-)
 
@Jack I don't live in France. Québec.
 
@Ariane me too
 
@Ariane fair enough :)
 
2:09 AM
québec != france :p
 
@HamZaDzCyberDeV no shit, captain obvious.
 
@Jack hahahahahaha
 
my boss would have said speaking like a technician: tell the obvious
 
With all the random capitals with it your name gives me a strong image of the word being electrocuted.
 
@Ariane where you from?
 
2:10 AM
how do technicians talk?
 
@Ariane I'm planning on changing it, but I need to think of a name ...
 
@HamZaDzCyberDeV Just Ham will do :)
 
@Happyninja You mean, precisely? Saguenay.
 
Ham is a cut of meat from the thigh of the hind leg of an animal, usually a pig. Nearly all hams sold today are either fully cooked or cured. Etymology The word "ham" is derived from the Old English ham or hom meaning the hollow or bend of the knee. Regional use Belgium Jambon d'Ardenne is a dry-cured ham from Wallonia (Belgium), rubbed with salt or immersed in a brine, and left to mature in a cool place; if it is smoked, wood or sawdust must be used (softwood and reuse excluded). It has the European label Protected Geographical Indication (PGI). Bulgaria Elenski but is a d...
@Jack a big NO
 
@Ariane i'm in Gatineau
 
2:12 AM
@HamZaDzCyberDeV Hamza all short does the job. Without the superfluous Z.
 
@Ariane There are 1000's of Hamza !
 
@A
What the.
@Hamza HamzaOnemoreword.
 
@Jack what's that? it's a computer
that's how tech speaks (from my boss perspective)
@Jack is there a way i could help cleaning unanswered question (i noticed there is some who can't be answered)
 
@Happyninja Define "can't be answered" ?
 
@HamZaDzCyberDeV a) it's not a question b) the user doesn't exist anymore so the question can't technically be answered
 
2:20 AM
@Happyninja I think you can flag the question as not a real question
 
@HamZaDzCyberDeV and as for the other option?
 
The mod will review it, otherwise posting a here would also maybe help
 
okay
 
@Happyninja Part b: It's a philosophical question since you can answer it but you won't get rewarded/accepted
 
@HamZaDzCyberDeV but if it can't be accepted it will roam\ forever
 
2:23 AM
@Happyninja There are so many questions that are high voted with a lot of answers but not accepted
 
If the user is gone, you could flag it as Other and then specify the reason.
but if it's a real question, you can answer it anyway :)
if not for OP it might be useful to others, especially if it was upvoted.
 
@Jack Well if a user does not exist, it does not mean we should delete the question only if it's horrible ofcourse :p
 
i'm trying to help cause SO help me a lot :)
i will keep it in mind
 
@HamZaDzCyberDeV Did you read the next two lines as well? :)
 
@Jack Yes I did sorry for the repetition ...
 
2:27 AM
in the mean time, good night everyone (10h27pm)
 
@Happyninja it's ~4:30am here :D
 
@HamZaDzCyberDeV night shift?
 
@Happyninja nope, I've got exams at 9am and I've to learn ...
 
wow
intense!
 
@Happyninja give it up, not going to happen :)
 
2:29 AM
hahahaha
 
whatever you learn at this point will fade into /dev/null
 
@Jack true story
@Jack Actually I checked the exam of last year and tried to answer the questions it seemed quite easy :)
 
that should be good enough, now go sleep instead :)
remembering stuff in the morning is a lot easier, at least from personal experience
 
Yeah you're right ...
but it's already morning xD
 
2:38 AM
don't underestimate the power nap
@ircmaxell well well well, that seems like a major improvement pull request =D
 
haha
i'm surprised that your head doesn't have dents left by your palm ;-)
 
nah, I appreciate the effort
 
love the combo of $camelCaps->lower_case() :)
 
@Jack I actually did one ...
 
2:41 AM
well, as a separate wrapper i guess the idea ain't half bad.
@HamZaDzCyberDeV shuddup, go to sleep!
:)
 
hahaha :D
got to check last things. ..
 
the good news is that the oo wrapper itself would still work in 5.5 ...
@ircmaxell btw, what's this PHALANGER thingy?
 
Well, there's no real benefit in just shoving the functions into a class wrapper. It doesn't appear that there's any actual benefit or value added other than syntax changing from password_hash() to $obj->password_hash()
 
@Jack not the code provided there
@Jack Read this: blog.ircmaxell.com/2012/11/… especially as to why it's not "oo" in the first place
 
@ircmaxell ehm yeah, i thought he just wrote a wrapper lol
 
2:44 AM
no, he tried to modify the core implmenetation
 
Making something into an object just for the sake of it being an object doesn't make sense to me.
Not everything needs to be OOP
 
Oh, LOL, I just looked at the actual diff
it doesn't change anything
it copy/pastes inside of a class
 
Nope
Just shoves it into a class
 
untested, just put it all in a class file, which will never be loaded
 
I mean, no actual benefit at all
 
2:47 AM
@ircmaxell Lack of understanding of what OOP actually is.
 
haha
 
I had a feeling when I saw the constructor have no args in his example and the call look exactly the same
That something fishy was going on
 
and define constants!
 
i guess now there's a level -1 in oop design :)
 
I hesitate even classifying it as OOP
 
2:50 AM
that's because oop levels are >= 0 hehe
 
Super namespaced functions. The function is "namespaced" to the class which is in itself a namespace
 
~super global static namespace expialidocious~
 
@Danack Announcement: It's not PHP's fault. It's the TinyMCE JS itself that changes the src's. For some stupid reason. And the code is super complicated, so I'm going to have to do this an even more barbaric way.
 
@manarth http://www.quickmeme.com/meme/3ulsuk/ LET'S CLASS ALL THE THINGS!!!
 
3:08 AM
@ircmaxell Do it, do it naow! $i = new NonNegativeProbablyImmutableNumber(42);
 
.. and there is the magical Bootstrap class
 
@tereško Boostrap.
 
Are there formal names for the left and right operands of a binary operation? (other than left and right?)
 
aren't binary operations symmetric in nature?
 
3:15 AM
so left and right doesn't really matter so much :)
 
Oh you mean operand order.
 
as in, other than their position, there's not much else to say about what they are.
 
When using session do i really need to call session_start at start of page first ??
 
@Cody doesn't that make sense?
 
Regardless, operands are defined in an order; whether that order bears significance on the operation in question, the operands are cosmetically ordered.
Read left to right, they would read left and right, but I didn't know if there was a formal definition of them, such as source and target
actor and actee, I dunno.
 
3:19 AM
@Bracketworks that's exactly my point, because binary operations are symmetric you can only call them left operand and right operand.
 
@Jack Well, since it depends on context they could be additional idioms; receiver and sender, where the left operand is a recipient of right
I dunno, I'm guessing since nobody piped in that there doesn't exist any convention beyond left and right.
 
yiz
what are :
 /var/www/robots.txt
&
/var/www/favicon.ico
 
@yiz The little machines that keep system32 working.
@yiz and your favorite icons.
 
@Bracketworks right, but the context is binary operators here, so i'm not getting your point :)
@yiz robots.txt is for search engines, favicon.ico is for browsers to show in the location bar.
 
yiz
why does my PHP script demand my favourite icon?
 
yiz
@Jack thanks
error notifications - courtesy of /var/log/apache2/error.log
 
@Jack The general context is arbitrary binary operations; the syntactic context may suggest for the sake of human understanding that one be referred to as A and the other as B, as may be the idiom.
but, rather than continue with my pedantic gibberish, left and right it is.
 
feel free to give them names ;-) i prefer using superman and marypoppins.
 
@Jack Fuck Mary Poppins. She flew by my house and broke a window.
;)
 
you should totally drop windows and use jquery instead.
 
3:29 AM
I know, I know, I didn't upgrade to jq-mary-poppins-repellant-1.0.7.js and the bitch put her boot through my bedroom window.
Doesn't matter though; I've got a 12-gauge and rock salt.
What. The. Actual. Fuck.
I search "Mary Poppins Songs", because I was going to make a funny and wanted to get one of the names right; I'm browsing the Google results, and Supercallafragalisticexpyalladosious comes on; randomly. I close the tab? Doesn't go away.
It did, about 15 to 20 seconds later.
 
imgflip.com/i/1p60v @Bracketworks
 
lol
Please replicate that for reference; it freaked me out a bit.
I feel I should take back the rock salt remark.
 
ahh, better :)
 
Asterisk?
 
nah, the extension has to be image-like.
 
3:38 AM
No, the asterisk in fuck.
 
you know that mary poppins is not PG rated right?
 
hah
 
Seriously; tell me if you hear supercalla... google.ca/…
I'm searching the network activity, I can't find it :|
 
it's in your head, that's why.
 
3:49 AM
Shit, seriously; this is messed up man.
Well, no sleep for me tonight. Better get drunk.
Going later dude.
 
I wish Reflection allowed you to dynamically create new types
 
@cspray Generate code inside .php file, include() it .... safe :)
 
@Jack Let's just say that for whatever reason you can't generate the code inside a file
It needs to be generated at runtime
 
@cspray Is there any practical reason for such a construct?
 
@Jack Yes
A library I am working on is essentially an API to allow you to configure the details of autogenerated code
Because the details are set at runtime and ultimately the final product of the API is created at runtime I need to create the object at runtime.
 
4:01 AM
Seems pretty fragile.
 
@Jack How so?
 
yiz
LOL, now I am onto automating the android push notification. Lemme C whether my luck is better this time ...
 
@cspray Just the idea of creating classes at runtime that are modifiable from the outside ...
 
@Jack Eh, this library isn't necessarily meant to be used in a production environment
But it could be used to generate code in a precompiled format, ie all the source code generated is stored in a file and that file is included unmodifiable, for production environments
 
I'm not making any judgements based on the library itself, because I don't know what it entails :)
 
4:10 AM
@Jack typesafe enums
function pointDirection(Compass $compassDirection) {
    if ($compassDirection === Compass::NORTH) {
        // do something
    }

}

$CompassEnum = $LibraryMagic('Compass');
pointDirection($CompassEnum::NORTH());
 
yiz
@Jack Can I sent an array of strings from perl cgi to PHP through cli?
 
@yiz aha! i knew it would eventually pop up again =p
 
yiz
I am not there yet ... currently automating only single recipents
but eventually I could send a bunch at a time
 
@yiz sure, just add them to the process arguments.
 
yiz
well ... will leave that to the future :p
thanks again
 
4:14 AM
@cspray Hmm, I don't really believe in public enums :)
 
@Jack Now that's crazy talk.
 
@Jack What do you mean by "don't believe" in? They're definitely real
And I think they're rather useful when you're dealing with constant data that is associated to one another
 
Sure they're real; but I feel it makes code too much aware of the individual values.
 
The code still has to work with and do stuff with the values that the enums represent, yes?
 
@Jack I don't see that; using literals I can see being a cause for code being too aware of the resulting values, but enumerations give you a layer of abstraction.
 
4:20 AM
It's like if ($direction == compass:north || $direction == compass::south) vs. if ($direction->isVertical()) ... lame example i know ...
 
I'd rather if ($code == ResponseCode::BAD_GATEWAY) than if ($code == 502) because the intent is much clearer.
 
@Jack But ultimately the $direction->isVertical() is just an abstraction of the 1st example
At some point the code somewhere has to do the check for direction being north or south
 
@cspray yeah, but you can change it behind the scenes without having to change the code that relies on it.
but once you make an enum public, you're pretty much stuck with it.
isn't always bad.
but it's a consideration.
 
I just don't see how enums all of a sudden means that you can't write expressive methods anymore
 
where username='$_SESSION['username']'

Can I get away from the unexpected '' error without setting the session variable to another variable that's not an array?
 
4:23 AM
@cspray when did i say that?
 
@Jack In the example you gave.
 
@cspray don't follow.
@Ariane you shouldn't use session contents like that in your query.
 
@Jack Do you mean there's an obvious syntax error, or is there something special?
 
@Ariane well, there's an obvious syntax error surely ... what i mean is that you should at least escape the session value, but better is to use prepared statements.
 
So, another variable?
All right, that's what I'm used to doing.
 
4:26 AM
@Ariane No, you're looking at SQL injection vulnerabilities.
 
Then what?
 
@Ariane Then, you need to utilize escaping, or better yet, prepared statements.
 
The example is weak. It attempts to prove that public enums are bad, which they might be, but goes about trying to proving it by showing an example of an expressive method call being converted into a more verbose || check. I don't get how this proves that enums cause code to be too aware of internal values
Wouldn't the isVertical() method still need to keep track of the direction currently pointed somehow?
Even if it is internally keeping track of
 
Enumerated types exist in languages to provide a construct of grouping related constants; I don't see how utilizing them is in any way bad.
 
@Bracketworks ->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)")
This?
 
4:28 AM
In PHP, mind you, since type-safe enums are a kludge, they're a pain in the ass to implement well, or really, at all; but that's a different story.
 
@cspray I'm not saying public enums are bad ... the "fact" that i don't believe in them shouldn't be taken too seriously; it's my personal habit to hide enums first.
 
@Ariane Yes.
 
Okay, I'll try to understand how to use this.
 
@cspray the difference is where that method is implemented.
 
@Ariane You'll greatly benefit from it, both as a learning exercises, and as an exercise of keeping sanity down the line :)
 
4:29 AM
@Bracketworks They're kludgey but they can be implemented...to an extent
 
Keeping sanity?
 
I don't think you could ever get to Java like typesafe enums without hacking around with internal PHP code
 
@cspray That's what I mean; and since PHP lacks native support for them, I can see how the kludged constructs can be abused; moreso at least than a native enumeration.
I use them for HTTP "constants"
 
@Bracketworks I'm not sure, is $dbh the main mysqli object?
 
    Does anyone know how i can modify my query to also select users where by total votes for a given uid is 0. Currently it only gets users who have at least 1 vote or more:

    SELECT *,COUNT(votedfor) AS ct
    FROM users
    GROUP BY votedfor
    ORDER BY ct DESC
 
4:31 AM
$stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");
 
I don't bother with type-safety at all personally; favoring final classes extending from an abstract with a final private constructor.
And then just const const const
 
Yea
 
@Ariane Personally, I"m not famliar with MySQLi, I'd opt for PDO.
 
Well, I got the itch to implement typesafe enums in PHP
for some reason, not sure why
 
PDO?
 
4:32 AM
My initial concept has been proven
 
@cspray Well, you'll be itchy for awhile ;)
 
but, like you said it has a little bit of kludge
Nah
 
If PHP supported at least __toInt, then it wouldn't be so bad.
 
Right now the only real benefit is being able to typehint an enum value as an object type
 
4:33 AM
Comparing that object within the method using the typehint gets a little more kludgy
 
@cspray Oh, certainly; huge benefit. But unboxing a primitive from it is a pain and requires boilerplate.
 
But ultimately is very much still $var === ClassName::CONSTANT syntax that people are familiar with
Eh, with the library I've explicitly stated that everything is a string
 
Ah, well then.
 
That was actually one of the very limitations I wanted to not deal with
I want __toArray more than I want __toInt
 
@Bracketworks I guess everything I need to understand for now is that it's an extension that allows an exotic way of interacting with MySQL?
 
4:35 AM
because in the end, everything is a string :)
 
@Ariane Not exotic, common ;) among other drivers at least.
 
Dunno, never heard of such a thing
 
@Jack lol it's turtle shells, all the way down.
 
but honestly at this very moment 3/4 my last 48 hours were spent on this project. I'm not quite in the "woohoo let's learn" mood.
 
I wouldn't call PDO exotic ... I would call ext/mysql prehistoric :)
4
 
4:37 AM
@Ariane 36 hours? When you hit the 306 hour mark, you'll want to flip a desk, but you still hafta learn ;)
Oh man, I finally got off a death-march project; felt so damn good.
 
@Bracketworks I think after 306 hours of spending 3/4 my time on programming I'll be in the mood for transforming into goo and disintegrating rather than flipping desks. My energy is low enough after two short nights.
 
@Ariane You can always outsource
 
lol
 
If I start outsourcing school assignments, my life is starting on a wrong turn. xD
 
Hahahaha, nevermind ;)
 
4:40 AM
@Ariane that really depends on what your aspirations are ;-)
 
Either that, or international business management will be your forte'
@cspray I just want __to($type)
 
@Bracketworks That would work
 
I'm working on a language spec and toy parser; I'm thinking inline XML literals rather than parsing modes with delimiters. Thoughts?
 
I would also like better object comparison support
 
Anyone familiar with CakePHP?
 
4:43 AM
@wali It's delicious.
 
@cspray you mean like public function __compareTo($object) magic method? :)
 
php.net down for anyone else?
Rather, the static CDN; keeps blocking.
 
it's a bit unstable i believe.
 
Eh, you're getting a little out of my league. I'm not familiar with language creation or anything like that. I'm lucky to be understanding this relatively simple autogenerated code :P
@Jack Yes
 
@cspray Yeah, I wouldn't mind that :)
 
4:45 AM
@cspray Pff, I don't really understand it either ;)
 
Ok, the wife is giving me the evil eye
I think I've sat on the computer and programmed long enough for one day
I'll see you guys later
 
@cspray Night :)
 
I need some help with CakePHP blog app
????/
 
> Discussion for all things PHP - Don't ask whether someone is here to help you. If someone is around and wants to help they will.
Just ask; someone might be able to help
Minus the magic of course.
 
@Bracketworks Eh, I don't understand.
$stmt->bind_param("i", $id)
What the heck is "i"?
 
4:56 AM
@Ariane "i" is the placeholder name in the query, such that SELECT * FROM table WHERE column = :i
 
@Bracketworks But there's a problem. There's no i in the query.
$stmt = $mysqli->prepare("INSERT INTO test(id) VALUES (?)")
this is the query.
 
@Ariane Oh, then off the top of my head I believe that will bind left-to-right on the ?
 
So I need to make my second parameter "j"?
 
@Ariane I don't think you'll need to pass named parameters via the bind_param, you can pass them via exec or execute (static.php.net is down, and it's taking forever to load the page, so I can't be for certain)
 

« first day (955 days earlier)      last day (4009 days later) »