« first day (1564 days earlier)      last day (3381 days later) » 

1:10 PM
Laravel question:

I want to show a result in my admin.blade.php

This is the controller code:

$results = DB::select('select * from codes where code='. Input::get('code'), array(1));

return View::make('admin')->with('results', $results);

This query gives only 1 row.
I only want to show the 'name'column. How do I do this? Im a big noob at laravel btw.
 
@Loko You should use prepared statements
 
@Loko ow god
 
welcome to the 21th century
 
lol
 
where did you find that code?
 
1:12 PM
Laravel tutorial
documentation of the website
 
link?
 
what version of laravel?
 
 
@Loko Please take another look at laravel.com/docs/4.2/database#running-queries
see how it uses ? and passes the corresponding values in a separate array
 
It says $results = DB::select('select * from users where id = ?', array(1));
 
1:13 PM
do that, instead of directly putting stuff into the query
 
yeah back to your problem: $results = DB::select('select * from codes where code= ?', array(Input::get('code')))->pluck('name');
 
^-- that
 
aha
Ok well thanks
lol
ow now I see
 
this probably has nothing to do with your actual problem, but a good habit to get into, otherwise your site will get hacked.
 
Yeah I thought it was completely different
Yeah but can anyone help with the problem btw?
 
1:15 PM
yeah back to your problem: $results = DB::select('select * from codes where code= ?', array(Input::get('code')))->pluck('name');
I suppose... I'm not using laravel ;D
 
Or just DB::select('select name from codes where code= ?', array(Input::get('code'))). Can directly take only name in SQL.
 
Yeah but how to show it on the page?
 
well, what are you currently doing to show it?
 
It's not as easy as php normally right?
Nothing yet
 
@Loko have you already created that admin view you're using like described in laravel.com/docs/4.2/responses#views ?
 
1:20 PM
@NikiC yes
 
and what does it contain?
 
@extends('layout')

@section('content')
<h1>Admin page</h1>
<p> Welcome </p>
@stop
 
okay, so add a foreach loop there that outputs $results
 
@MarcelBurkhard please, don't use singletons
 
Shouldn't foreach only be used when it's more than 1 result?
 
1:23 PM
ah, if it's just one row, then you don't need to loop, yeah
 
yeah
so: {{ $results->name }} ?
 
probably $results[0]->name
 
Yup
that worked
thank you very much
 
you should probably also add a check for the case where $results is empty (i.e. wrong code was provided)
 
if (!$results->isEmpty())?
gives me an error
 
1:34 PM
if ( ! $results)
Would probably suffice.
 
@DejanMarjanovic Dat whitespace...
 
@Loko if (!empty($results)) or what @Dejan said
 
@NikiC Thanks... Im just thinking way too difficult.
@NikiC 1 more thing btw.

This is my if statement atm:

if (!empty($results)){
return View::make('admin')->with('results', $results);
}

But if the array is empty I still want it to show the View but I dont want the array to be shown at all.
 
@Loko then you probably want to move that if into the view
 
1:40 PM
but lets say in the future i want to use some things in the controller only when the array is filled.
I have to have keep the if in the controller then
@NikiC :P
 
in that case you'll likely just have it in both
 
lol
 
but given that this is probably an error condition, you may want to redirect & show an error
 
@NikiC Thanks that works :)
 
@NikiC stop wasting time, is what @tereško thinks :-P
 
1:47 PM
close enough
 
huh, just found a method called foo in this codebase ... and I added it. Guess that's what happens when you think "I'll rename this in a minute"
 
:P
Temporary permanent solutions!\o/
 
$ php --rf foo
Function [ <internal:standard> function foo ] {

  - Parameters [1] {
    Parameter #0 [ <required> $bar ]
  }
}
so... that was you...
 
@NikiC As my PM always said, there are no things more permanent than temporary solutions.
 
2:04 PM
wait… already 19 replies…
 
just let it stew for now ^^
and then lets see if we can get half the votes ^^
 
my current plan.
okay, sent one mail…
 
@tereško http://chat.stackoverflow.com/transcript/message/21192531#21192531

Not my fault :P That comes from Laravel...
 
