logs archiveIRC Archive / Freenode / #php / 2006 / June / 17 / 1
Jymmm
http://static.flickr.com/48/168468822_dc3b8e2bc9.jpg
equilibrium
hiya
AfroTurf
is there a function that will check for a negative number
richardlynch
AfroTurf: if ($x < 0) { echo "you're so negative."; }
killerspam
if ($foo < 0) ?
AfroTurf
lol k
don't know why i couldn't think of that
xshad
maybe your brain is out for vacation
killerspam
:D
I have a Q...
AfroTurf
maybe
:)
         

killerspam
I want to validate the nesting of bbcode
xshad
wth... gmail's spam filter is broken O.o
killerspam
and then if some of the nesting is messed up, display the section where it is
Touqen
killerspam: okay great
though that was more of a statement than a question
killerspam
yeah, sorry
richardlynch
killerspam: You essentially want to write a parser in PHP... At a minimalist point of view, http://php.net/strtok and substr are all you need. PHP may have more fancy functions, and I think I saw that some kind of parser was slated for PHP 6...
killerspam
watching big brother :D
basically, any general ideas how to do it?
im thinking building 2 arrays, one in reverse, of all the tags
Touqen
or you could just use a stack
and push/pop each set of matching tags
killerspam
could you explain that a little?
richardlynch
You will definitely want a stack: <b>text<i>blah<b>foo</b>more</i>and more</b> is syntactically valid, if goofy.
killerspam
not familiar with stacks, since doing it a few years ago in school
yeah richardlynch thats what I was thinking
Touqen
a stack is a lifo list
killerspam
with you so far :D
Touqen
[b]..[i]..[u]..[/u]..[/i]..[/b] <-- example string
killerspam
sure
Touqen
so you just procede through the string and you end up with a stack like [b, i, u]
and then when you reach the /u you pop off the u
and you are left with [b, i]
and just keep doing that until you get to the end.
killerspam
and the error detection comes where?
im just running through my head here..
Touqen
If you get a closing tag that doesn't match the top of the stack then you don't have proper nesting
killerspam
ah yes
makes simple sense
i'll want to store the positions in the string of each tag too
so I can report an error of where it was
Touqen
That's completely up to you.
         

