« first day (405 days earlier)      last day (4526 days later) » 
00:00 - 14:0014:00 - 00:00

12:00 AM
From what I understand from your question you want to dynamically fill your catagoryData array rather than manually adding items to it
 
lol yeah but as mentioned... i go to bed now... and my question will be tomorrow realy far away,no one will then read it anymore if i not ask it good now
@w
@Willempie yes/ja
you also understood it should query as multilevel, and build an array from that?
Theres someone in javascript room ... thanks for your time Weltrusten @Willempie
 
I think I now understood how that foreach thingy works
Took quite some time ^^
 
Care to share?
 
5
A: Why does PHP's foreach advance the pointer of its array (only) once?

NikiCRight before the first iteration the $array is "soft copied" for use in foreach. This means that no actual copy is done, but only the refcount of the zval of $array is increased to 2. On the first iteration: The value is fetched into $x. The internal array pointer is moved to the next element,...

 
12:17 AM
So php suddenly has to hard-copy $array to keep the foreach alive while already inside a foreach iteration, I'm suprised the foreach didn't simply break on that. Oh, the more you know ...
 
I wonder why current needs the var by ref
 
nl.php.net/manual/en/function.current.php#37917 seems to have some thoughts on that
 
anyways, good night now
 
Cheerios
 
 
1 hour later…
1:51 AM
anyone know how to use cURL with wildcard?
 
2:16 AM
@skeith what are you trying to do ?
 
downloading multiple files which had similar names
like example.com/2011/11/24/page001.jpg
it contains up to 30 files
 
@skeith that is not possible but you can iterate for sure.
 
i've told by my friend to use for($i=1;$i <= 100; $i++)
but still feel dumb :(
 
you don't have to feel dumb, http/tcp doesn't has support for wildcard your request should be specific.
 
so i should use curl multi handle
 
2:23 AM
I am not a curl grue, in fact I have never use it in production.
 
I'm looking for a highly lightweight template engine in PHP, any suggestions?
 
@Incognito PHP.
 
:P.
 
A little less light-weight.
 
2:23 AM
:D
 
@OmeidHerat anything will do, don't have to be curl
 
@Incognito what do you want ?
 
i also heard it can be done with bash/cron
 
<?=$someDataToBeEchod ?>
<?php if($test): ?>
...a bunch of crap here
<?php endif; ?>
 
@skeith You can probably just file_get_contents('http://www.example.com/file{$i}.jpg') if it's just to get the images the one time.
@OmeidHerat I have a site such as imgur.com/hcHRg here
Some pages will have long lists of boxes, others will not, all pages will have the descriptive blob to the left.
There will be a case where the four small boxes are one larger area for text.
I'd like a tiny bit of mutability without going over-kill.
I'd like to not write my own classes ground-up to not go over-kill.
 
2:32 AM
@Incognito wait, I will write something simple for you.
 
I was looking at smarty but it feels too big for something this easy.
 
what is exactly a php templating engine?
 
@skeith Basically lets you worry less about mixing your HTML with your PHP, and re-use a lot of your HTML. It lets you be lazy and helps you maintain code.
 
@Incognito Look it's simple, you don't even need a template engine just put some place holders in your template file, say __BOX_AREA__ and load the template and replace with what you want (which is of course created dynamically) and then output it to the browser.
str_replace() is your friend,
 
so
it is like shortcode in wordpress?
 
2:36 AM
public function getPage() {
return str_replace('__BOX_AREA__', $this->boxarea, $this->html);
}
 
RPM
CLL uses so much less memory than browser its crazy
 
@OmeidHerat That could work, but what do I do with things where I might have long lists of boxes? Just dump HTML files and forget the database?
 
RPM
I have a bash script executing almost 40 different scripts from 1 script in the command line
 
@Incognito look, you can create the 'boxarea' data from where ever you want and however you want.
so why not use a database ?
 
Oh I see what you're saying.
That makes a ton of sense.
 
2:39 AM
:D
 
Alright thanks man.
 
np.
 
@OmeidHerat can you suggest me how to do a filetype filter on an upload form
i tried with reading first byte of the file
i don't know if it good
 
@skeith it really depends on what you want, the first thumb rule is that think as if every user is trying to hack you.
Never trust user.
 
i allow user upload file, but only PDF
 
2:45 AM
So I wouldn't even care for extension, though it's a good thing for client side validation with JS.
 
however we can't sandbox user to choose only pdf file on the upload dialog box
well, the possibility of "naughty" user is small, but better than nothing
 
@skeith why not ?
 
i've told that we can't interfere with user's system through the browser
 
I'd honestly read all the links in the reference section here.
 
2:49 AM
Oh I see what you mean, no you can't trust user. but at least for sake of user User-Friendliness
@skeith no you can't, but you can always check the inputs value and stop user from submitting a form.
 
at my first attempt, i can still upload a php and execute it *FAIL
@Incognito what if user rename a *.exe file to *.jpg will that be a problem?
 
@skeith Filenames are nearly meaningless to a computer.
If the binary data is an executable, then there's an executable on your server.
Ensure it can't be executed.
 
what Incognito said.
 
Sometimes you can examine a file and do a sanity check on it, for instance, an EXE won't parse as a JPG.
 
You should always keep in mind, that Filter-in is not enough you should also filter-out.
 
2:54 AM
But there's exceptions and ways to smuggle stuff.
@OmeidHerat You know, nobody ever does this. It amazes me.
Lots of effort to ensure sql injection can't happen, no effort to ensure they aren't putting malicious JS onto a site.
 
ah
malicious JS?
 
@Incognito I know right, it's like no guards at the exit.
 
Scripts that steal cookies or whatever.
 
or redirects. my fav one ;)
 