maybe you should reflect on that for a moment ...
 
I don't use laravel
Just tried to help loko
 
2:14 PM
oh!
 
But Dericks reply somehow was amusing. Just a short "Absolutely not." as it it were just for his emotional attachment.
 
@bwoebi Are you talking about the removal date.timezone warning?
 
yes
 
Link to discussion please (I'm not subscribed to internals anymore)
 
2:19 PM
ty
@bwoebi The very existence of a .ini file to configure the language baffles me
 
And the "I can't guess the default timestamp" is utter bullshit. Node, python, ruby, and any other web language manages just fine
 
hi guys
when i am posting html data to xml and parsing to a url by using the below code
<?php

if (isset($_POST['lsr-submit']))
    {
        header('Location: myurl');
    }

I am getting the "HTTP Status 405 - HTTP method GET is not supported by this URL"
any idea why it is comming please let me know should i make any changes to overcome this error
 
<form method="POST" ...
 
@bwoebi You know? I get on with life, everything is pretty much sane, NodeJS, even Java. It's not 100% to my liking, but it's sane.
And then there's PHP.
Where people argue whether or not to poke users with annoying warnings because they didn't go up to their room and set their cloaks.
 
2:32 PM
@MarcelBurkhard should i remove that if{} and replace with < form method="POST" ...
 
Well, that's why we're changing things. To make it saner.
 
@bwoebi That's the most insane part
You don't seem to even have a majority in that internals discussion!
 
@edward no I assume you're sending the form using get
@edward so you would need to adjust the html (or template)
 
@SecondRikudo not sure… but still, the loudest are always the no-sayers…
 
@bwoebi It's funny how personally Derick seems to take it.
You're trying to kill my baby! Stop it!
 
2:35 PM
19 mins ago, by bwoebi
But Dericks reply somehow was amusing. Just a short "Absolutely not." as it it were just for his emotional attachment.
 
@MarcelBurkhardI have written like this in html
<form name="lc" action="lc.php" method="post">
 
@edward You can't GET to myurl
That's probably defined somewhere at the nginx/apache level
You can only POST there
That's my guess.
Look at your access and error logs
 
@MarcelBurkhard ya u r ri8 i m getting the response from there apache tomcat /6.0.36 - error report
is there any solution for these to post and get the response from them
 
@edward English, please.
 
@SecondRikudo How to solve this error any solution please
 
2:48 PM
@edward A Location header is a 302 redirect. If you want to POST to myurl you'll need to use cURL or something similar. Plenty of tutorials on Google for that.
 
@JeremiahWinsley ok i will search
 
@edward stackoverflow.com/a/2440274/3794472. You can probably pass $_POST directly to CURLOPT_POSTFIELDS if you don't need to perform any validation on your side.
 
posted on January 27, 2015 by kbironneau

/* by JRich */

 
^^ And theeeere it goes!
 
3:04 PM
Did antone used fullcalendar?
Anyone*
 
yes
@Poteito I do
 
You conected it to a mysql database ?
Because I having trouble setting it up.
I'm*
And most of the guides/tutorials are from the first version
 
user895378
morning
 
@JeremiahWinsley thanku i will try that once
 
@Poteito, yes. I use eventSources
@Poteito which call some url returning a json feed
@Poteito are you using symfony/twig by any chance? Then I could easily help you..
ah you posted a question.. I'll look into it
@Poteito Oh I see, my fullcalendar implementation is read only
probably not what you're looking for
 
3:18 PM
Someone should tell Derick that people maybe often get tz wrong - this warning doesn't disappear. Just the warning when no tz is specified at all. // not wanting to reply to Derick directly on internals.
 
Yes i want actually a manager but cant find any guides :/
 
is reflection the recommended way to unit test private methods?
 
@crypticツ Don't test private methods
ever
 
@Poteito do you store events yourself or using google calendar?
 
@crypticツ Just test the public api
 
3:21 PM
My self something i dont understand is why do i need json if i store everthing in mysql ?
 
@PeeHaa Is it because a break in a private method will result in a break in the public method?
 
yes
 
hello everyone...guys, is this syntax correct?:
 
Also: One does not test private methods
 
@Poteito think of it as a transport format, the calendar loads the events using ajax thats why it needs that
 
3:22 PM
$statement = $pdo->query("SELECT idHotel FROM Hotel;");
$result = $statement->fetch(PDO::FETCH_ASSOC);
$id = $result['idHotel'];
$statement = $pdo->prepare("UPDATE Hotel SET Nome=:nome WHERE id=$id");
 
@PeeHaa too bad. Lisp can do it.
:P
 
PHP could too :P
 
@Japa you are doing it wrong
 
@Japa remove the ; after Hotel
 
@PeeHaa then how would you help pinpoint where the break occurred. A break in public method could be related to one of many private methods.
 
3:23 PM
So should the json folder be empty ? If its only for transport
 
@crypticツ Is the problem not rather that the thing is doing too much?
 
@Poteito what folder?
I don't have a json folder
 
I m using the json.html template an there he uses a events json file
 
ok ...thank you, i´m checking if the table already has values, so i´m getting the id, if the id is > 1, i want to update the value :name of that row....if not, i´m inserting...so the rest of my code is: ( could anyone tell me if i´m doing the right way)
$nome = filter_var(($_POST['formGeralImputNome']),FILTER_SANITIZE_STRING);
$statement->bindParam(':nome', $nome);
$statement->bindParam(':idHotel', $id);
$statement->execute;
 
please stop guessing the code
 
3:29 PM
do i have to bind the id which is a autoincrement value?
 
please stop, FIFY @tereško
 
@tereško guessing the code?
 
how many assertions are too much for a unit test method? I currently have 5 test methods, with a total of 10 assertions.
 
@Poteito yes that's useless in your case however as its static, you need to supply an url which returns a json from db, as in json_encode($events);
 
@crypticツ So 2 assertions per test?
 
3:33 PM
@PeeHaa on average
some have 4
it's to get coverage for a switch()
 
@crypticツ Create separate tests for those
It also allows you to give better (more specific) names to your tests
 
kk, thx
 
@tereško can you help me?
 
@japa $statement->execute is a function, you're missing the parentheses.
 
@JeremiahWinsley thank you, i was forgetting that, but i´m confused because the rest is not working
 
3:42 PM
What errors are you getting?
 
@MarcelBurkhard So I'm now at home and but I don't have access to my folders but I can explain what I already tried
 
@JeremiahWinsley the update is not working, in the network tab in chrome i can see the 200 ok and the value i have insert in the form, but then the database is not updating.
if you see my code, i´m getting the row id in the database ( which it has to be always 1 because i´m gonna update always the same row)...so i do a select, and then update the value nome in that row...is it the way i´m getting the id?
this id value is primary k
 
@MarcelBurkhard Do you know how to get Data from MySQL to JSON and then into the calendar (please excuse me I probably the worst programmer ever xD)
 
@Japa Echo out your variables before you bind them, and make sure it's the values you're expecting.
 
@Poteito yes, but Its not like I can explain it to you in 3 sentences...
@Poteito But basically you query the database using php to get an array and then echo the output of json_encode($result); Additionally you set the response headers to be Content-Type: application/json
lets say you do that in json_events.php
now in your fullcalendar config you add json_events.php as an eventSource
eventSources: [ './json_events.php' ]
you'll need to provide the events like this: fullcalendar.io/docs/event_data/Event_Object
e.g. $event = array("title"=>$row["Title"], "start"=>$row["From"],...............
 
3:56 PM
anyone here who bought the sourcemaking design patterns book and can recommend it? (sourcemaking.com/design-patterns-book)
 
@MarcelBurkhard and this is what i don't understand : e.g. $event = array("title"=>$row["Title"], "start"=>$row["From"] Does the array know "title" and "start" ?
@MarcelBurkhard Because if you fetch then in a array there will be only the record from the database
 
Ok lets say we'd have the year 2005
$res = mysql_query("SELECT Title, From, To FROM events");
$events = array();
while($row = mysql_fetch_assoc($res)) {
$events[] = array("title"=>$row["Title"], .......

}
echo json_encode($events);
gotta go now
good luck
 
lol
 
but you need to use pdo
:D
 
news.php.net/php.internals/81246 … huh? you'd prefer to make life harder for end users …… not sure what to reply there…
 
4:03 PM
How project managers are born: http://i.imgur.com/jubT0vJ.jpg
/cc @tereško ^
 
Holy crap. Look what I have found in a codebase
document.write( '<body style="background-repeat: repeat; background-image: url(/the/background.jpg);">' );
 
oh god
why
 
No clue whatsoever
 
I guess it was something else originally...
s/guess/hope/...
 
And in case you are wondering how that even works. It doesn't
 
4:05 PM
@MarcelBurkhard thx :)
 
why wouldn't it work?
 
Because it ends up being awkward html in ie
> HTML1514: Extra "<body>" tag found. Only one "<body>" tag should exist per document.
 
@PeeHaa That's an oxymoron. I mean, even IE is so awkward they're renaming it in WinX
 
lol
 
Man crawling is a ballache some times
HTML from doing it from CLI is different to that of browser. -_-
 
4:11 PM
@Fabor Add a proper user agent
 
Already done
 
Oh in that case copy all headers from your browser
 
user895378
@Fabor I apologize I still haven't had a chance to work on your proxy issue. I've been coding every free moment since you first reported it ... just haven't had time :(
 
user895378
Also:
 
user895378
Lost in the #PHP date() timezone debacle is this: php.ini is a registry anti-pattern. Forcing bad design on code is not a language feature.
 
4:14 PM
@rdlowrey No worries. :)
 
@rdlowrey Yet you find the time to tweet...
 
user895378
E_DERICK
 
@rdlowrey Yeah, I never understood why php.ini needed its own timezone
 
@PeeHaa Exactly the same headers still different html
 
@Fabor Impossibru
Same ip?
 
4:16 PM
Want me to send you the domain? :P
No, using a proxy.
 
I am bat shit busy atm
 
heh no worries
 
@Fabor Ah. That might just be it
Try it from your own ip
 
user895378
@bwoebi ugh, you mean I have to participate on-list? :)
 
