logs archiveIRC Archive / Freenode / #php / 2015 / July / 1 / 1
markelite
Bittarman, Got it. I've been using single and double quotes interchangeably.. thanks for pointing that out.
Zeranoe
Is it safe to use $conn->query("SELECT Token FROM Tbl WHERE Token = '$token'") if $token is a argument for the function that calls the query? $token is not a user input var
frostschutz
Zeranoe, of course not
kieronwiltshire_
Guys, I plan on creating a restful permission system which is as generic as possible. Is anyone interested in helping out?
Zeranoe
frostschutz: So I have to use prepared statements for a single query?
sorabji
Zeranoe: it's less cognitive overhead to just use prepared statements
Chunk2
Zeranoe: SQL queries are literally compiled when they get sent to the server
If you make them by string concatenation you're basically eval()ing arbitrary code.
thebuccaneersd-1
Zeranoe : in theory, its safe enough, but its generally a bad idea. you never know how the code might change
Chunk2
PDO makes prepared statements extremely easy
like much easier than mysqli
         

thebuccaneersd-1
it takes pretty much no additional effort to use prepared statements
MrPunkin
Hey folks. I have an issue where the integer 373185000007071227 is being converted to E notation on my production server, and I cant get it back to this format. Ive tried sprintf(%.0f, &) however that converts it to 373185000007071232 (which is no longer the right number)
any suggestions?
frostschutz
MrPunkin, float is inaccurate
MrPunkin
Sure, I dont need to do math on this, its just an ID for a remote service that I use via API. I need a way to get it back to a string
that is all
Chunk2
MrPunkin: If it's a unique identifier, I'd just leave it as a string
if it's that long
frostschutz
MrPunkin, there is no way back once it went float. so don't go float in the first place
MrPunkin, prevent "being converted to E notation"
MrPunkin
Yeah, Id love to know how to do that.
Im just json_decoding the API response
since its a JSON API
TML
MrPunkin: I can't replicate that - can you pastebin the JSON that's coming in that causes the problem?
MrPunkin
TML: http://pastie.org/private/q7aviuwmsfiy2uki0bzg
TML
MrPunkin: http://3v4l.org/MMHZE
["ID"]=>int(373185000007071232)
MrPunkin
TML: var_dump works fine, as does var_export, however trying to use it in a string or something it gets messed up.
and prints as E notation
TML
MrPunkin: If var_dump() shows the data as being fine, then it's being stored accurately.
MrPunkin
TML: Im fully aware I may just be referencing it wrong, just cant get it to print properly.
in string concatenation
TML
so show me what you're doing, because it prints just fine for me - http://3v4l.org/gM8bX
martin290
Hey everyone, what's a good first project to do in php with a back end db?
jbafford
martin290: something you think would be interesting and useful to you
Dustin|Work
martin290, I'd say a Blog style system
jbafford
build a database to inventory your dvd collection, or action figures, or books or whatever.
blog system number ten billion is good also, as a learning experience, just be ready to throw it out and use some pre-existing blog software when you realize a blog system is a lot of work.
but the point is: make something that you find interesting and that you will actually use. because if you dont use it, if it doesnt scratch some itch, then its work, not fun.
martin290
Good point
Something I'll actually use, that's tough
TML
jbafford: what's wrong with it being work?
         

jbafford
TML: hes just getting started with PHP. Why not let the learning experience be fun, if possible?
MrPunkin
TML: I cant replicate it on my local server. My production server, when using json_decode, indeed converts it to e notation.
TML
*shrug* Why make "work" and "enjoy yourself" mutually exclusive?
MrPunkin
TML: So it must be something with the environment or php.ini settings?
TML
MrPunkin: Does var_dump show it in scientific notation?
MrPunkin
TML: yes
TML
MrPunkin: What version of PHP?
Tennis
yh
MrPunkin
TML: 5.5.21
martin290
I need to think about something I'll use
Maybe a to do list??
Just for fun
jbafford
TML: true, work and fun arent mutually exclusive. But if youre doing something you dont have to do, for the sake of learning something, why not at least try and make it fun?
martin290
I think I could make an inventory system. That would be interesting
MrPunkin
TML: and trying to use number_format or something is failing too, converts to the wrong number.
TML: I guess I just need to manually wrap this integer in my JSON response with quotes via preg_replace or something.
Happy_the_Exceed
martin290, forum software!
martin290
Forum software??
sorabji
MrPunkin: i'd be more interested in finding out why your server is doing weird stuff
jbafford
(Action) puts a little phpnuke in a box next to Happy_the_Exceed and runs for cover
sorabji
rather than hacking around it
MrPunkin
sorabji: Sure, but how can I do that? Its Media Temple shared Grid hosting
Happy_the_Exceed
martin290, similar to what mybb, or phpbb3.1 is.
or "invisionpower"/IPB forum.
martin290
Oh wow, that's a big project lol
Happy_the_Exceed
;)
sorabji
MrPunkin: perhaps reach out to them
you can show them that this is not normal php behavior
Happy_the_Exceed
martin290, a "small" project would be a shoutbox. Or Guestbook.
martin290
I wanted something small first, get my feet wet, and I want to learn pogo php the right way
Happy_the_Exceed
It's one of my first project I've worked on right after I learned PHP's syntax.
martin290
Yup, I think I'm going to do a to do list
You can store files on the server in xml, right?
I've got host gator
Happy_the_Exceed
MrPunkin
sorabji: It seems from Stack Overflow that it indeed may be normal behavior in 32-bit environments
Happy_the_Exceed
martin290, But with better CSS theme obviously.
Dustin|Work
martin290, as far as I know, hostgator will let you store stuff yes
Happy_the_Exceed
Then you can "Evolve" that into a comment for each web page you make.
Which evolves into a blog.
jbafford
(when then evolves into a giant security disaster if youre not careful. Either way, a good learning experience.)
MrPunkin
sorabji: though actually it does seem to be on a 64 bit server so nevermind.
Happy_the_Exceed
Requires 1-2 files literally. Just 2 queries.
martin290
Happy, that looks cool
How would I update the site for everyone on it, if that makes sense
Happy_the_Exceed
martin290, your "Send/submit/post/Shout/Leave a message" button would trigger a script like this: http://dpaste.com/0KPGHR1 (postgresql example)
martin290
It looks like that just updated the db, right?
I mean inserted a record into the db
How about showing the new message to everyone on the site?
monsterco
I am supposed to receive three variables and one .tif file in POST from a vendor. Can you please point me to an example of how to receive the contents of these three variables and also the file?
Dustin|Work
martin290, you just read the DB from the page and print out all the rows
martin290
And that will update the page for every instance?
KLVTZ
Good Morning, we have a SOAP service provided from a Magento application's API. We use PHP's SOAP Client to create a client object. We pass through a user agent as well as wsdl_cache_none. We get a client back but when we attempt to call a service method (login) we recieve the following: https://gist.github.com/KLVTZ/b2175a972b685eab0315 --we determined that our varnish cache is blocking this because a user-ag
ent is not being pass through. Why would a user agent pass through on an initial instantion of the client, but when we call the service, no user-agent is provided>
and the above statement has been verified as we see a 200 user-agent on soap client creation under varnish (i guess the client hits the wsdl) and when we call login, method available, we see no user-agent 403 block.
xochilpili
hi all
i have created a function to authenticate a user with ldap, but i like to create another functions to add user, change the group, and delete but with the same credentials once the user is logged, i have declare $ldap_config['host'], $ldap_config['usr'] and pass, in the begginning of the php called functions, then once the user is logged on, i fill $ldap_config['user'] and pass, then in another function called test() i try to connect with ldap
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 next »