logs archiveIRC Archive / Freenode / #php / 2015 / September / 19 / 1
morfin
is that fine to store error codes in inherited from Exception class?
and then do ApiException::BAD_API_KEY
sorabji
morfin: like, will it work?
morfin
yes,
sorabji
why not try it and see?
morfin
it works, i already used it
sorabji
ok
morfin
i was interested not will it work but is that fine design
sorabji
it's not much to give an opinion on
morfin
nevermind
why that "closures" in PHP does not allow use($this)?
or it automatically catch $this by reference?
         

sorabji
doesn't look like you need to use($this)
caffinated
you don't.
http://codepad.hashphp.org/MDibRJ
morfin
hmmm wat
http://codepad.viper-7.com/sUAq3f
why it throw an error with 5.5.24?
oops
caffinated
morfin: it doesn't. https://3v4l.org/ts0c3
morfin
is that some bug? because i have 5.5.26 and it works fine btw
oh
but i can't even imagine when it could be required btw
AliG1000
I would like to catch errors.
In production mode, I would like to output all errors to the screen via the use of the variable $live (which can be either TRUE or FALSE).
In live mode, I would like to ouput just a line 'Hmm. Something went wrong. We've logged it with log id #103 and we'll look into it'. This means making a connection and logging it to the database.
If it is a Fatal error, can I do this? Or does the rest of the PHP process stop running once it hits the fatal error and thus cannot log anything to the database.
morfin
sorabji, after C++ i was trying to capture $this :D
but i see it works fine
caffinated
morfin: closure scopes in php are a bit oddball
it's understandable that you'd think it would work that way
morfin
not sure when i would use that in real code =)
_dreamer
I do not uderstand, I get a SQL error $sql = "INSER INTO `project` (owner,name,email,type,deadline) VALUES ($project_owner,$project_name,$project_email,$project_type,$project_deadline)";
this is what the error message reads You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSER INTO `project` (owner,name,email,type,deadline) VALUES (1,test,test@localh' at line 1
Gugge
what makes you think INSER is a valid SQL command? :)
_dreamer
why does the line not fully display?
XD
OMG
thanks
Gugge
because what is the way the mysqldevs chose to output errors :
sorabji
_dreamer: why aren't you using prepared statements?
_dreamer
how embarrasing
XD
not for this
this is just a noob school project
I dont have to
sorabji
pride in your work, c'mon
_dreamer
I would in a proper project though
kminooie
hi everyone, can anyone help me find some documentation for php configuration directive 'access.format' ? I have been googling for hours now and can't find any thing.
_dreamer
need to get it done before 12 o clock
XD
retran
it's not like prepared statements are such a huge overhead
         

_dreamer
asses on fire
retran
they dont really add a workload at all... you either have to concatonate the string to include parameters, or use the prepared statement and bind
not that different as far as how much code/complexity there is
kminooie
I need to find out what each one of those place holder do 'access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"'
retran
i'm guessing its just you're not that familiar with prepared statements
Gugge
kminooie: who told you that was a php configuration?
kminooie
it is php-fpm configuration
Gugge
sure, its a fpm config variable :)
kminooie
still there is no documentation for it any where? does it suppose to mimic apache ones?
Gugge
kminooie: the default fpm config should have a lot of info about it
kminooie
I couldn't find any. can u send me a link
Gugge
sure: https://www.google.dk/search?q=php-fpm+access.format
first hit :)
someone posted a config
kminooie
!Gugge yup thank you, apparently adding the magic fpm word made all the difference :) thanks
Robossoon
do i need to apply the js encodeURIComponent() function on a get query in an ajax call to some php file intended to return back some data ?
it's said to be a function for encoding urls
aias
if i have variables called $varAlpha, $varBeta, $varGamma, and an array containing [ 'Alpha', 'Beta', 'Gamma' ], how can i use the values of the array to loop through variable names?
sorabji
that's a strange position to be in aias
freite
Robossoon: i would really recommend using a library like jquery for ajax calls
fergal
hi guys, if i wanted to write a rest api in php, what frameworks/libraries/websites would you recommend?
caffinated
Robossoon: no, it's a function for encoding URI *components*, not complete URLs
Robossoon
caffinated: ah, but do i need to encode the url/get query in the first place?
caffinated
Robossoon: you understand how you'd use urlencode() in php, right?
Robossoon
caffinated: yeah, but i'm taking about the fie where the ajax request is written, in js
caffinated
it's the same thing
Robossoon
*talking about *
caffinated: what do you mean? :o
caffinated
i mean, the way you'd go about encoding URL components in php is how you'd go about it in javascript.
some parts are encoded, other parts are not
generally speaking, in the query parameters you encode the value, but not the key (unless you're using oddball characters in the key, which is rare)
you might encode part of the URL path, but not the entire URL
Robossoon
caffinated: i did this xmlhttp.open("GET","supp_fact_ajax.php?fact_ref="+encodeURIComponent(field_val),true);
where field_var is the value to be sent
caffinated
seems reasonable.
if you use jquery, it may do it for you.
Robossoon
caffinated: ah
freite
it will and it will save you a lot of time...dealing with bullsh*t browser incompatibles
mostly dealing with IE crap
caffinated
I know the javascript purists are a bit down on it, but it sure does make the process easier
Robossoon
yeah, i use query in my code, but haven't used it yet in ajax things :p
caffinated
as a backend programmer, I'd rather drink a crushed glass and motor oil milkshake than spend my day dealing with inconsistencies between browsers.
Robossoon
i just wrote the traditional js code :p
morfin
how do you think - if i have some external API(delivery) and writing implementation of that API is that better to wrap results so i can hide details from user?
as example right now API returns cities list like that: [{"Name": "Somecity","Code":6}], if API authors will change keys so i will have something like [{"name": "Somecity","code":6}] if i just return raw result to user and he access like $city->Name his code will crash
laszlof
I tend to subscribe to the idea that you should make all data available via the API.
caffinated
If API authors are chaning their api arbitrarily without notice they're already doing it wrong.
laszlof
that too.
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 next »