4:18 PM
@PeeHaa My IP still different :P
 
@rdlowrey great idea!
 
@PeeHaa Your requestable has the same issue.
 
whats the domain?
 
Wouldn't mind your input on this too @rdlowrey
Will delete as it's a y'aaar!! pirate link ^
 
I don't want to argue too much on internals. They're excellent in misinterpreting your input and turning it against you…
 
4:20 PM
If you view the html from @PeeHaa's requestable it's different to if you use postman
In particular the <title>
 
user895378
@bwoebi Exactly. It's not worth arguing there.
 
lol
 
user895378
@PeeHaa E_YOUR_CLIENT_DOESN'T_KNOW_HOW_TO_DECODE_GZIP_ENTITY_BODIES
 
sorry my bad
yeah just noticed I forgot to remove the header
 
4:26 PM
<--- scanning through postman extension for clues now.
 
@rdlowrey curl probably knows how to do it but the developer of this site was lazy
 
@rdlowrey only issue now that there is an open and wrong claim other people might agree with and vote no.
 
@Fabor I don't have time to go deeper, but this is strange at first sight
 
@PeeHaa When there's something strange...
FTR @PeeHaa It's the same wrong HTML on Goutte, Artax and vanilla cURL. Postman works.
But no worries about your time usage. At least I am not being dumb.
 
