logs archiveIRC Archive / Freenode / #php / 2006 / June / 5 / 1
sundev
drstroker: a count variable and is_dir() should work.
Pollita
If he bounces again, I'll put a temporary ban on him
Wolfpaws
Pollita: I ment to do that, but you're welcome just as well :)
grendal_prime
sundev tried that
Pollita
(Action) looks at Wolfpaws....
MrSmile
Hi people!
Pollita
Do I know you?
MrSmile
I need help...
Pollita
By another nick maybe?
         

Stormchaser
I think so :)
Pollita
gotcha
MrSmile
Does anybody of you know how to create dynaic arrays with php?
DrStroker
sundev: its like this right $count = ++;
MrSmile
I have no clue, and I am not getting smart :(
Pollita
MrSmile: http://www.php.net/language.types.array
$a = array();
Dangermouse
Wolfpaws, noooo go back
Pollita
$a['foo'] = 'bar';
sundev
drstroker: i'd using something like $count += 1;
Pollita
$a[5] = 'baz';
$a[] = 'bomb';
Wolfpaws
(Action) shakes his head
MrSmile
dynamic!!! not static
Pollita
Define what you mean by dynamic
Because I just "dynamicly" populated that array (granted with static values)
MrSmile
let us say, fetch through a select query from a table a value, and dependend of this value (after converting it to (int) you want to make the size of the array.
DrStroker
i'm trying to make a count varible in a while statement will this work $count = ++;
sundev
no
Pollita
MrSmile: You don't declare arrays to be a certain size
MrSmile: They simply grow as you put stuff in 'em
If you want to make a big array with a bunch of empty values you *could* do: $arr = array_pad(array(), $numItems, NULL);
But that's kind of a silly thing to do.
Very "not-php"
grendal_prime
sundev i if i add a header('location:index.php'); after the auth...it never fires up the auth request..it just goes to the index.php. and the auth just reopens because im unable to redirect the browser aftet the new authentication is entered
OrbX
Flannel: I am nesting the <ul> in a <div> tag and the div doesn't auto increase if I use float any ideas why?
prophile
grendal_prime: you can't use header if you've already outputted anything
         

zom__
how can I merge two arrays but preserve my existing (integer) keys?
grendal_prime
exactly
prophile
zom__: manual foreach and the [] operator:
grendal_prime
if i use this. on a page called logout.php header('WWW-Authenticate: Basic realm="Booksnmore internal"');
header('HTTP/1.0 401 Unauthorized');
prophile
grendal_prime: output buffering
colder
prophile, how would that preserve any keys err ?
prophile
prophile: http://uk2.php.net/ob_start
colder
zom__, $array1+$array2, simply
prophile
colder: function &array_merge_preserve ( &$array1, &$array2 ) { $temparr = $array1; foreach ($array2 as $key => &$value) { $temparr[$key] =& $value; } return $temparr; }
or that
heh
TimJR88
I was told by a friend about classes, but I dont see what the advantage of useing them is? Can some one explain to me the dvantage?
colder
TimJR88, you mean using OOP ?
TimJR88
yes
zom__
colder: thanks
prophile
TimJR88: http://java.sun.com/docs/books/tutorial/java/concepts/index.html - technically for Java but the points you see there still stand
JJPeerless
to protect against sql injection from a input field..can i just do stripslashes?
er, striptags
prophile
TimJR88: also look at http://en.wikipedia.org/wiki/Object-oriented_programming
JJPeerless: you could try using whatever escape function comes with your database driver
JJPeerless: if you're using mysql the best method is mysql_real_escape_string
TimJR88
was just wondering why use it for web stuff?
colder
prophile, and err, no need to bloat your code with references in that case
prophile
colder: speed... if the array held like 2 million values you'd want to minimize duplication
colder
prophile, it won't be duplicated until you modify it, which is not the case here (talking about passing by reference)
prophile
right, in that case take out the & for the two params, but the rest would remain the same :)
colder
TimJR88, who said PHP was dedicated to web stuff ? anway even with web stuff there are bunch of reasons.
prophile
aye
Model-View-Controller works well in PHP
and there are non-web uses of PHP
quickly hacking together scripts for whatever is very easy in PHP
and with ncurses you can do all sorts of other stuff too
Wolfpaws
!+enter
prophile
like an IRC client even
php-bot
Don't use the enter key as punctuation. Think in complete thoughts, then type.
prophile
right
colder
Wolfpaws, ehy (-:
Wolfpaws
heya, colder! :)
Kartagis
good night
hermit
What's the easiest way to go about creating a random password using php standard library functions?
I want it to be alphanumeric, so rand() wont quite do it
and an md5 hash is too long
I guess I can just clip the hash down to 8 chars or something..
colder
hermit, what's wrong about rand ?
hermit
i want letters not just numbers
I am just going to do $password = substr(md5(time()), 0, 8);
that ought to do the job
colder
hermit, use range, and chose randomly some keys of the array of letters.
hermit
sounds like more work than my solution
Piero
hi everyone!
I can't understand what "$search_html .= <<<FO" mean
what is <<<FO?
colder
Mtraker
#css
Piero
colder, great! Thanks a lot
diego
why does ('somestring' == 0) always evaluate to true?
Piero
diego, is it an "if"?
diego
Piero: it's a conditional statement, it doesn't matter
colder
diego, that's the way php makes the comparison between different types
Piero
diego, try ("somestring" == "0")
arpad
diego: '' and '0' are the exceptions
diego
colder: if it can't compare, they must be equal?
colder
diego, err, what ?
jbrimble
hi guys, Just a quick question.. Is what I'm doing the correct way to make a template-style site? The address would be www.domain.com/default.php?about
and the code:
<?php
$i = $_SERVER['QUERY_STRING'];
switch ($i) {
case "about":
// Company Info here
break;
Wolfpaws
...
jbrimble
Is there anything wrong with this?
colder
diego, take a look at that: http://php.net/types.comparisons
jbrimble
:( i wasn't spamming
sorry
diego
colder: uh...thanks. i'll never understand why though
Wolfpaws
!+pastebin
php-bot
Submit your code to http://hashphp.org/pastebin or http://cpp.sourceforge.net or http://php.pastebin.com then tell us the URL and a summary of the problem. Don't flood by pasting in the channel.
jbrimble
understood
colder
diego, you can't say in php: ehy "asdf" is (bool) true, 0 is (bool) false then "asdf" != 0.
dieg^^^^^^arr he left.
JoelR
how could i do if i want to calculate the same time that is right now, but 6 months back?
colder
JoelR, you could use mktime() or strtotime()
nicos
:)
arpad
strtotime('-6 months')
JoelR
arpad: as simple as that?
nicos
yes
JoelR
thanks!
and if i have a time that was formatted with date() and i want it in timestamp way so i could compare it with another one?
arpad
JoelR: strtotime() again, you might need some preparation first though
JoelR
mmm could i use something like this: mktime(0,0,0,date('m',$var),date('d',$var),date('Y',$var)); ?
arpad
no, date() expects a timestamp there
Qube
arpad, tho I've seen people do things like that to get midnight on a particular day!
(with timestamps)
arpad
Qube: heh
SqrlWthANife
Greets.
jbrimble
when you're using a switch, can you use Case NULL?
nife
jbrimble, yeah
jbrimble
cool, thanks.
Oh, and how can i make it "Case "home" or NULL ?
arpad
case 'home': case null: foo(); break;
jbrimble
Thanks :)
gymsmoke
i'm looking for an example of a mysql table maintenance script (add/edit/delete/list) so i can try and get my arms around table admin using php/mysql
i've been googling for the past two hours and haven't found anything yet
mattwestm
how do I turn off safe_mode?
or is it off by default?
the-erm
gymsmoke: sounds to me like you need a general knowledge of php and mysql.
gymsmoke
the-erm: not really... i've never written a table maintenance script in php before
the-erm
gymsmoke: What are you trying to do?
Maybe I'm just not getting the question.
mattwestm: php.ini
marksman
hi guys
« 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 next »