Well the big one is editing forms that ask for personal data to send to malicious servers.
 
2:57 AM
social engineering
 
@skeith And also, never ever save the file same name as user, at least prefix or suffix it with some Hash.
 
lot's of that kind of emails on my spam box
 
@OmeidHerat Came in handy before for me, I have a third-party site we do business with that said they couldn't fix something (remove an image) for 4 months, which wasn't good enough because my customers went there... so I just went good old document.getElement...
 
@OmeidHerat wow, i never thought about that
 
@skeith Nope, social engineering is Scam. XSS is Hack.
 
2:59 AM
Sometimes XSS will do social engineering, zuse-bot is famous for that but it's more like HTTP injection
 
i've met a site which allow us to input negative values even before we hack them. so my purchase is free LOL
 
@Incognito haha, good one.
Social engineering is commonly understood to mean the art of manipulating people into performing actions or divulging confidential information. The people who need to hide their crimes say it is similar to a confidence trick or simple fraud, the term typically applies to trickery or deception for the purpose of information gathering, fraud, or computer system access; in most cases the attacker never comes face-to-face with the global criminals/victims. Accusers say "Social engineering" as an act of psychological manipulation was popularized by hacker-turned-consultant. Global criminals ...
Such a a controversial term.
 
@skeith I've seem stuff like that, except you input 0.1 items on the purchase line, 90% discount, but people on the packing line see "01" and just put it in the box.
 
but i never do it, does not worth the goods
sadly store with good goods is so secure LOL
@Incognito about file_get_contents('http://www.example.com/file{$i}.jpg') that you mention before, does it work one by one?
 
@skeith HTTP only requests one resource at a time.
You would wrap a for loop around that.
And write the file contents to disk somewhere.
 
3:09 AM
can't we use iframe? to multiply the request?
 
What?
PHP doesn't run in the browser.
Iframes don't exist outside of the browser.
 
so the page will still loaded untill all the images is downloaded right
 
@skeith I don't know what you're trying to do any more.
I thought you were downloading 30 images?
 