killerspam
so can this stack be 2d?
Touqen
I'm just giving the conceptual view. The actual implementation details is an exercise left for the reader.
killerspam
yeah i get it now, mental block a bit i think
much appreciated
gen-2
hi
rixth
$tagArray = $this->db->multipleRows($this->db->prepareSql($sql)); << why on earth would that throw "Array to string conversion"? The $this->db method returns an array, and I am not using type casting, so why would I get that error?
gen-2
how to do a query to find out the biggest number in a filed? like this: "SELECT id FROM admins WHERE id is_the_biggest"?
rixth
Hi, gen-2
xshad
gen-2 #sql
rixth
gen-2, SELECT id FROM admins ORDER BY id DESC LIMIT 1
gen-2
rixth: okay thats easy what means DESC LIMIT 1?
xshad
!tell gen-2 about g8
rixth
xshad, leave him alone =(
ORDER BY id DESC means sort by the id descending, LIMIT 1 means get one row (which will be the highest id number)
xshad
I'm doing it
gen-2
okay thanks
cya
Touqen
rixth: um what exactly is throwing that error?
php doesn't complain about array to string conversions.
richardlynch
gen-2: select max(id) from admins
Touqen
It just converts an array to "Array"
rixth
Touqen, I use E_STRICT
Touqen
oh
(Action) is slightly out of touch with php5
s/slightly/very/
what data types does prepareSql return?
richardlynch
rixth: Tear apart the 10 operations into separate lines, so you can figure out what is going on.
rixth
Touqen, an integer
richardlynch
$db = $this->db; would be your first line.
rixth
richardlynch, alright
richardlynch
And use var_dump() on whatever seems "wrong"
Touqen
what does multipleRows take as a parameter?
rixth
Ah, I'm in idiot. It said the error was in videoCategories.php, and I was looking in another file.
multipleRows take an integer
Touqen
nevermind
no need to explain if you already figured it out
(Action) bounces
xshad
Wolfpaws *poke*
CrazyTux
does anyone here have some good php 5 oop examples I can take a look at?
xshad
CrazyTux g1.tigris.org ;)
Triton
why does echo 20060616143048+3; print out 2.00606161431E+13 instead of the number?
it kind of messes up my timestamp function
DJ_Spin
what is that, date time?
heh, yeah
xshad
Triton php isn't good with numbers, you'd use math ext
mattmcc
Triton: I get the number.
xshad
and... wtf with this huge number ? :)
Triton
its a timestamp, june 16 2006
DJ_Spin
2:30 and 48 secs
;p
xshad
isn't a timestamp
Triton
ok... is there a setting to not do the scientific notation for simple math
DJ_Spin
i also get the full number
xshad
I got the number too
CrazyTux
Triton, sum ?
Triton
hmmm, i dont.
is that a function?
CrazyTux
no, lol, one sec
xshad
see you guys.. have fun
CrazyTux
Triton, try seperating it?
Triton, num + num
lith
put your equasion in ()'s
CrazyTux
and not num+num
lith
echo (1+29);
Triton
its in ()s and i seperate the + , nothing
lith
Triton: then your doing something else wrong
that works fine
Triton
heres the whole line echo '<td style="width: *;">'.parseTimestamp($row['timestamp']).'='.$row['timestamp'].'='.(20060616143048 + 3).'</td>';
DJ_Spin
i've never checked in php.ini for sci notation but is there something in there about it?
lith
Triton: man... thats just a screwed up way to do it.. make it a variable
Triton
well, i have shared hosting, my php.ini is just basic settings
lith
making it a variable will do two things... It will work, and it will be cleaner
DJ_Spin
(Action) agrees
Triton
ok
richardlynch
20060616... is not a time stamp.. It's just the date all smushed together....
Touqen
richardlynch: it's a mysql timestamp
Gimp_
how can i convert an integer to binary format in php?
Triton
$tis = $row['timestamp']; echo '<td style="width: *;">'.parseTimestamp($tis+30000).'</td>'; samestuff
Touqen
Gimp_: pack
richardlynch
Then use MySQL functions to data_format it to get what you want, and leave PHP out of it. :-)
decbin?
lith
oh when you said timestamp i thought you ment UNIX timestamp
CrazyTux
Could someone answer me this.... in php 5 oop why would someone want to make a function call in order to get/set variables, rather than just setting the var public and accessing it $oop->actual_var_name rather than $oop->getVar('actual_var_name') and returning the value?
richardlynch
CrazyTux: Religious conviction that functions are better, or they might someday NEED to "do something" when the data is get/set or....
Gimp_
Touqen: thanks
lith
crazytux: one example that comes to mind, an active record, you may want to addslashes to a var coming in and strip them going out
crazytux: there are a number of reasons... setting min/max on certain attributes
fangel
CrazyTux: and you can inplement security checks.. (like automatic escaping etc)
Triton
i dont see why this is causing a problem, seems pretty simple
lith
crazytux: exactly... security
CrazyTux
hmmmm so you guys do recommend I use a get/set method
lith
triton: making a sandwitch is easy... unless your using sticks to cut the meat and your feet to spread the mustard
CrazyTux
so now in php 5.... do you guys mind explaining this new __get / __set magic methods?? I'm looking at the docs but there are alot of different examples, makes it a bit confusing
Triton
im not making a sandwitch, im doing basic addition
lith
crazytux: when you need it
Triton
you can't make a sandwitch with php
lith
Triton: your using the wrong tools for the job
hence the analogy
Triton
alright, i'll learn the mysql way later, thanks
kman
richardlynch: you there?
Gimp_
alright, better question, i need to be able to convert a variable number to a format of binary 1s and 0s. say i need to make 4 = 0000000100
i can't figure out how the heck pack works
richardlynch
sort of here... compiling my invoice for the boss is taking priority... :-)
lith
nono... getting PAID takes the priority :D
kman
took pdf and catputred it, used pdftops and sent to port 9100 on print to kinda create automagic priting of pdf file created in pdf, thanks!
in php*
richardlynch
Gimp_: http://php.net/decbin much less confusing.
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 next »