4:37 PM
hiya everyone
http://laravel.io/bin/JxzLv
The update query doesn't seem to work :(
 
Not many laravel users here. Try a laravel irc room
 
@Fabor I also pasted the link over there....
 
Why can't you block asshats on Reddit?
 
4:53 PM
There's an extension for you to build :P
 
user895378
@Danack Because everyone on reddit is an asshat and you'd be left with a blank page?
 
@rdlowrey Which would be perfect...
saves having to route it to 127.0.0.1 every time it gets too annoying.
 
I'm on reddit ...
 
posted on January 27, 2015 by kbironneau

/* by @beulenyoshi */

 
user895378
@JoeWatkins So am I :)
 
user895378
5:02 PM
kind of.
 
@rdlowrey is on /r/programmersgonewild
 
-9
Q: bad characters in the first response

MarcoI have found this question: Corrupted question The first answer seems to be corrupted. I see the answer as follow: Is it an issue of my pc or not?

 
user895378
@Fabor /r/programmersgonewild /r/faborsmom ... OH SNAP!
2
 
lol
 
5:05 PM
@rdlowrey So we moved from Lusitanian's mom to @Fabor's?
 
Second.jpg
 
user895378
I don't know what you're talking about ;)
 
hm?
neither do I
 
When you do PHP install it copies some header files to be used when compiling extensions. Is there a make command to clean these?
As I've just found that someone renamed a header file in the core, so stuff is broken, but it works for me as I've been using the cached version of the file....
 