like this site of mine > get.suyalynx.com
perhaps i was mistaken
what i think is, if a download php script is running and opened in a browser, we cannot close it
still confused :(
 
Eh, I'm not clicking anything :P.
Describe what you're doing.
Because downloading 30 images, and displaying 30 images are two different things.
 
3:16 AM
i assure you it is safe
downloading 30 images to my server
then merge all of them to a single PDF,
 
You can run PHP from the command line, the website never needs to be part of it.
 
when done, delete the images
so it will be a cron job?
 
No, I mean you can just type in php foo.php
 
how can you run PHP from the command line?
from inside Windows or UNIX?
 
I like to use php foo.php -l to run lint.
It works in both.
 
3:19 AM
how can it be accessed from Windows cmd?
 
i use cpanel, wher can i execute that command?
 
uhh
This is something you can probably look up in the PHP manual really easily.
like, "how do I run php"
 
alright, thanks
 
aight, I have to go.
Peace out.
 
uhhmm, so i need access to command line
thanks @OmeidHerat for your help
 
4:09 AM
I have the following line of PHP code:
$statement = $sql->prepare('INSERT INTO tu_owners (full_name) VALUES (?)');
It's not working - $statement is bool(false) after executing this line.
...but $sql->error is reporting a blank string.
How can I find out what's wrong?
 
what is $sql?
PDO? MySQLi?
something else?
 
It's an instance of MySQLi, sorry.
I kind of forgot to mention that :)
 
do a var_dump($sql->errno);
 
int(0)
 
huh?
 
4:13 AM
I know - weird, huh?
 
after the prepare statement, sql->errno is 0, and $statement is bool(false)??? wtf?
 
Yup.
Not only that, but other queries on the table are succeeding.
 
that makes no sense
 
This one succeeds:
$statement = $sql->prepare('SELECT id FROM tu_owners WHERE email = ?');
...but not the INSERT.
 
odd
 
4:18 AM
WOW - guess what happened...
$statement => $statement2
...and now it gives an error.
 
lol
 
string(52) "Commands out of sync; you can't run this command now"
We're making progress :P
 
4:41 AM
Seems I have to call close() on a prepared statement before I can create another one.
 
4:52 AM
How do you keep SQL seprate from PHP ?
I know there is a few question in SO but none of them has a real answer, and I am not really thinking of ORM, just not my thing.
@ircmaxell, any thoughts for my question ?
 
i have array structure like this Array ( [imagename] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [x] => Array ( [0] => 13 [1] => 44 ) [y] => Array ( [0] => 33 [1] => 22 ) )
how could i print it using foreach loop
 
@Hira for what purpose ?
 
it is in $_POST i want to get image name then its respective x and y
 
foreach($name_of_array as $group) {
    echo "Group $group<br>";
    foreach($group as $key => $value) {
        echo "- $key => $value<br>";
    }
}
@Hira How about that ------^
...though it's essentially duplicating the functionality of var_dump().
 
ok wait let me try it
 
5:05 AM
Don't forget to substitute $name_of_array for the actual array variable :)
 
ok
@GeorgeEdison thanks its working
 
No problem.
@Hira Take time to carefully look over the code so that you understand what it does.
 
@OmeidHerat Honestly: create an API. You might be thinking, what? But it's simple: with an API, you have a single entrance to your database information that is abstracted from your normal code. Sure, inside of the API you are integrating PHP and SQL, but when you are using it, there's no indication of the technology behind it
Consider:

$api = new ApiConnection($version='1.0');
$api->user->create($name='Omeid', $email='omeid@host'); //returns the id of the new user.
$api->user->removeId(1234);
Etc
My example is just not well refined, but it gives you the idea.
I like to have api.example.com/$version/ . . . and just use HTTP calls.
 
5:29 AM
@LeviMorrison Thanks, that is a good idea. I think I will just extended the PDO.
 
6:18 AM
wow
awesome thanksgiving
 
6:31 AM
I always wonder where should I initialize my private fields, I declare them in the class definition, but I am not sure if I initialize them in ctor or at the definition itself (of course, the default value variables go inside ctor, but what about those without any defaults ? )
 
6:45 AM
Can anybody help me with an ajax/php problem?
 
