logs archiveIRC Archive / Freenode / #php / 2015 / September / 13 / 1
mreynolds91
I need some help with a php script. It will save form data to a text file formatted as: year-month-day_filename.txt
__adrian-pnwPHP
mreynolds91 sounds more suited to a database.
Bad_Advice_Cat
__adrian-pnwPHP, jelly.
__adrian-pnwPHP
:p
mreynolds91 did you have a specific problem/question? or looking for a starting point
mreynolds91
Yes and more coding, Im not very familiar with php. I was attempting to create a lightweight blogging system for a client.
__adrian-pnwPHP
Bad_Advice_Cat pretty fun. just came out of ircmaxell's talk.
Bad_Advice_Cat
AAAACK >.<
*super jelly*
ircmaxell
:-D
__adrian-pnwPHP
hah, he's here
         

Bad_Advice_Cat
my php dun work. *kicks ubuntu* <-- Imma have to compile my own. I was really hoping to be lazy and not do anything because I like automation, but I will have to make a script to get php 7 RC2 going.
__adrian-pnwPHP
mreynolds91, is there a reason you're not using an existing system? that might be the better course if you're not familiar with php. there are plenty of solutions out there.
php
Bad_Advice_Cat: Sorry, I need to go to the doctors. :(
mreynolds91
anyway.... i wanted to create a form he could use to save his entry with the aforementioned format.
And yes Formatting joomla or wordpress to get it looking exactly like i want is tedious.
Bad_Advice_Cat
php, pronto!!!
__adrian-pnwPHP
mreynolds91 i understand. both my points stand... especially, "sounds more suited to a database."
tw2113
formatting Joomla or WordPress? you mean like CSS?
or making it do what you need?
mreynolds91
Its not the CSS that bothers me. its sifting through everything else.
__adrian-pnwPHP
(I'm not the person to ask about themeing joomla/wp, but that's a lower learning curve than building a blog from scratch.)
by far
tw2113
heck, reading some tutorials and documentation is less of a learning curve
__adrian-pnwPHP
mreynolds91 re: files: http://php.net/file_get_contents
* http://php.net/file_put_contents
tw2113
having fun at the conf __adrian-pnwPHP ?
__adrian-pnwPHP
totally.
mreynolds91
what i really couldn't figure out was getting the dashes and underscores to work with the date inputs for example this is my problem... and yes i know its very wrong... ...file_put_contents($targetFolder,"$year","-","$month","-","$day","_","$title"".md", $title, $entry);
__adrian-pnwPHP
mreynolds91, you need to understand how to write php code.
you're just adding extra args to the function.
mreynolds91
your right of course.
__adrian-pnwPHP
which doesn't work, because it doesn't expect all those args
build the filename as a string first.
$filename = "...";
then, file_put_contents( $filename, $contents );
mreynolds91
so It would be something along the lines of $filename ="$year-$month-$day_filename"
__adrian-pnwPHP
sounds like
you'd do well to define the whole path, of course
so you don't have to rely on what you assume the current working directory is
mreynolds91
and the dashes and underscore will just appear in the filename? you dont format it differently to get them to appear?
         

__adrian-pnwPHP
well.. is $day_filename *supposed* to be one var, or two?
mreynolds91
two that was a typo
__adrian-pnwPHP
because it's only one
How about `$day_` then? what do you think that var name is?
is it $day + "_"? or $day_ ?
Bad_Advice_Cat
(Action) waits for ircmaxell's talk to appear on youtube...
ircmaxell
(Action) has no idea
laszlof
back to work!
;)
mreynolds91
$filename= "$year-$month-$day"_"$entry.txt
__adrian-pnwPHP
you can do that, but you need to concat
(Action) chuckles
$filename= "$year-$month-$day"."_"."$entry.txt";
OR use braces $filename= "$year-$month-{$day}_$entry.txt";
AcidReign
or date("Y-m-d", $time)
laszlof
ircmaxell: did someone record your talk?
mreynolds91
i will try that. thanks!
tw2113
I know Anthony talked in the main room for PNWPHP, but not sure the videos are going to be made public for free
from what i understand, myself having a live stream ticket will get access to it
laszlof
I was manning our booth, missed it.
Bad_Advice_Cat
(Action) wonders what the talk was about.
tw2113
__adrian-pnwPHP
yeah, they recorded it but I dunno when/how/if that will be released
about type systems
laszlof
probably could have wandered over there but was being lazy ;)
__adrian-pnwPHP
laszlof you were 20 feet away. i'm surprised you couldn't overhear it
laszlof
rofl
ya, probably
there is a large wall between here and there
__adrian-pnwPHP
and snacks on the other side
laszlof
right. good point
tw2113
i probably should have streamed Hartjes' talk instead of watching Supernatural
ircmaxell
laszlof: it was recorded, but I have no idea about it
__adrian-pnwPHP
I missed samantha quiƱones' talk; the description sounded very "basics"-oriented and bland but word is it was pretty good
(about restful apis)
laszlof
apparently my talk was both too basic, and too detailed, and not enough live demo
:)
tw2113
PNWPHP is broadcasting live on September 11th & 12th.
Register as a ?Virtual Attendee? to get access to the live stream from our main event room, which will include 16 general sessions and keynotes. Live stream attendees will also get access to the videos? once they are published.
ima masta at tha copy/pasta
Bad_Advice_Cat
Yay slides! *slides in socks literally*
tw2113
the question is though, Bad_Advice_Cat....are you as short as Tom Cruise?
__adrian-pnwPHP
laszlof you knew about the live demo problem.
laszlof
yup, sure did
__adrian-pnwPHP
sometimes can't be helped
laszlof
oh well, if I present it again, I'll try and cut it down for more live demo anyways
Bad_Advice_Cat
tw2113, nope. xD not as sort.
Renari
Does anyone see something wrong with the PDO query? https://gist.github.com/Renari/a3fb19f27d1a4a9b4fbb I've done queries this way tons of times before and I can't figure out why it's not working this time.
Ah it seems $stmt isn't being bound correctly by $db->prepare for some reason.
Do prepared statements work on sqlite?
__adrian-pnwPHP
if $stmt is "not an object", it's probably FALSE. meaning, prepare() was not successful.
and yes, sqlite supports prepared statements
even if it didn't PDO emulates them
Bad_Advice_Cat
I do not think you can do that with column names, Renari.
__adrian-pnwPHP
table names, right
Bad_Advice_Cat
Table names.
__adrian-pnwPHP
parameters are for DATA
Bad_Advice_Cat
Thanks.
Renari, you instead have to build a white list.
1 2 3 4 5 6 7 8 next »