I would hope make distclean would work, which should clean everything.
 
5:28 PM
@LeviMorrison Apparently it doesn't. That's a problem right?
 
Probably.
 
user895378
--enable-maintainer-zts is unnecessary on windows right? Doesn't it build thread-safe by default?
 
Awesome - the code was working when compiled with a cached and no longer used file. It now crashes uses the correct files.
 
@rdlowrey Beats me ^^
 
user895378
/me doesn't love building php in windows.
 
user895378
5:34 PM
It's not that bad, I just hate using the garbage windows command line tools.
 
user895378
@LeviMorrison for future reference I was correct. windows builds are TS by default.
 
5:58 PM
I rebased the return types impl onto master and it worked without debug, but on Travis the debug build failed: travis-ci.org/php/php-src/jobs/48510859
There are a lot of of return types tests that fail, but there are others too.
 
Go go gadget arms. http://t.co/rYNbAvP15B
 
user895378
@LeviMorrison Next step would be build it locally and examine the test .diffs and see what's going wrong.
 
I've never done that on Travis; how can I check them?
 
user895378
The only failure I see that isn't return types is:
 
user895378
mysqli_fetch_all() [ext/mysqli/tests/mysqli_fetch_all.phpt]
 
user895378
6:01 PM
@LeviMorrison Just do a ctrl+f and find FAILED TEST SUMMARY in your browser window
 
@rdlowrey Right, but where are the diffs?
 
user895378
Oh, I don't think you can see those on travis. Hence the "build it locally." When you run the test suite locally any failed tests result in .diff and .out files (among others) in the same directory as the failed .phpt test
 
user895378
So you can examine exactly what was expected and what actually happened
 
user895378
So I would just run the failing tests listed by travis one at a time and troubleshoot them using the resulting .out and .diff files.
 
user895378
It also outputs a .php file with the actual test code so you can play with it and see what's going on without going through run-tests.php
 
user895378
6:05 PM
Not trying to be pedantic, just don't know how much you've worked with manually running php-src tests:
 
user895378
$ ./run-tests.php -p path/to/bin/php Zend/tests/return_types/006.phpt
 
user895378
^ for example. Doing that in your php-src directory will run that single test and generate the output files for the test failure inside Zend/tests/return_types/
 
This may be a dumb question - how is this code safe? It appears to be setting the pointer to the return value to be pointing at the stack.
 
user895378
@Danack The place where that's happening isn't a PHP function. That code is only using retval inside that specific function. It runs the callback on line 1443 and the callback's return value is stored at retval. retval is just a placeholder to help determine the function's real return value: rval.
 
user895378
So it doesn't need to survive beyond that function scope. It's not the magical PHP function return value, just a temporary variable in that function's scope.
 
user895378
6:17 PM
The variable naming certainly could be improved to avoid confusion.
 
k - thanks.
 
Looks like I have memory leaks (or to be completely accurate, dmitry does ^^)
 
user895378
:)
 
6:50 PM
Alright, I think I fixed it.
Fixed locally anyway.
 
gods below, I cannot express the hate I have for fucktards like Brandon Savage and P. M. Jones who keep poisoning PHP community with their bullshit
4
 
@rdlowrey Possibly the same question again - does add_assoc_zval copy zvals or is there other stuff going on there?
@tereško pm jones doesn't seem that bad...
 
he cares only about two things: pushing his books and pushing his framework
both of which are borderline harmful
 

« first day (1564 days earlier)      last day (3381 days later) »