6:59 AM
@Howdy_McGee read the chat room description (BTW, I don't know much about ajax)
 
7:42 AM
okay, that's a really dumb description, honestly.
it's worthless to post our question if nobody's going to help.
it's just somebody's dislike of messages like that manifested into a "rule" of sorts...I don't get it
 
 
2 hours later…
9:52 AM
Morning
 
yay'
 
10:04 AM
@Purmou its not a dumb description. people usually come in here and ask things like: "can i ask something" or "can someone help me with ajax" or "anyone used X before" which serves as some kind of introduction and polite but basically unnessary.
 
@Gordon But still...I'm not going to post my code and give it to the public (or registered users, at least) if nobody's going to help with it
"can i ask something" is something i don't want to see
but stuff like "can i get some ajax help?" and "anyone used x before?" seem like legit questions to ask
but eh, not worth complaining
 
@Purmou id argue if you are concerned you give your code to the public, you should not ask here in the first place
 
@Gordon sometimes it's a really urgent matter...I've been so quick to post a question on SO that I forgot to omit my database information
just as an example
 
@Purmou doesnt convince me :)
 
@Gordon fair enough, but don't you still think that even if it's unnecessary, it's worthless to say "look at the description" if someone comes and asks a question like that?
it's not hurting anybody at all, what's the point?
it may be unnecessary, but it doesn't really make a difference
 
10:18 AM
do you want to compete in weeklies ?
 
what the hell?
you're so kind, thank you.
 
Morning!
 
@tereško that was completely unneccessary
 
can users be punished for chat messages?
 
@Gordon Sadly it's true sometimes.
 
10:22 AM
he is trying to legitimize question like "can someone help me with php?" and "is anyone here?"
you cannot be nice about this
 
I'm off swimming.
 
i'm glad to be part of a community where opinions are treated rudely
 
cu later folks.
 
@Gordon Maybe not regarding PHP, but for example JavaScript. Some user with 21k rep. answerd, but not completely and now question is still open due to him, since there is no certain answer.
 
@tereško of course you can, YOU just can't
you're obviously somebody with respect for others' opinions
i'm only 14, cut me some slack
 
10:38 AM
i suspect that you meant to say ".. with no respect .."
 
@tereško nope, it was sarcastic
 
Updated PhpStorm IDE yesterday with new EAP and interface changes are great.
I hope they will leave it for the RC and official release of PhpStorm 3.0.
 
i have been playing around with Sublime Text 2 editor .. not an IDE , but it is pretty nice
 
@tereško Ignoring me now? psh
anyways, good night everyone
 
10:56 AM
Well I think you will like PhpStorm if you never used it and are planing try out.
 
i did try it
i like my save buttons where they are , thanks but no thanks
 
Currently playing with Netbeans, but I'm not really sure I like it =/
 
heh , my primary IDE is Titanium ( previously named : Aptana ) but i do not recommend it to others .. it has a lot of issues
 
Never even heard of it :D
 
i would really love to see an IDE which can give me a reliable JS autocomplete
 
11:02 AM
241
Q: Good JavaScript IDE with jQuery support

Pop CatalinI'm planning to start learning jQuery (among other things), so I'm looking for a good Javascript editor that can preferably provide some of the following features: Syntax coloring Contextual help for standard JS functions, jQuery functions and possibly custom ones Some code completion (optional...

But it seems to favor Aptana, which you don't recommend :D
 
i do not us jquery
 
Surely if it works nicely with jQuery it has a good underlying support for vanilla js??
 
@tereško And WebStorm/PhpStorm don't do it?
 
here is example of the code : pastie.org/2918786
it is a work in progress and has one very annoying bug at the moment
@Eugene , how does *Storm handle it ?
 
@tereško One moment I will test.
Played now with session_set_save_handler a bit and found, that documentation can be better, then it is now.
 
11:08 AM
i can add html and css too if you want a live example
 
@tereško It looks fine in storm? What should I try out to express my opinion?
You need a screenshot of some lines?
 
line 53/55
can you reproduce the toggle() method in autocomplete
( if it hasn't already ones been executed on the object )
or any other of Select objects methods , @Eugene
 
Back to session_set_save_handler I have to say, that this is odd. When I started session with session_start it called callback $open , callback $close , callback $read , callback $write. Shouldn't it call only open and close? And only when there is a need to get some data from session or place it there, only then call those functions/methods.
 
anyway , i'll be AFK for something like an hour soon
you could for example try and see if on line 53 you can see populate() method for the current object , @Eugene
if you cannot , then autocomplete is failing
 
@tereško One moment. Uploading two pictures.
Did I do like you asked?
 
11:20 AM
yes you did
 
@tereško Also have you any idea about my question with session, that I added here?
@tereško And how do you feel about PhpStorm now? :)
 
first shot indicates that autocomplete is guessing by just showing all the defined methods
and second shot is fucked .. ther eis no jquery anywhere in code
 
Ou. That's probably my library so it takes also what he sees from there two.
Autocomplete is global.
 
anyway , i g2g , i will be back in an hour , then we can continue
 
@tereško Okey. See you later, but I think from first ss I understand what you mean.
Would like to chat with anyone who has any ideas/knowledge about how session_set_save_handler works and about calling of functions/methods, that are passed to it.
 
11:36 AM
super happy to use VIP (vim plugin for PHP) , creating docblocks is so much fun now ! but can someone tell me how to use/document @throws tag ?
and any general guidelines for short description of methods ? I sincerely believe that my method names are self descriptive but nevertheless I would like to get into habit of writing docBlocks (so that later on I can skip writing one intentionally )
and do I need to document both my interface and the actual implementation ? (e.g. docblocks for methods declared in both IBuilder and DbhBuilder )
I mean seriously do I really need to document my interface too ?
Hmm after reading this I think I might just skip my interfaces for now and document the implementation, skip @throws tag entirely , I don't feel so excited about typing so much obvious (and I know I am wrong/will be proven wrong)
 
12:04 PM
should I document class consts? how about namespace consts?
 
12:17 PM
I feel stupid documenting my __construct() . The documentation task is turning out to be rather too boring !
I want to hear your opinions/discussion my friends ! where art thou? @Gordon @tereško @Eugene @edorian @ircmaxell
 
12:34 PM
hi everyone
i have two session id's in a single php script. can someone please tell me how to make a specific session id useable ?
 
@hussain session_id ( and_id_goes_here )
 
@hussain what do you mean? Use one session after the other? Copy over session data?
 
1:00 PM
@hakre I think he is gone :)
 
Hi
 
@Sudhi your constants should be named in a way that dont need explaining
@Sudhi documenting a ctor is pointless in most cases
 
@Gordon ohhk, thats taken care of const/ctor , what about @throws tag ?
as of now, I have two types, LogicException and RuntimeException , former is clearly error in programming logic, RuntimeException happens (almost all of the time) when database related exceptions occur
 
@Sudhi I always document @throws
 
@Gordon even when the params are wrong/missing?
 
1:10 PM
@Sudhi huh?
 
//how about following method of my \Rednaxela\Processor\DbhBuilder class ?
public function getProcessor()
{
    if($this->_proc == NULL) {
        throw new LogicException('Processor not yet built!');
    } else {
        return $this->_proc;
    }
}
 
/**
 * @throws LogicException When proc is null due to unfinished feature
 * @return Processor
 */
 
//and how about for something like this
function foo(array $arg)
{
    if(!isset($arg['bar']) {
        throw new LogicException('Missing option bar');
    }
}
 
Hi guys got a quick question lets say I've got a large array all with different keys and values. Now I have a key and I can get that value really easily.
Now I want to get the next and the previous values and keys - how would you do that?
 
//something like this is acceptable ? @Gordon
/**
 * @throws LogicException When option bar is missing
 */
 
1:18 PM
@Sudhi yeah
 
I'd rather not pass in an array with arbitrary keys there
 
ohhk, and what about the feeling of stupidity that I am getting when documenting methods like Builder::buildProduct($productId) ?
 
If it needs 4 values out of arg give it the 2-3 values as params. Else think about a configuration object or something
 
@edorian can you elaborate ? I did not understand configuration object, whats that ?
 
ehh .. got suspended today for :
> yesss , you have won the "Stupidest statement of the day" award
in response of :
6 hours ago, by Purmou
it's worthless to post our question if nobody's going to help.
 
1:22 PM
@tereško I refer them to chat room description
 
that guy was defending people who enter channel and start with "can anyone help me with php?" question
 
Hi, any ideas, on my problem?
 
@RichardHousham is your array associative or indexed ?
 
associative
Looks like this is my only option
http://stackoverflow.com/questions/4792673/php-get-previous-array-element-knowing-current-array-key
but it has a while loop that looks rubbish
 
you want next
 
1:24 PM
@tereško seriously, the suspension was well deserved. you outright insulted him for nothing.
 
yeah. I do - but I need to set the array internal pointer to my key and that's the trouble
 
@RichardHousham the accepted solution tells you how ! while(key($array) !== $key) next($array);
do read the complete solution, there are loop holes and corner cases
 
Quick performance question, guys. I'm receiving data from twitter's streaming API, let's say about 1 tweet per second at busy times. I need to store some of these tweets in a MySQL database. Would it be better to store the tweets in an array and add them to the database as a bundle in a single query, or would it be fine adding them 1 at a time immediately as they come through?
 
ah right, I think I see some fingers crossed they will help.
Cheers
Richard
 
@AndyE 1 tweet per request?
 
1:30 PM
@Gordon : and what about interfaces ? How do I go about documenting them ? I wonder if you have looked at my pastie yet , you might want to look at the way i use IClassType and ClassName implements IClassType
 
@AndyE 1 query/s should not matter
A normal sized mysql should be able to easily work with 10k requests per second
 
@Gordon this is a background process running alongside a webapp. I'm just worried about adversely impacting the main webapp.
 
@Gordon Can you show @Sudhi a sample for a $options class. I don't have a link handy. Something 10 method parameters => one object
@AndyE If it is a innodb table (which i assume it is) the write overhead and the locking time of one tweet will not hurt you
 
@edorian ok, thanks :-)
(it is InnoDB)
 
@Sudhi I like to document interfaces like regular methods: github.com/gooh/InterfaceDistiller/blob/master/src/Distillate/…
@Sudhi and then put a @see for implemented methods: github.com/gooh/InterfaceDistiller/blob/master/src/Distillate/…
@AndyE what @edorian said
 
1:34 PM
thanks, guys, I feel a little better now.
 
@Gordon aha! the @see looks great, I would rather document the contract than an implementation
and how about the $options class that @-edorian was talking about ?
 
Not the nicest sample but it should do
 
@edorian thanks a lot ! thats one great website , Used it quite extensively to refactor a 1.5k LOC program
well, I think I can extend the concept if I understand it thoroughly :)
 
happy friday
 
damn i cant decide whether i should buy LA Noire now or wait til it gets even cheaper
 
1:50 PM
It's pretty cheap right now, why bother waiting?
 
@edorian well, I get the idea, but the array type acts like $options object because of typehinting in method signature. I will have to check for arguments somewhere, moving that checking to outside the method/class seems bit odd , and the class wouldn't be extensible anyways, will it be ? e.g. ...
 
@Willempie because i still have plenty to play and when im done with those it might be even cheaper
 
sorry, can't think of anything, I am still confused, perhaps I didn't get the idea completely
 
whats' everyones 20% projects?
 
github.com/edorian but atm mainly PHPUnit
 
1:54 PM
@Gordon well, I guess if you want to finish your current games before going on to a new thing, you can wait. I personally quite enjoy having multiple game options to choose from.
 
hmm, time to go home guys, will come back soon in ~1 hour
 
@Sudhi Ok, later. I look for a nicer link
 
@Willempie guess I'll wait then
 
0
Q: __autoload fails to throw an Exception when it fails to load a class on a static method call

WillempieWhile attempting to implement some kind of error handling when my __autoload() function fails to load a file I stumbled upon this little 'oddity'. According to http://nl.php.net/autoload Exceptions thrown from within the __autoload() function can be caught in a catch block since PHP version 5.3+...

Mighty overlords of the PHP world, please help me find a solution that doesn't use eval() : (
 
don't use __autoload, use spl_autoload_register
 
1:58 PM
Will spl_autoload() throw Exceptions on a static method call if it fails to find the file where the class is defined ?
 
Just as a general statement. Not sure that solves your issue :)
Generally you don't want your autoloaders to throw expections because you can have multiple ones and they should play nice with each other
 
@Willempie I have problems to actually understand your issue.
 
But I need to play around with that to see what happens
 
00:00 - 14:0014:00 - 00:00

« first day (405 days earlier)      last day (4526 days later) »