I have a database table that stores a username and the date when a user loggedin if the user presses the logout

method()
even though it's a static call, $this is available still
it's voodoo
^^ for you

mmk
thanks

np

nham…other question, where i donwload Apache?

http
blah
http://httpd.apache.org
there is again Win32 binaries

thanks xD

Thank you, I should've known that Davey!

Delixe:

any recommendations for a unit testing framework?
phpunit was uhhh, painful.
or is this seriously a lost cause, as i've been told?

What's the most common XMLRPC implementation? (I have full access to the server)

anyone know how to set up curl

hey y'all

server or client?
the extension?

client, I guess. does it matter?

check out the one in Zend Framework, it's pretty good
and the nicest API

i was like here 2 days ago looking for a decent HTML tree parser ( php4 compatible ), still can't find anything have been trying to write one, but its a total bitch :[

PEAR has the HTML_SaxParser IIR
C

weird I thought there were native versions

there is the xmlrpc extension, and the immature xmlrpci extension (client only)

I guess i'll take a look at zend, thanks

http://pear.php.net/package/XML_HTMLSax3

http://us3.php.net/manual/en/ref.curl.php

*reads*

http://pear.php.net/package/XML_HTMLSax for the older stable version
what are you trying to do with CURL?

this i am assuming
nuttin much
play with it\

if you're *making* standard GET requests, the http stream is far superior
if not, maybe HTTP_Client/Request or Zend_Http_Client would be better
finally, there is installation instructions right there in the page

davey….you are talking way over my little head

file_get_contents("http://url") == HTTP stream - automatically just works
if you are wanting to pretend to post forms or whatever, http
blech

yeah !! thats ut
it

http://pear.php.net/package/HTTP_Client or download the Zend Framework http://framework.zend.com and pick out the Zend_Http_Client

me ?

yes, you

oh god….i'm scared

if you want to post forms or perform more than basic requests, use those
well, you're in luck, I wrote the base of the Zend one, heh
http://framework.zend.com/manual/en/zend.http.html#zend.http.client
it's pretty well documented

how ?

how?
I hit the keys on my keyboard

yes, how?

letters were typed

and then

or am I misunderstanding your question

sorry….just amazes me

HTTP is a pretty basic protocol

hold me

are you hot? :P

don't worry i am a girl

I didn't ask that

so its ok if i was a hot guy

Who am I to be picky?

man you men arent picky anymore, are you
whatever walks …grab it

if someone is hot, they're hot. regardless of gender. The fact is I find very men hot :P
very FEW men

but you do find some hot ?

sure

hello
what is PHP

depends who you ask

Personal Home Page.

don't make me stab you.

i am logging stuff to a file…

Yes, everyone on IRC does that [domon].

but it's *most* common answer is, a programming language commonly used for web sites (in fact, the most popular for that job

characters?

are you going to be a little more constructive?
[domon]: str_replace()

yuck lol

[domon]: pass in arrays for both the first two args
it's fast
[domon]: the other option is http://php.net/html_entity_decode

i think that's better
thx davey

[domon]: but it's pretty much the same thing under the hood
[domon]: str_replace() is faster if ALL you want is and

html_entity_decode replaces more than and .
Things like — and & will probably get replaced as well.

it's also character set aware

:P

if I have a mysqldump/phpmyadmin dump.. is there some how to easily excute it again through PHP?

yes and no

Wrong parameter count for fread() in /var/www/vhosts/iptriple.com/httpdocs/API/index.php on line 720
Wrong parameter count for str_replace() in /var/www/vhosts/iptriple.com/httpdocs/API/index.php on line 722
:|

if you have MySQLi then yes, it's reasonably easy

oh whoops
LOL

just use mysqli_multi_query()
otherwise, you need to explode() it into seperate queries, and iterate them through your query function of choice

hi. i am trying to understand the code here: http://pastebin.ca/636773. I know that it relates to the mapping of URLS within the site I am looking at. The main bit I'm unsure about is $GLOBALS['app']-Map-Connect. I am used to OOP syntax like
$this-class-method. Can anyone shed any light on this?

$GLOBALS['app'] is just the $app var in the global scope
$GLOBALS['app'] is an object, which has a property called Map, which is also an object, which has a property called Connect

okay, thanks

Davey, thanks. is this php4? I am used to php5 oop syntax. DO you mean an object as in an instance of a class?

welcome
it's PHP 4 and 5
and yes

I have a requirement to add the ability for users to be able to save a partially filled form, and allow them to resume filling it out later
anyone have any experience developng such a feature?

Davey, is there a general term/phrase for what the developer is doing here so that I can read up on it?

actually, I spotted one the other day, one minute
http://jan.prima.de/LiveSaver/

wow, that is great
thanks @Davey
I was considering using a button, and a table with form id:value in order to save
but, this is more "resilient"

$fp = fopen("iptlogfile.txt", "w+");
$data = fread($fp, "706220");
what's wrong with that? o.O

[domon]: assuming $fp != false, nothing

Davey, i'm guessing that the app object has been instantiated somewhere earlier in the code and is stored in a global variable. I'm not used to working that way but would be interested to find out more

it's nothing special; you understand scopes?

Davey, variable scopes, yes. As in local variables and global variables. I probably don;t understand the intracacies of them across all versions of php, though.

http://pastie.textmate.org/83002
Resource id #16
1

hasn't changed since PHP 4.1.2
well, even then the scopes didn't change, they just added superglobals

that's the output of the script o.O

[domon]: php.net/resources (IIRC)
$GLOBALS is a superglobal that is an array of variables in the global scope

Why does 10%3 give 1, but 3%10 gives 3? Shouldn't they both be 1? Where did the 3 come from?

% = remainder after division using whole numbers

it prints out 1 for is_resource

so 10 / 3 = 3 remainder 1, 3 / 10 = 0 remainder 3
because 3 is not divisible by 10

Oh, I see.
Thanks, Davey.

grr, 3rd blackout

ouch

UPS ftw!
no problem

anyone have any ideas?

Davey, I have heard people say that globals are bad. Why would you not just extend the base App class? Might this be to ensure that the script works on php4 and 5?

well, i didn't say the code was *great*, they should've used a singleton IMO

singleton? :| ?

its a design pattern

[domon]: one of the staples of design patterns

vaguely remembers it being talked about but can't remember exactly what it is
erm..
that was meant to have /me in front of it

http://www.phppatterns.com/docs/design/singleton_pattern

ty
anyone know wtf is going on with my script?

TML?

Davey, the code is from a cms/framework called Jaws. ever heard of it?

ugh, this is *old*
yes, and know people who work on it

TML? davey said you were a moron

Davey, ah cool. what do you think of it?

kidding

http://www.fluffycat.com/PHP-Design-Patterns/Singleton/ - better

Davey, I am interested in getting involved and maybe helping with the documentation (there is none)

never worked with it, but I know the guy I'm thinking is a decent code
a decent coder*
I think you'll find I said TML knew me when *I* was a moron :P

lol
i have to make myself laugh sometimes

Davey, is he a native english speaker. I always seem to get a non-native in #jaws

no, he's icelandic, but his english is great
helgi thormar (where the th is a weird char like |D)

Davey - cool I'll look out for him. THanks for your help and general wisdom!
bDavey - cool I'll look out for him. THanks for your help and general wisdom!/b

makes me worry for the human race, frankl
y

its all relative!

I am by no stretch of the imagination, wise.
I'm just a good actor

does anyone here know a good PHP gallery?

coppermine?

is preg_match a good thing to use for all my validations

http://coppermine-gallery.net/

only if you want to make complex patterns
*always* use native string functions if you can, like ctype_*, is_numeric, etc
regex is *slooow*

Well, i am using is_string to validate a firstname box
But doesnt that mean they can put in whatever they want, spaces, $, %

sup!

I checked out php.net/is_string and they tell you how to use stuff, but never say what it excludes

yes, try using ctype_alpha instead

For example Davey, does ctype_alpha exclude spaces

yes
maybe you want ctype_printable
(IIRC)

Ok, looks like i have a winner, thank you

Then that would still allow spaces, $, %.

How can I see what pear libraries I have installed?

pear list
from the command line

Hm, weird. I installed the progressbar extension, and I don't see it there. Maybe I'm looking for something else.

pecl extension?
pecl list

gah, yeah, it was pecl
Thanks, I'm a tad rusty

Yeah I've been using coppermine
But I don't know crap about php so when I really want to customize
it's near impossible for me

pear list -c pecl or some such would work too

gets frustrating

you're going to run with that with most thing
s

yeah
I should probably learn PHP
on a scale from extremely difficult to impossible
how hard is it

uhh

because it seems real hard

it's relatively easy

any advice on where to start?

get the visual book on php
(PHP published by Visual)

hm, okay, maybe it wasn't pecl. Or maybe it was installed by hand, and that's why it wasn't on the list (eg. from source).
require_once() [a href='function.require'function.require/a]: Failed opening required 'DB.php' (include_path='.:/usr/share/php') - that's the error, hm, I know it's pear, I think. /me googles

ok

php config-show
make sure the php_dir is set to /usr/share/php

does anyone here have any experience with coppermine?

http://pastie.textmate.org/83005 - what's wrong with that?

Hm, php config-show says Could not open input file: config-show. And where is php_dir set? I don't see it in php.ini. hmph

Could PHP be used so that, if I were to choose an item from a drop down box, it writes a table depending on what I selected?
Would I have to write the HTML using PHP?

sorry, pear config-show

why couldn't you do that?

oh, hehe

I'm not sure how I could accomplish it
PHP can't write into an HTML page that's already there, if I am not mistaken?

1) Formulate the problem 2) think hard 3) code solution

print "table$variable/table"; or….

Hm, yup, php_dir is /usr/share/php. I'm moving stuff from one server to another, and I forget what DB.php is.

No, PHP is a server-side language and HTML is static.

print "table" . $variable . "/table";

You can always use EMCAscript.

hey who can put PHP programming into a nutshell for me

you can use AJAX too

[domon]: I would but I don't really know any Javascript. D:

google xajax
you dont need to know a drop of JS
all done in PHP

Hmm. This looks interesting. I'm assuming, since it's PHP, I can use it with MySQL also?

PHP is a programming language, commonly seen with web frameworks. End.

yup

My PHP-based system now uses MySQL, that's where it gets the data for the HTML Table from

If you have mysqld running and PHP is built with MySQL support, yes.

yeah not really what i was looking for
cool though

http://pastie.textmate.org/83005 - what's wrong with that? T_T

hrpmh, what function i need to cleanup text retreived from database, that has " and ' in it that i need to echo thru html
tried addslashes, not work, i forget what's out there

grr, apache creates a directory, then can't delete it, permissions are 0777

why is apache creating a directory?

a directory for an ftp user

what is ownership of directory created?

Apache

what is group?

it has all permissions set
windows doesnt have groups
well, not in the same sense

are you sure its apache creatign the directory?
never knew it too have such a feature, but i never use it on windows either

pretty sure
the owner is apache, and it's created the same time i run the script
hmm, something weird is going on D:

print filesize("/var/www/vhosts/iptriple.com/httpdocs/API/iptlogfile.txt");
returns 0 everytime :|
tho the file does exist…

sounds more like a problem with windows than apache, i'll try afew more things

http://thatvideosite.com/video/4607

this script is php you talk about ?

well this is a php channel

solution, dont run apache on windoze :P

well php is creating the dir?

maybe i'll just go back to running apache as SYSTEM

as user apache

php runs under apache

safe mode?

no safe mode
unlink(CFTP\root\home\test) [function.unlink]: Permission denied in Dwww\dev\admin\ftp\user.php on line 43
i'll try delete it manually as the apache user

can someone help me really quick

tag

PHP has a function for this, $text = nl2br($text) to convert newlines to BR tags
so echo nl2br(file_get_contents($blah)); would work

i did that but now the text do show up

why not just use \n for newlines?

\n is fine for console
if printing to browser, \n !=

well this is what i have

yeah

php $text = nl2br($text);
echo nl2br(file_get_contents($news.txt)); ?

which is the whole point in conversion

permission denied

\n?

tags in where the newlines are, which could change how your site looks

it can write files into it but can't chdir into it

php echo nl2br($text); ?

TehSausage, i think you need to start conversation from scratch, sound like theory… why is script making directories as apache and not as user running script?

it's just a simple script to add/delete ftp users

is there a php-suexec or whatever?
for windows

okay apache user can delete from bash

cuz apache is deleting it, sounds like user is trying to delete which is why denied

have to use file_get_contents or else the content in the file wont disply on screen
have to use file_get_contents or else the content in the file wont disply on screen

file_get_contents = file into string
file = array

php echo nl2br(file_get_contents('somefile.txt')); ?

can someone tell me why print filesize("myfile") returns 0? the file is 777 for permissions, and definitely exists, as i can see it via FTP and shell

is the file bigger than that? rofl :P

because = the result
0 = the result

erm..?

[domon]: Well, what is the actual size of the file?

690 KB
706,220 bytes

oh joy, is_writable('C\FTP\\root\\home\\'.$user) returns true aswell

it worked thanks

anyone?

[domon]: You can try if (file_exists($filename)) print filesize($filename); else print "File doesn't exist?\n";

it exists

that way you can make sure you're referring to the file you think you're referring to… we don't know where this file is (same dir as the script? somewhere else?)

har har
found the problem

i think you have to take out \n

i had fopen(filem, w+) before print filesize(file) XD

hiddenfellon, why would he need to take out \n ?

hi

let's see if I can figure this out

how can i make a string always to be 10 digits? i tried all - $tmp = sprintf("%-' .10s", doesnt work

hello

use substr($string,0,10)
so $string = substr($string,0,10);
that will make it 10 digits

and this retuerns also 10 digits if the string has only 5?

well, no
then it would be 5

thats my problem

strpad

then just add some stuff onto it

I'm trying to figure out how to read data from a database using this

I want useing the javascript source.

strpad(substr($x,0,10),10,'0',STR_PAD_LEFT);

how can i do it?

thx

$row = mysql_fetch_array($query); this array value $row .. how can I using the javascript var i=[]; ?
db query and var a=[]; a==$row?; alert(a);
function Array() { [native code] }

you cannot do that
JavaScript and PHP have nothing to do with each other.
You need to loop through the results in PHP first, and assign them in JS during loop

Artnez, okay.. I know loop .. but it's very long line.. :-)

example - php echo "var results = new Array();\n" for( $i=0; $isizeof( $results ); $i++ ) { $result = $results[$i]; echo "results.push( '$result[name]', '$result[address]', '$result[other_field]' );";

so I will find better skill ^^;

in any case, you can't share variables between PHP and JavaScript, please read the basics of these 2 languages to understand why.

Artnez, thanks.. :-)
good man..

does anybody where i can get fonts fot FPDF?

Yes. Offtopic.

Jafet, can you tell me where?

I don't know.

Jafet, You said Yes!?

what does that have to do with PHP?

You asked if anybody knew. Somebody probably knows, so the answer is yes.

Artnez, yes . the class is written in PHP

Ask an inappropriate question…
If I write a PHP script to serve fetish hardcore gayporn, does that make fetish hardcore gayporn a valid topic of discussion in this channel?

Jafet, do you think you are "cool"? i don't think so

Yes, I think certainly think highly of myself. I don't see how that has anything to do with this, though.

I think he's cool too!

damike, google probably knows

He's convinced me too

stay on topic here please, do some googling

He seems pretty cool to me.

Jafet, here are PHP developers - i don't say the problem to ask such a question - just idioits complain about that!
see

In English please?

lol

Jafet, the last part is enough for you

?

And here he comes, straight into the troll-trap, folks!

damike - ASL?

just to questions about *php code* and you'll be fine

Artnez, …

google search for "fpdf fonts", could you know have done that?
the first result is what you need
you'd have all of your fonts ready by now if you spent that time google searching

Artnez, i still tried to convert manually

whatever, just use google. i believe this channel is to help people learn PHP better, not how to operate proprietary librarys that convert font files to PHP files

"The award-winning Opera Web browser The coolest, fastest, and most secure Web browser available." - those are rather bold claims =/

hello

ShaunOo`: Bold… but true!
Firefox doesn't count because it's an XUL interpreter, not a web browser.

Artnez, no problem so far - but at the moment there a no people here asking PHP questions - so i can't understand why IRC people have problems with that - the "my holy channel" thinking .oO

you are ignored. im not an admin, talk to them :-/

I'm sure there are lots of user in this channel who know where to find fetish gayporn as well. That does not make it appropriate to ask for fetish gayporn in this channel.
s/user/users/

ShaunOo`: Opera is great. Only problem that I have is it doesn't have a lot of community plugins like FF.

which functions can i use to list in a web page the last 5 files that have been modified or added inside a directory ?

ShaunOo`: IE: the web developer plugin sucks, whereas the one for firefox is great

http://xkcd.com/293

Artnez, ahh. IE and Opera - where is the PHP part? …
troll channcel

#phpc

:p
funny pic
anyways

All the functions needed should be neatly categorized in the manual.

do you know them

you were talking about FireFox?

Check under Filesystem and Directory, or something.

k thanks

No, I don't. I do know where to find them.

My Name is Blah My Name is Halb, how do you make it some preg_replace only replaces between the first ocurrence of My Name?
so*

To throw damike off. Nevermind.

use the filemtime() function

is it recursive ?

Generally preg_replace will find the first occurence My and the last occurence of Name
Can you set it to non-recursive?

um, no. you need to specify the filename as a parameter.

No LongBeach. You have to traverse directories yourself.

just loop through the dir and sort

ok, i hope it's fast

If it isn't, don't use PHP.

nah, traversing recursively through a large directory tree is not fast in any way, php or not

PCRE regex isn't recursive by default, if I understand what you're asking that is…

Doesn't preg_replace only replace the first occurence unless you use the global flag…

I want to replace the first My Name not what's in between…

it would help to use special naming conventions for the filenames

I am not sure guys

http://www.the-art-of-web.com/php/dirlist/

tell us the original text and the way you want it to be
can't guess what you want

"My name Chad"

preg_replace('/My name/', ''); ?

"My name is Bob My name Chad", it's already null thankfully.

Artnez, I prefer Opera for PocketPC but not for desktop for some reason *shrug* but regardless, it's THE best mobile browser.
Hell, even IE for mobile is better than Minimo :P

preg_replace doesn't look at the first occurence and stop, it looks at the end of the string and then replaces..

so you want to remove the "is"
is it *always* "is", or can it be something else?

What's your expression?

Well the REAL string is:
"SELECT [….] FROM WHERE ( SELECT FROM […] WHERE [….] )" and I want to replace the FIRST occurence of SELECT FROM and place something like count(*) inbetween it. only the first occurence.

are you trying get total results for DB query?

yes
I have a bunch of union'd statements

there is a better way

So I have make them sub-queries
What's the better way? I haven't see any other way to do it…
heh

SQL_CALC_FOUND_ROWS

Use a non-greedy match.

http://www.arraystudio.com/as-workshop/mysql-get-total-number-of-rows-when-using-limit.html

Or that.

sorry, i had to google it. couldn't remember the exact thing

Interesting, I'll try it.

read the MySQL docs on the topic here: http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows
note what they say about unions
will probably be relevant to your situation

Interesting, thank you so much for that Artnez, that helped me immensely.
No preg_match needed =D

$var, $_POST['var'], $HTTP_POST_VARS['var']

i think im going to buy a hat tomorrow so i can really tip it, thats such a smooth thing to do
use $_POST

ok. just out of curiosity is there a reason why everyone doesn't just use the shortest version?

learn the difference between superglobals, read up here:

http://bin.cakephp.org/view/851322774

http://php.net/manual/en/language.variables.predefined.php#language.variables.superglobals

alright thx

please dont forget to read up on
*register_globals*

well i'm reading a book right now. just haven't gotten to superglobals and stuff yet

how old is the book?

$arr[0][0]['count'] ?

2005. it talks about php5

oh…

but thats the newest

hey
how do you calculate sysdate minus 2 weeks ?

arg the websites talking about php6. i wish technology would pause for a moment sometimes :P

go back to kernel 2.2 then

ha

Thanks Artnez again, that really saved me A LOT of time and actually improved a lot of things

or go back to Rasmus Ledorf's mother womb

cool

Can somebody say 'unbirthing' … ew ..nothing could be more worse

uhh wtf lol

what do you guys think of MVC?

it will save your life
just dont use somebody elses code to do it

what do you mean? not use a lib?
or an MVC framework, rather
im thinking of using CodeIgniter

yeah. Look at how frameworks work, and learn from them, and create your own to suit your needs

well, i did, but it doesnt use MVC
and i'm doing just fine with it

it all depends on what you want your site to do

it actually acts alot like MVC does, except with Models and the file structure is slightly different

if your site has a 'one-look-and-feel' based system, MVCing is going to be a big timesaver
aaah… MVC = Model View Controller
so 'except with models' == wtf?

*without, sorry

oh :P
imo, file structure is unimportant
its how the code is assembled that counts
nasty = include trees

yes, i avoided this well

include("bigincluderfile.php") ?
ive worked on so much code that includes more than nessecary to make a page work, and its hell trying to work out what exactly it does

yes, i dont do that at all. there's only one place where includes come from and that's the main.php file (which is the starting point)

imo, the MVC philosophy basically equates to keeping the problem domain in the one place

i guess i'll stick with my framework, it's been working great for half a year with no problems
was just second guessing myself as i always do to try and better myself :]

yeah, if it works good, and development is fast, i say dont change unless you _know_ something else will work better ^_^

ha, i need to take a week or two break so i can pull my code together and make it rapidly deployable (ie; create an SQL schema and refine it, maybe an installer files)

my biggest task atm is modularisation for easy slap in from one site to the next

i actually just finishe that upgrade

my MVC aint perfect yet,

at the moment the framework comes with MySQL database handler, data objects, session handling, etc
in the config, you set the libraries you want to load
some are dependant on one another, so errors are raised appropriately

why raise errors? why not just be smart and include what you need?

the biggest gotchas i keep having where there are modular interactions, but the interactions are always different depending on the task :/

because there's no overhead by raising the errors. let's say i have a code profiler. instead of including the profiler only when i need it, i can save time by just disabling it
if statement checks of config wants to load the profiler and other dependant classes make sure the profiler is loaded with another simple if statement - no problemo
regarding my page modules, i do a different system than MVC. i have a dir name "modules". my-site.com/my/profile will be modules/my/profile.php

is there a quick way to sort, in a chronological order, an array filled with (value, date) fields ?

usort()

url-php relation is a must, seen too much abuse of mod_rewrite and

thanks

ok so you should use $_POST['var'] instead of $var but what if you are defining a new local variable which obviously wouldn't be in the POST array. $var may not work because the register_globals setting may or may not be on
the book I'm reading just keeps using the $var format for local variables

url-php

Url has at least 1 file that exists in the FS which is an obvious and unique entry point
maybe not for paramters, but use some common sense

my page system doesnt do that, and it works fine. as said: site.com/my/profile accesses /modules/my/profile.php

as it should

nvm got it

i hate dealing with some systems that have doc_root/my_profile.php, which includes like 30 libraries and a 'main.php' file at the top

/my/profile and /my/otherprofile dont both call the same php script, which then does magic

theJackal, well this is how i deal with parameters

yeah, i know exactly waht you mean

lets say you want to view someone's profile
site.com/user/theJackal is /modules/user.php

by parameters, i mean, numbers, names, etc, ie: things youve watned to clean out from the ? part of the equation

what i basically do is traverse the modules directory
using the url
in this case it sees that there is no /modules/user/theJackal.php so it goes up one
and it finds /modules/user.php
then it takes everything that was in front of the found module (in this case "theJackal") and appends into the $_GET method with numeric array
so to access the username, you would access $_GET[0]

thats good :P .. but im saying the problem is when dumbasses do a mod-rewite to site.com/user/thejacakal == index.php?dir=user/theJackal
and then have no file even with user in it

ooooh, i see
when i came up with that idea for numeric keys for $_GET it felt like fate, as all keys for $_GET are strings

you just spend hours looking through code to find somehting as trivial as a html syntax error

the one thing that interested me about MVC is keeping the page module in a class file
so in the constructor i could assign template values each time

and then theres people who combine that stupidty with _NOT_ using MVC, and have about 20 versions of every file

in my case, i need to have seperate files for update/delete/etc
/modules/user/delete and /modules/user/update

and _NOT_ usins svn*

brb

people who dont use an RCS need shot
repeatedly
in the balls
( tennis ) _

i dont, dont shoot only because i do all projects on my own and for some reason every client needs everything "NOW NOW NOW", thus i just skip version control and get coding right away
i've implemented good version control a few times though, when designers and other developers were coming onboard later on
i had one nightmare situation when there was no version control and developers were overwriting updated files with their older ones when they made updates
the amount of times i got the "hey can you update your version of some_file.php because i overwrote it with my old one" phone call was unnerving

is it possiable that the file get command wont let you change the size of your content in your text?

can you rephrase?

ill just tell you my problem
i used this command to get the content of my txt file to display php echo nl2br(file_get_contents('site.txt')); ?
now when i go into txt file to add html it wont work
for example FONT FACE="Times New Roman" SIZE="12"something here/FONT
it displays at size 24 i think
but its not 12 thats for sure

that's an HTML problem, size=12 is not size 12
first of all, start using CSS in external css files. second of all, do "font … style="font-size: 12px;"something here/font

I have a database table that stores, a username and the date when a user loggedin, if the user presses the logout button he gets removed from the table, but if he turns off the browser he stays logged in in the db table, how do i remove him from that table when he turns off the
browser?

http://www.htmlcodetutorial.com/character_famsupp_92.html
there is no reliable way of doing this

i see. Any way that might work?

you need to create an "updated" field, that updates to a new DATETIME (NOW()) whenever they refresh the page
then you could say that if he/she didnt access the website in the last 30 minutes, their session is expired and you automatically remove it

font, what I would do:, add another column, 'lastPageLoad', update it every time they load a page with the unixdate. Add another query that searches the table for any lastPageLoad older than 20 minutes and remove it

you'll need a maintenance function that either runs from cron, or runs on every page load (more overhead) to do this
you can use javascript however

A cron would be more preffered but if you must, just do it on page loads
*cronjob

I think i can manage on page loads, cause the page won't have much traffic.

javascript has an event called onunload(), it is called whenever the page is closed. you can trigger the "logout()" action using this event.

interesting.

Artnez, like you said, not very reliable

Is there a way in php5 to extend more then one class?

unfortunately, some people might have javascript turned off, so it would probably be good to implement both the session timeout and the onunload() methods

I see, thank you for the insight.

you mean like ClassA extends ClassB extends ClassC?
if yes, then no you can't

ShaunO` solution is very good. (with additional column)

-sigh- thanks ;|

http://us3.php.net/manual/en/language.oop5.basic.php
"A class can inherit methods and members of another class by using the extends keyword in the declaration. It is not possible to extend multiple classes, a class can only inherit one base class."

And i get the pageload from js?
Oh no. I get it now.

what you would need to do is use the onunload() to trigger another page via ajax or similar

Comments

I have a database in server it has some MyISAM tables and many InnoDB tables If I look through phpMyAdmin its

but the try/except it supposed to catch that i think..

/usr/local/mysql/bin/mysql

`which mysql` could help

how which
i compile 5.0.41
i compile host 5.0.41
what to write then path to mysql shared libraries directory?

is it an autoincrement issue? doesn't look like you're inserting a primary key

i dont have an autoincrement. the 'groupname' is the key

oh, hm, and an exception is being thrown?

ihaaaaaaaaaa
it work

congrats

sandrot, from where are you ?

US

sandrot, thanks man
SP

ok im totally retarded
nevermind
i had "show exceptions" checked , so when it popped up the exception, i thought it was erroring out..

glad he irc helped kickstart your brain

it was doing exactly what it was supposed to do

=]

well, at least i know im not losing my mind.. that was working fine yesterday!

sandrot, what is the new version of mysql

I don't know ubuntuserver

ok

can you give a full query an alias or variable or something?

Is there any way to do a 'select into outfile' from the command line that outputs to STDOUT? That is, write a query that outputs CSV

will mysqladmin do it?

That's kinda why I'm asking :-D
I can't see anything in the help that will do it
mysqldump is more likely, but I can't see the useful options

you may not get a csv out of the box but if you organize the dump excel or something could generate the csv for you.

excel? I don't think mysql is gonna do excel if I can't get it to do CSV
I think I found what I need in mysqldump
heh .. it just a select into outfile internally
Unfortunately it won't do it to stdout coz it needs –tab

I meant you could take the contents of the dump and import it into excel, then have excel create a csv out of the contens
Hmm

that would be the craziest way to do it :-D
It would be much saner to just SELECT in perl and just output to STDOUT

thought you wanted csv specifically…

yes .. perl is quite able to output to CSV ..

yeah, guess it could be easy to do with perl
nice

much better than having to manually phart around with excel!

fuck yeaH!

I have a database in server, it has some MyISAM tables and many InnoDB tables. If I look through, phpMyAdmin it's size is more than 28MB. But when I check database file size with command "du /var/lib/mysql/databasename", it shows 448kb. How this is possible?
I just came to know this by copying directory to localhost for backup.
and check it through localhost phpMYAdmin

the whole directory is 448kb?

yes

hmm, yeah you're right…

and in localhost phpmyadmin, I see only all tables, but does not have records.
?

I dunno, records have to be stored somewhere else, but I thought the MYI stored all the info

no, in the downloaded directory, for many tables, there is no MYI files, only FRM files are there.

hey

and all these FRM are InnoDB too.

what about /var/lib/mysql/ibdata# ?

has anybody here used the Google patch for replication?

not familiar with it

mmm

1 min

It makes sure that the slave never falls behind

nice

ibdata1 = 171MB

by not commiting any changes until the slave has received them
wondering how well it works o_O

ib_logfile0 and ib_logfile1 = 5.1 M
I do not know what is happening.
But once commented all setting related to innodb in mysql configuration file, I get the database host and tables as it is in server.
Anyhow, thank a lot for response.
bye

see ya

http://rafb.net/p/IAlHxe91.html
Is that possible with a SELECT query?
Hello btw (

what's the problem?

I have a table with fields and their values and one table containing the fields for a particular type.
type, fieldname, fieldvalue.
I can do SELECT fieldname, fieldvalue FROM mytable WHERE type = 0 to get the fields for each item in the table which has type set to 0
Though, I'd like to get one row for each item of type 0 and turn the table 90 degrees so that the values of column fieldname end up being the name for the columns
as my little drawing shows

what's the second table schema like?

Something called PIVOT tables they said in #sql, but I didn't really understand any of the stuff I found on google
I know what JOIN is and that's not what I want here.
I want to turn the table 90 degrees clockwise so that the left most column turns into table header
and the right column becomes the first row

does anyone know of a proper way to input zip codes into a mysql database? the table itself
I want to input it into a table called users i want to make a field for zip codes

Almost certainly, you want a varchar- even if it seems like you want a int or decimal

Im thinking i might need a int

Remember that post codes do not necessarily follow the same format in countries outside the usa

I'm trying to setup the table the correct way So i do not run into problems later

Varchar is best, e.g. Swedish zip codes are 60351 inside sweden, but S-60351 from outside.

im going to end up making a radious and proximity search

I don't know what the structure of a USA zip code is, but I strongly recommend a varchar

alrighty, even tho char is faster?

As far as I know, you'd have to store lat/long to do a radius search

Mark is there a pasty site that this channel uses?

char is not "faster". Benchmark them to see which is faster if you're terribly concerned about performance.

dpaste.org is nice

varchar is potentially faster if your server is I/O bound and most of the rows contain only a short string
The only way of determining what is "faster" is to benchmark your application with real data

yes
dpaste.org is down

pastebin.ca

http://dpaste.com/14919/
I need to do it in the users table
Because I need to make it so when they do the search it gets people in there area

their

thar

If you're expecting a significant number of users, and you want to search by zip, I'd suggest you might want to index the zip column too ..

how would I accomplish that?

(also, if you're international consider just a free-text 'name' as some cultures don't have the same concept of a first and last name)

hang on here is how I was planning on accomplishing this tell me if I'm doing this the wrong way
I was going to go ahead and have all of the peoples zip codes stored in there user section

THEIR

then get all of the information for longitude and latitude and make a new table called zip codes
have the script take the searching zip code use the info inside of the zip code database then print the users profiles because it knows there zip codes
Is this the wrong way to accomplish this?

sounds about right to me .. though are you planning on calculating the GSD to every other zip on-the-fly?

I'm trying to a SELECT a from `table` where LOWER(a) = LOWER(b) but this doesn't work. is there some other way to do this?

Why do you need to use LOWER() ? Why not just use a collation which is case insensitive (these are used by default in most installations anyway)

woosta I'm going to have the Users zip codes stored in the users table, have the data with long and lat stored inside of the zip codes database so it would do it fast

No, it wouldn't

I'm probaly going to end up even caching the zip codes searches too so it doesnt need to calculate instantly

I don't know how many zip codes there are in the USA, but you're going to have to calculate the GSD for every one of them on every request

not a bad idea, but at other times this table needs to be case insensitive.. is there a way to force the collation for the duration of the comparison?
(rather, case sensitive!)

Woosta, I dont just have usa

Then you MUST cache it

I have canada, all of uk australia and many more

However, I wouldn't bother

I believe there is, but you will lose the ability to use indexes if you do this. Normally if you use = to join two indexed columns, this is a good thing

Just have a table of 'close' postal codes

the tables are small, it's ok

You'll find that due to our government's idiotic information policy, getting location data for postcodes will cost you money
(I mean here in the UK)

I already have them :-p

You can calculate the GCD just once then for every postalcode-pair, and store the closest N

fresh from 1 month ago

What, all of them?

yes

I assume you paid money, it is NOT free

I know the owner of a data company

the information is 'out there' ..

It is out of date and potentially wrong however

sure

he paid
I didnt
:-p

All because our government is too stupid to see the public interest of making it free
Curiously, in the USA this info is free

lol

is it?

so should i use varchar with int? or just varchar

In our country, healthcare is free but post code geocoding data costs money
varchar.

ok

Why an int?
jsut a varchar

I can't see Moore making a film about the geocoding data though

And as I said, you DO NOT want to calculate the GCD in real time, ever

mhm, what is the benefits to using char then?
Curiosity guys
I'm learning =p

It can store post codes for countries other than the USA

alrighty
how many characters?
do you think

Erm
Don't you have the data already?

i dont know how many uk has
its on my laptop
lol

So .. have a look there
Pointless asking us

grr now i have to get up and get it haha

As far as I'm aware, the longest uk postcode is 7 chars, but don't count on it

We know databases, but can't really tell you much about international postal codes

well one of you all said you are from uk
ill go safe with 15
varchar(15)

If anyone can help with this, please do. I'm at a complete loss.
MySQL won't start. InnoDB just gives out an error … let me get it
It tries to process the binlog, one that doesn't exist and is removed from the index.
Error: tried to read 16384 bytes at offset 0 770048
Was only able to read 8192
Error Number 22 means 'Invalid Argument'
read
Cannot continue operation

Are you sure it's trying to process the binlog, not its own log files?

It tries to open a non-existant binlog then errors.
So I made a backup of the ib_logfile's and deleted the original to try again.
But it's just odd … it's trying to open a non-existant binlog.

If you don't want to recover the server from a backup and it's not a replication master, you can safely remove (or move) all the binlogs and their index file. php mysql web hosting will start again from 1.
Be very careful what you do to a production system however
(obviously)

We did remove the binlogs.
It's still trying to open them for some reason, even tho they aren't there.
This time I got a I/O error after it said it was trying to read from log-bin.000008
Hey … question.
ib_arch_log_000000000000 what's in there?
I just tried copying it to my backup, and the disk gave me an I/O error

If your disc is giving I/O errors, you have other problems.

Oh I know.
I'm trying to get shit off this drive, but I need MySQL up to do it.
Can I safely try and delete the ib_arch_log file?

If your hard drive has failed, you may as well restore from a backup
I don't know.

The drive isn't failed, yet.

My servers never seem to have one of those. We use 4.1

Ah

If it's giving IO error, the drive *has* failed

Yeah, backups on this box are very hard to make. Something about 2.5 million tables.
It's just this one file.

2.5M tables sounds like too many to me

So it's that part of the drive.

hey guys Im going to do one more pasty really fast

And yet I can delete it.

if you go to http://puqs.com/install.php if you go here http://dpaste.com/14920/ that is my code I'm trying to make it force into the database
there is an error on the last line am I closing it wrong?

Don't use PHP short tags
Does your user have permission to create tables? WHat happens if you execute the same command from the mysql client?
Are there some quotes missing in that script?

if i drop the table in phpmyadmin it works
but I cant get it to run this way

Stuff phpmyadmin - use the mysql command line client
It looks like there should be a quote on line 16

how do i make it work without using any client
just the server

Use the mysql command line client to test queries in your development environment. Don't use phpmyadmin for anything, it's made by idiots

") ENGINE=MyISAM;" ?
=[ I'm still learning just started today figured the best way to learn is to take my time and learn as I go along
been reading tutorials and such
Mark, the query works
It's getting the php hosting to drop the files in the database
that is not working i have all permissions set on the database

hellas
i have installed the xampp package and would like to install a forum
but it cant find the php mysql web hosting server

not found"

This is a mysql channel, sounds like you're using some strange bundled package. Consult the winmysqladmin support people or xampp.

ya
ok

line 42
better yet…
supplied argument is not a valid MySQL result resource in /home/made/public_html/www/doc-root/flipcide23/index.php on line 42

This is a PHP problem, you have failed to correctly call mysql_query, or not checked its return value. Probably there is a problem with your query.

thanks

hi everyone!
when I've got a 'enum' field, can I order per value? so like: order by enumfield = "open", enumfield="close", … ?

insert ignore
does that mean disregard errors
ignore insert errors?

I believe it only applies to duplicate key errors

cool thats what i want
second question. structure question

Other types of error will still be reported

i have a product inventory table

it means you have to read mysql.com/insert

i want to add a feature to TRACK the old prices of products (when doing a big database update)
so the way i'm planning it is. a second table. old_prices
ProductID,Price

You would surely need to have a date/time of when the price was current from / to

nah. i'm only tracking the last price
just so i can show on the product page Up $22 or .. Down 13$
anyway the dilemna is… how do i set the change to Zero.. if the price is the same?
Inventory (current invent) and… NewInventory (latest inventory & prices)
all i do is update inventory,newinventory set i.price = new.price where i.code = n.code
wait i think i got it

Why not put it in another column in the same table?

i dont like too many columns in one table

Prefer new columns to new tables, mostly.

and because that would destroy a million other things in the database host update system

Why?

cause of the way my system is built thast all
update inventory i,newinvent n,pricehistory h set h.price = i.price where i.price != n.price and i.code = n.code and n.code = h.code
hows that

I'd just do two updates
But again, I'd put it in a column

nah man
you heard of Normalization?

Yes I have. Having several columns does not violate normal form.

sure it does
dude
you can't denyyyy. that PriceHistory should be a table
look at the name. it screams tablify me

If you only want to store one historic price per product, you may as well put it in the product table.
If you need several, you need another table.

nah. just pretend that i want to store date & other prices
ok you win in that regard i geuss
but ill still make a second table cause one table is 2 much
work

If you're storing it so you can display "was £5 now only £4", then you only need one
One table

yeah i know
i knwo this
but i have to do 2 tables
anyway a table JOIN isn't that slow is it

A table join isn't generally that bad, it depends on a lot of factors however

ah yep

someone how knows how to sort on multiple enum values? like: order by enumfield ="open", enumfield = "other" ?
didn't try this, but is that possible?

roxlu, itis

grouped by location. Whats the best way to do this?

ORDER BY created, location doesn't work like I want. and neither will location, created
Is this a programming issue or can it be solved with a query?

group by and order by

SELECT * FROM `job_listing` GROUP BY `location` ORDER BY `created` desc LIMIT 5 ?
doesn't seem to work properly
Anyone?

so customize it to your needs

and when you remove the quotes?
ah..

What?
The quotes dont matter

god damnit

How int he world can I repair an innodb table?
Incorrect key file for table 'table'; try to repair it

sorry ’bout that one :P

Hi
Whats wrong with this syntax? INSERT INTO packages (name, major, manor, release) VALUES ('error-0.1.0.zip','0','1','0');
bWhats wrong with this syntax? INSERT INTO packages (name, major, manor, release) VALUES ('error-0.1.0.zip','0','1','0');/b

Comments

i have a database query returning me array elements with NULL for some of the values issetdata[Column Containing

I create 10 XMLHttpRequest, but response are serial, not parallel as one would expect

because of the browsers limitations

I see.

if you start 10 copies of wget, or something like apachebench, it can handle as many connections from the same ip address as you've got threads/processes to handle
unless you have a module which limits the number of concurrent connections per dedicated ip hosting address

So, neither FF, nor IE, nor Safari handle that?
yes, you're right too.

it's a browser limitation to stop you from ddosing the server or client, but yeah I thought it would atleast be able to do one other connection in parallel

ok, I see your point. Sad

How exactly can I access the @attributes array from a simplexml_load_string response? I can't do $xml-result-@attributes-hid.. ?

did you try it without the @?

yes

$xml-result-attributes()-hid ?

did you try reading the docs?

!rtfm

that gives compile errors

http://uk2.php.net/manual/en/function.simplexml-element-attributes.php

I wonder, though, how can a browser 'decide' how to have the request handled by the server.
I wonder, though, how can a browser 'decide' how to have the request handled by the server.
it just sends a 'packet'…

so you have to iterate (foreach) over the attribute array to access a specific value??..

yeah but the general concensus was that less connections is better, so for the past 5-10 years they've been leaning towards that

you may be able to use xpath or something

for example, if your browser loads a page which has 1000 images on it, it doesn't start up 1000 new http connections to try and get all the images at once

keep-alive!

you mean connections are held and not forwareded until the 'channel' is free?

ste, it uses 2-3 connections because it's more effecient with traditional websites

ok

yes

Very lame.

although AJAX is changing the requirements somewhat

ste there is still only one string between server hosting and client

Ok, so I'm done
the browser, yes, access.log states that request are ISSUED in a 'serialized' way.
won't blame php anymore. won't blame apache anymore. 100x.
won't blame php webhosting anymore. won't blame apache anymore. 100x.

ste, read the HTTP RFC

hehe, the whole beast? About what?
well, one may also say that 10 simultaneous connection to a single server is not even sane, actually.

ste, most browsers will use keep-alive and pipelineing to open a small pool of connections, and then they send a bunch of requests all at once in each connection, then the server responds when it can keeping the order consistent in connections
it reduces the latency caused by the SYN/ACK of the TCP connection, most browsers will open one connection, then pipeline 8 requests to it, and repeat until it has issued all requests for the page

I'm having a brain fart right now, I'm trying to process using recursion, an unknown depth of multi-dimensional array, http://pastebin.ca/644245. Any help on the logic/

ste, but read the HTTP RFC, and most of it anyways, skim over it so you at least read every header (though probably not the full descriptions), it will tell you what is valid and what is not and how the browsers interact with the server

lo

CrazyTux[m], you can do that without recursion…

HarryR, enlighten me

gimme a few seconds

ok, thanks. I suspect actually that this behaviour has something to do with avoiding floods of requests to a single server

HarryR, thank you, I haven't came accross this problem in a while, and it's 5am, so, not thinking to clearly :P

uh, im not quite sure what you're doing though

How to clear cache with php ?

oh right, getting all keys, and putting them in $data[$key]

ste, for your stuff, you asked if PHP is thread safe, yes it is, but you have to understand that browsers always pump stuff out in parallel, and your session data is written at then end of the request, so if you do stuff wrong your session file can get clobbered

you can't do anything with the browser cache, but you can control it's caching behaviour using header()

HarryR, it's basically a prototype example to be applied in other context.

ste, you can also download safari, get the nightly webkit version, it has a debug thing where it will show you when the requests were made and in what order, when they started, basically everything

HarryR, I want to maintain the tier, basically, and recreate the same array…

uh not quite getting what data you want to apply it against

HarryR, the real purpose would be to take a unix path i.e. /some/path/ and start at /some/path/ and create an array file struct.

How to control with header

my requests are independent. 10 requests that will update 10 different blocks in the page.
but actually I see they are pumped out one after another

uh right, with all the files in there too?

array('a', 'b', 'c', 'd')))

HarryR, correct

k you're doing it in reverse though!

HarryR, what do you mean?

at least, looking at access.log. But ok, I see what you mean.

ste, http://webkit.org/blog/wp-content/uploads/2007/06/newinspector.png

oh nm, you're going to be giving it an exploded path?

ste, that is very useful

HarryR, no, just a single path

see php.net/header, Caching directives

but as an array

HarryR, those paths were file structural examples.
HarryR, /a/b/c/some_file_a, /a/b/c/some_file_b, etc

ok, thanks

HarryR, well I'd be using either old fashion opendir/readdir or SPL (DirectoryIterator)

argh

HarryR, but I want to pass a single path, and create a structural array of files based on that path

7pm, lunch
k I see

HarryR, I'll be around , if your still up for running me through my logic thoughts when you get back from lunch.

hey
i need some help with building a logic
http://paste-bin.com/12184
a href="http://paste-bin.com/12184"http://paste-bin.com/12184/a

where can i get googlemaps support?

CrazyTux[m], it can be done using one array like a stack (LIFO), just loop until its finished, no recursion needed

td width="86" (single_cat_title() == "blog") ? 'bgcolor="white"' : 'background="http://www.101greatgoals.com/wp-content/themes/default/images/header_white.jpg"' ?/td

foutrelis www.tangocms.co.uk ^^

do you guys see an error?

hrm?
that's filthy, don't do that
just give the thing a CSS class and assign presentation based on that

PHPadam, don't use short tags for one…and i agree with f00li5h

then you can use .blog .post { background-color: … } and .news .post { background: url(…) } to stick formatting to the cells

edman007, So traverse reversed?

PHPadam, single_cat_title() is a wordpress tag, i presume? Your usage is wrong.

CrazyTux[m], you make a LIFO (Last In First Out), open the root folder, loop through it, read everything into your output array and put the folders on your LIFO, then when you finish looping through a folder you read the next one from your LIFO, your done when the LIFO is empty

edman007, so in essence storing whole paths in an array and filtering in the end?

yea, the LIFO is the list of folders to read, and your final output array will grow as you progress

$phpbb_root_path = '../forum'; which is my phpbb.php file in public_html to link to the forum folder in my root? http://images.uploadimago.net/?s=30416Untitled.jpg

Is there any way I can typecast my php vars?

imme, yes

imme, yes.
$integer = (int) '1';

and string?
(string) ?

anyone?

Or is that called datatyping?

Mech0z, this is not PHPBB help

it's called typecasting

I'd like to define what datatype the vars are inside my class…

how do I see if the php host is compiled with –enable-fastcgi support?

hello friends

$string = (string) 1;

edman007 its not really a phpbb problem more a php problem

thank you.

settype will probably work.

settype, great, thanks.

sure

f00li5h you know yesterday we was talking about clean urls?

hrm?

well i now understand what you were saying, ive read up on it real good

oh, neat.

let me come back to you on this one

sure

can you read what I said in #apache f00li5h?
I'm 99% there

rick111, where is the other 1%? wondering the streets?

im being bulled by apache

edman007, I'm still having a problem comprehending how exactly to go about this… I don't see how to grab the structure to begin with is possible without recursion? given Nth number of dimensions?

bullied

CrazyTux[m], it actually scales better then using a recursive function, lemme get you a little demo function

edman007, thank you, appreciate it, yea.. I try and stay away from recurssion.

CrazyTux[m], you keep a reference to the parent in an array
and use each() on it

what's happen with mysql_connect() function? It shows "Undefined function"

great tool (webkit inspector), really!

Congrats on the site

thanks I'm so happy to release it finally ^^

AlexC_ lets see

www.tangocms.co.uk

Have you installed the appropriate mysql package?

I installed using
sudo apt-get install ubuntu-lamp

never knew that exists,

however… yes.

try sudo apt-get install php5 apache2 libapache2-mod-php5 mysql mysql-serveer
and php5-mysql

Lamp stands for Linux Apache MySQL Php (you know…)

yes I know :P

or perl/python

i don't know there is a ubuntu-lamp package

it's not in my repositories

AlexC_, "mysql" not found

woops, sorry
sudo apt-get install php5 apache2 libapache2-mod-php5 mysql-server php5-mysql

If I declare a var or a const as a property of my class, why does it complain about the value of it being inside an array?
Example; const request = $_SERVER['REQUEST_URI'];

pastebin the line and the classes

No need to pastebin that, right?

i think that may be too complicated to go there

HarryR, so reference the parent being the value of the array?
HarryR, $a = $a[key][] = some value…

AlexC_, thanks a lot, it works

HarryR, or something like that/

So, I should put it in a var and put that var inside a construct?

AlexC_, now I have to understand how… humm bye bye

you're welcome

ghehe… php.net speaks: "The value must be a constant expression, not (for example) a variable, a class member, result of a mathematical operation or a function call."

that's a bit silly, but true

yeah, that's silly

anyone familiar with nusoap? I have a question…

you there?

CrazyTux[m], http://pastebin.ca/644303 …all well i'm slow

edman007, thanks, let me take a look

CrazyTux[m], and actually line 8 in there is garbage, it does nothing…

anyone familiar with nusoap? I have a question…

edman007, alrighty, let me examine this, and see if it makes any sense.

XeroCks, if i say no will you not ask your question?

what does that do again?

exactly
i'm trying to accept a request, containing a bunch of string elements and one list of strings

f00li5h, recursively read a folder into a multi-dimensional array without a recursive function

i can't get the list part to work

also, you want to read from the directory and close the dir handle before you recurse
oh, sorry
i did one of those just the other day, but in perl

Hello
is it possible to add an interfase to add Linux users through a php web page?

It is but I'm not sure if it's the right way to go

why not?

I mean, you can execute linux commands to add a user with the functions at http://php.net/exec. As far as security is concerned this may not be a safe way :P

corpulunt, possible, yes, but you really need to know C as well (or any other compiled language) to do it in a secure fashion
….well i guess you can use other scripts if you use sudo….
but you need to basically have a fronted that executes something that ads the user, and that requires escalating your privileges (so sudo or setuid)
corpulunt,

since you can't avoid passing your user input through a shell, none of php's run-commands type scripts are safe

that sucks

use ldap with pam

f00li5h, you can

how?

open the executable with a constant (so no user input) and pipe the user input through stdin

sure, and all unix binaries read their options from STDIN?
also, that doesn't avoid the shell
the shell is still invoked to run the binary

f00li5h, well write one that does accept it that way, or write a C wrapper to do exec() the C way

write another exec type function for php?

write directly to /etc/passwd, /etc/group and /etc/shadow
and create homedir

can anyone see why this is not running? echo shell_exec('/crontab -u cowen /var/www/time/crontab1.txt');

f00li5h, exec('/app/bin/binary', 'app-name', 'arg1', 'arg2', NULL); there is no need for escaping with that call

what? why?

yes
to avoid shell when adding use
r

but php doesn't have that one, does it?
i'm not adding users

no, but thats where this discussion started

and if writing to /etc/passwd was a good idea (see also: isn't) i'd still have to put the column there

f00li5h, the one in PHP parses it in PHP or sends it to a shell to parse it

and as you can see it was not directed to you

which one parses it in php?

there is also a shell escape that will do

shell escape is garbage

f00li5h, http://us2.php.net/manual/en/function.exec.php

i can set my sell to all manner of confusing things, for example, my shell could find f to be a magic character (if it wanted to)

look at the C function, man exec
it takes multiple args so you just need to pass a valid C-string

who's being passed a C-string?

Hi

f00li5h, man 3 exec

Hi all. Can you suggest me a good Linux program to create web pages (writing by hands) ?

oh, right
g?vim

uh?
"g?vim" ?

vim or gvim

So, they'll probably add this assign_return_of_function_to_const thing to php6, or not?

emacs for PHP…

f00li5h, I tried Screem (not good highlighting but good automatic completion) and Geany (not automatic completion but good highlighting)

vim does both of those things

uh, good…

ZmaX, bluefish/Quanta for HTML editing, but they are too bloated for me

auto completion is annoying

TehSausage, not me :P

propably not

not if you have to demand it to happen

What exactly is the purpose of SSL/OpenSSL/TTL and stuff like that? I've been programming PHP/MySQL etc. for many years but have never got in to it.

why not then?

So I'm wondering what the purpose and implementation is like
As in, why use it, and for what reasons

vim requires me to say ^N or ^P to get it to produce the list

thats against the nature on constants
on=of

Along with how difficult it is to implement in projects that are near completion or very far along.

Kcaj, so i can't buy stuff with your CC when you go shopping at the coffee store

f00li5h, what is the difference between "vim" and "gvim" ?

/dev/null 2&1 &"');

http://www.paste.co.za/8

gvim has gui bits in it

I do not understand, the "variable" $_SERVER['REQUEST_URI'] is a constant itself, within a call, not?

menus and button bars and the like

edman007 Okay, so basically, OpenSSl if I implemented it, just makes all communication between the client and the server encrypted?

not

Kcaj, for HTTPS, yes

its a superglobal

f00li5h, ok thans a lot for your suggestions!

You might also like to take a look at easyeclipse

yeah?

heh, gvim actually works on here
hmm, vim with a gay font and menu's… cool

It's an IDE. Just take a look at it.

lol

It's java absed though…
But the superglobal doesn't change all the time My PHP-program is running…

it's the variable's name
but that doesn't make it a constant
$foo = 'moose'; #never changes, but is still a variable

the gza, the rza, methodman, redman and ODB omg the wu-tang clan, ghostface killah, and etc.
!seen OldDirty[Bastard]
I haven't seen him on in years
omg, overdose :O

i haven't seen 'olddirty[bastard]' sicne he overdosed and died, Kcaj

I'll read up…

hello
any nginx users out there?

hello simoncpu

fifo_, i would say its one of those undefined behaviors, but it is somewhat unexpected, if you file a bug report i bet they will say its not a bug

never mind

bah, i can never get gnome to start ;(

fifo_, foreach ($ar as &$bugVar); gives different results as well

I still don't really get it, if I got a variable and I want the current value of that variable to be assigned to a constant, why is that not the way constants work?

imme, assigning implies changing the value, "constant" means something that does not change (look it up in a dictionary)

could you set it to a reference to a variable when you define it?

I'm looking for some suggestions or hints how to make a website login that would also login you to phpBB forums at the same time if you know what I mean. And also, how would I keep sessions up on the website then…coockies or what would be the proper solution in your opinion?

That would mean constant could never get a value. I'm talking about the first assigning…

imme, the define() for the constant can only occur once, and that is where the constant is created, in many other languages constants are things that are done at compile time (so it should give you an idea on how people expect them to work)

Yes, and with define everything goes well. However, when I want to define a const inside a class, it does not,
define('req' , $_SERVER['REQUEST_URI']);class tst{const request = req;}

edman007, it probably is not a bug.

class tst{const request = $_SERVER['REQUEST_URI'];}

edman007, but just to relieve my frustration in finding this bug, i'm gonna give them a headache

imme, thats because define() is a function, and is done at runtime, a class constant is most likely done at parse time

edman007, at least a glimpse of a headache

just because something works, doesnt mean it's right

fifo_, you ever mess with sessions and have register_globals on? it does the same thing, but a bigger scale

it's possible to access private/protected properties with some useless string parsing, but you don't

fifo_, echo $_SESSION['myVar']; $_SESSION['myVar'] = 1; $myVar = 2;

Do you think it should not work like this?

fifo_, that ^^ is inconsistent depending on register_globals

you shouldnt have to store a variable in a constant
just use the variable
define('HTTP_STATUS_NOT_FOUND',404); # good use of constants

imme, class constants are generally used as parameters to class functions, and their values should almost always be integers (though strings would do)

LOOK AT THIS PAGE ITS VERY FUNNY
http://www.pennergame.de/ref.php?uid=2349
THANKS
http://www.pennergame.de/ref.php?uid=2349

spammer.

Is mb_convert_encoding not supposed to convert & to amp if you pass "HTML-ENTITIES" and "auto" as the 2nd and 3rd parameters ?

icio, did you RTFM?

no, where should I be tryingit ?
oh, LOL
newb
yes, I did.

hey.. what php ide for windows would you reccomend besides PHPEclipse?

I'm not exactly sure what I'm looking for, though :/

input id="site_update" name="site_update" type="submit" value="Update"
once you click this, does a variable in $_POST get set?

HTML-ENTITIES OR HTML_ENTITIES ?

Vme, site_update is set to Update, so $_POST['site_update'] = 'Update'

- (dash/hyphen), like in the manual

$_POST['site_update']";
i try this

and stuff like that

it fails
i get nothing

if you read the manual is says that

echo $_POST['site_update'];

mb_convert_encoding ( string $str, string $to_encoding [, mixed $from_encoding] )

you should understand how strings works in php

2nd is TO, 3rd is FROM

what is wrong with my syntax?

meh…i need sleep, 20 hours is too much for me

I'm trying to convert the likes of © to ©
try echo " HERE: {$_POST['site_update']}";

icio, htmlentities()

and "

thats htmlspecialchars()

Anyone have any fancy suggestions on how to impliment javascript alerts into my php programs?

with javascript?

Right now I basically have it sending a header location with a variable containing the message which shows on page reload when $alert is set.

well, there are options, I prefer printf('HERE %s', $_POST['site_update']);

what does that mean?

Which works nice… but when they hit the "back" button, it obviously shows an old alert.
Style_Info.php?StyleID=".$_POST['Style']."&alert=Hello My Friends");

MrBojangles, scriptthrowError("php echo $error; ?");/script
just make it good HTML/javascript etc..

throwError is a javascript function?

hi people it exist any function that return a first letter? examge +Pepiro the function return +

strstr, I think
to Dj-TaMPaX

thanks MrBojangles

Dj-TaMPaX: substr()

use substr(0,1,$variable);

I think you'd redirect to the old page, only with the alert, and if the alert is solved they get to go to the next page.

I just looked it up in my code

you can also $first_letter = $string{0};

why not just use a ticket queue, like bestpractical.com/rt

curly braces style is deprecated, right?

for subscripting strings? yes.

i have this in .htaccess but dont work, and i have in first line RewriteEngine On, i have mod_rewrite loaded and AllowOverride None

/var/www/test/urls.ph
/var/www/test/urls.php

Did you check to make sure that the .htaccess is pushing the url to the php file?

how does that relate to php?

yes

#apache … :P

if apache does send it to the php script it does if not it doesn't :P

I was just gonna say.. it DOES have .php extension… lol

i have a database query returning me array elements with NULL for some of the values. isset($data['Column Containing Null']) will return false on these despite that the variable is set to a NULL value. is there a better way to test if the variable exists, even if the value is NULL?
a .php function doesn't make it magically sent to be parsed by php
* file extension

if==NULL or ($datap[])
if($data[''])

does it really have null in it? var_export($data['column'])

checks against NULL, FALSE, and

is_null()

that'd throw an error if the array element (column) doesn't exist
i did a var_dump

and what type was it?

NULL

softwork:do a var_dump or print_r on $_POST and $_REQUEST to see what it is getting

well, is_null is what you're looking for

if ( isset() || is_null()) ?
php throws a Notice if the element really isn't set at all. i can't guarantee on the returned elements

have you got error_reporting and display errors?

yes. but turning them off seems premature…

who said anything about turning them off?

okay, i was assuming that would be the next logical thing

never code blind

i don't like coding blind -_-

the last place i was at had notices disabled
it sucked

and i scolded my colleagues for doing the same and then turn it on for them

notices disabled..yuk

I turned it ON for a couple of requests while debugging, and it broke so much stuff
like it even broke sessions (because notices happened before the cookies on login)

now about the problem of detecting variables that were set but have the value of NULL and can't be guaranteed to exist?
what about ob_start()?

you should know if they're going to be set
ob is not the solution there … fixing the borked crap code is the solution
why would there be variables that you don't know about in advance? you put them there

on line b34/bbr /

ob would buffer it so that the code would work while you stamp out the notices/warnings/errors

the line is array_push($nicks_tratados,$pepe);

Dj-TaMPaX: you are not allowed to ask any questions about that error message

and $nicks_tratados = array();

Dj-TaMPaX: it's not an array, it's that simple
you've assigned something over it somewhere

but i have this line $nicks_tratados = array();

not actual variables, but data returned from the database. i can't guarantee that the columns. they may change without notice. i'm using SELECT * FROM

what's the best way of implementing a verification of email system? (eg sent an email that verifies your account when you register)?

Dj-TaMPaX: it's not an array, read the message
not implementing it, go and find someone else's code to do it for you
don't use select * from

is that a suggestion or an accusation?

both.

I've got an idea of how to do it
I just wanted to know if there was a "trade standard" way

i know of the "SELECT * FROM" is considered harmful.

you need to know what dataset you're operating over, selecting extra stuff that the code doesn't use is wasteful (since it's ignored) and selecting less is useless, because the code can't make it's decisions
select what you use, and use what you select

in my case, it would be * all the time.

then list each column

and to do otherwise would result in the code blowing up in size by at least 10x

if i alter the table, and ad a blob column, you don't want to have that column retreived all the time
how?

because i have hundreds of tables

Not an apache spesific question, but I'm trying my luck anyway. I've installed suphp, and it's not giving me any errors, but scripts are being executed as cgi-php, instead of the user. What have I misconfigured ?

how?

maintained by database n00bs

do you really WANT to select all of the hundreds?

well, that needs fixing too

and i can't replace the n00bs because that would mean kicking out half the country
tho that would have been nice

but you can't change the schema until you know what is used where

Can someone help me out with an SQL query, or point me towards a better place to ask? Simplified, I have two tables, orders and line_items. Line items have a boolean column, in_stock. I want to select all orders where every line item is in stock. Any ideas? I'm using MySQL.

#your-database
once you know which code uses which columns of which tables, you can start changing the database schema

?

becaues you know what code will break when you make each database change
#Mysql

no. i don't want to select all of the hundreds. only one table is selected at a time, depending on what lookoup the user is doing

Oh duh ok.

how do I check if certain table exists already in php?
in sqlite
in php

sounds like you need to … gah I don't know I'm new at this stuff I think a switch might be necessary though

your tables should be created when you install your application
they should just be there from there on

i've been around for a few years. don't worry about it. first time i have had to deal with NULL values though

f00li5h, I want it to create a table if it doesn't exist and if it does, it just uses it
f00li5h, I hate assumptions in coding

the user you connect to the database as shouldn't be able to alter the schema
you are allowed to make assumptions, if you ensure they're true before hand

doesn't creating a table that already exists return an error?

f00li5h, so can it be done or do you not know?
I have no idea

it can, but there is no reason to do it

I would guess so

:/

it will make your application more complicated and less secure

meh, then I'll assume

it will also make it more fragile

check the table "sqlite_master" for an entry

but you don't want to have to check for the table before every query

from a security point of view, if your malicious attacker with intent to destroy gets in the system you have lost when he exploits a user account with the DELETE privilege

of course not
sqlite is an embeded database

i'm aware of that. with the publicity surrounding firefox

deadroot, I'm creating for my own use on my own computer with http server bind only to localhost
so the security isn't really an issue

then it being fragile and buggy is still going to be an issue

feel free to use root then.

it'll be on localhost, until someone sees it and thinks "that looks useful, get everyone a copy"

like there is a hacker for every ten database sites

and even more users… users do all manner of things to your application

deadroot, 10 hackers for every 1 microsoft db site
f00li5h, I'll remember to use magic quotes!

DON'T USE MAGIC QUOTES

why the hell not

escape them explicitly!

deadroot, what does that mean?

magic quotes leads to sloppy programming. there are times when you don't want to escape that ' or "
and when some smart guy disables the magic quotes without checking the code, there goes your security

place holders for the win

you should escape at a low level an for the target - not generic
and

yes, times like printing the data the user just submitted

or builing an sql statement (if not using prepared statements)

why would you not be using prepared statements?

IN ()
old databases, old php versions, …

for me, i would escape the data when storing into the database, and then use htmlspecialchars (generally) when returning the data to the user

yeah

wow I feel honered…. just found an online game thats a 99.9% rip off of mine lol

how do you know that they ripped you off, instead of a pure coincidence?

and for sqlite it is sqlite_escape_string()

i'll pay IN ()

SeanB, what is it called?
SeanB, also, did you invent it originally?

They keep trying to advertise on our site and they acually have parts of my HTML comments

dynamic conditions :-)

Not the genre but the game yeah

well… the audacity of them

fun!

I actually enjoy it since it's such a bad ripodd lol
*ripoff

(not really)

Even down to the old ticket center we used to use is copied lol

tags in ONE script?

Yes

yes

Praise the lords!

it buffers the whole script

you can even call them more than once, recursively!

morning all

sup AlexC_

ahh not much :P just relaxing on my b'day ^^ … not sue why I am on IRC when it's my b'day but oh well!
s/sue/sure
yay, what I've always wanted

f00li5h, I was actually thinking about writing one

oh, rly?

but the time it was published, it would be outdatted, surely 6 would be out before then

hi

f00li5h, ntrly

well, the trick is to not make it about php5

make it in general,
then explain some of the ways of doing it for those versions

I can't help but think that if everyone held off for that reason, we'd be somewhat book-less.

or you could write the book about a langauge that doesn't break major volumes of code with each release

there are some generic programming books. there's even one highly recommended one that doesn't even focus on programming. iirc. don't know the title tho

is it the gang of four book? i hear that's quit egood

I know some too

s/ eg/e g/

might be

a really good one imho is the pragmatic programmer, it's a generic best practices book.

I hear that's a good one, but it didn't seem pleasing when i was reading it at the shop

also I find antipattern books to be handy for that as well
f00li5h, any reason why?

amazon, AU$40, Borders, AU$70
bastards.
I guess I just didn't like the tone, or something

yeah books are expensive, I have a metric shitton
probably have several thousand dollars worth of books

you have a what now?

f00li5h, a metric shitton

what's that then?

f00li5h, it's a unit of measure

oh, i see
weight, is it?

yeah, it's ambigously large
it's bigger than a crapton

Hi all

but smaller than a holyfuckton

cyth its hard work cataloguing a large pile of books

If I have one function which connects to a MySQL database and another function which uses the connection, should that work fine so long as the functiont hat connects to MySQL is run first?

and all of them weighs less than the ether
yes

archivist, cataloguing is for the OCS types, my cataloguing contains rummaging throuh a pile on my desk or floor

hehe
only desk and floor

are all of those books actually useful stuff that you can't learn from the net?

Is there anything wrong with this?

s/OCS/OCD/
the one's that I don't read much are on bookshelves

$query = "SELECT content FROM templates WHERE theme='$GLOBALS[theme]' AND group='$group' AND name='default'";
$result = mysql_query($query);
$data = mysql_fetch_assoc($result);

mtappenden, your not checking for errors… that's a big problem

have you tried echo mysql_error()?

No shall try that now

deadroot, most books I have are replacements for crappy documentation on the net.

Well this is what it says, but I don't see anything wrong…

I find tutorials to be to brief, lacking in theory as well

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 'group='support' AND name='default'' at line 1

#mysql

mtappenden, to debug… echo your sql out to make sure it looks right
after that, #mysql

kk
thanks

/mxg php-bot guidelines
hey all..what is the best SOAP server to use these days? Is that PEAR SOAP? I've been using nuSoap but have run into some limitations

how can i remove all ' — these from a string?
city='here',state='there',etc..

php.net/str_replace

zwi, php soap?

php soap … pah, what next - php shower geil?

What is the real difference between PEAR and php soap? I'd like to be able to generate a WSDL on the server.

i don't think php soap has that ability
I hate using soap :p
REST ftw

hey guys

cyth I'm sure your friends hate you for hating soap as well!

AlexC_, nah showergel!

^^

I've been using nusoap and when working with the WSDL have found some shortcomings…So thought I'd try out pear soap since it seems to be the successor. I can't even get that to generate a wsdl…segfaults at first (which I've worked around) but no WSDL at all
What I'd really like is to just have a WSDL that a soap server can use and go from there..any suggestions?

in php, if i want $blah = system("/usr/bin/file $name|wc -l"); — how can i get it to be quiet ? when i run that.. it works.. it gives me what i want, but it spits out the answer
so if the answer from that system command is 1, it ends up saying 1 and 1 twice.. once for $blah = system("/usr/bin/file $name|wc -l"); and once for echo $blah;

Hey how can I have let the user of a form attach a file to the form, that then gets sent to my mail scirpt?I need to know how I can attach it to the email

BigMac, you'll have to learn how emails handle attached files and do that, it isn't too hard, just have to have the right headers and base64 encode the file
or you can find a mail class somewhere that makes that easy

Anywhere specific I could learn that stuff?

I would suggest checking out the PEAR:Mail since it has MIME encoding right in it for sending/recieving etc

I have a page which refreshes for every 10 mins. and it has a image which should be only refreshed after 1 hour.
how can I do this?

BigMac, http://www.sitepoint.com/article/advanced-email-php

n/m about my question, got it sorted

BigMac, I would like to override SeanB's suggestion and suggest the newer Zend_Mail (part of ZF)

Hi all. Regarding vim/gvim, it has a very good highlighting but I cannot setup the auto-completion…

so is there anybody in here who would consider themselves a soap/wsdl expert (or at least darned good)?

#vim then?
or #linux #yourdistro may be able to help,

lol
AlexC_, I am sorry.

anyone here use php with a ldap database?
sorry
type
o

is it possible to do concurrent programming or threading in PHP that works cross-platform?
pcntl_fork in only available on *nix systems

amgd, nope wrong language
try ruby, perl, or python

i want a php frontend that will submit info such as username, contact, serial numbers, and products

Yah, neither of those make any sense to me :/

I would, but that's not an option

Is anyone in here good with GD im having a small problem, i cannot make PNG's transparent no matter what i do, yeah i have the png extension and all …

just wondering if it would be easier done with mysql or ldap

BigMac, what doesn't make sense to you?

any help will be appreciated

is there a way to tell if the value in an input table has changed?

What browser?

pthreat, there is something you have to set… can't say what it is on the top of my head, but it's in the manual somewhere.

Firefox

IE has poor PNG transparency support

Is there something that has to be done to allow sites to open streams or is it supported out of the box?

so when the click submit i only pull the changed variables?

could you check for it please … ???

The attachment process, I already have a form, and i need to make a button for uploading, and then in the php file another entry for the attachment, but can't figure either out

i've looked at the manual a lot

BigMac you know how file uploading works?

did you look inside it?

Very basically

var_dump ($_FILES) on your action script
better yet echo 'pre'; var_dump ($_FILES); on your form method="POST" action="myfileuploadscript.php"

BigMac, so basically you get the uploaded file with the $_FILES array, you don't need to move_uploaded_file or w/e the function is, just open in and base 64 the contents and stick it in the message with the mime boundaries, like that sitepoint article explains on page 5 I believe

tag? and do where do I put the files variable inside mail()

ok looks like i still have the problem. when i run: if ($blah = system("/usr/bin/blah $name|wc -l") == "1") { echo "the answer is 1"; } else { echo "the answer is 0"; } it spits out what i want for the echo but it also spits out the answer, (From wc -l).

or action="" even

like so if the answer is 0, it would say.. "0 the answer is 0"
instead of just "the answer is 0"
so im wondering how to get this quiet

ah yeah enctype="multipart/form-data"

im just trying to dive into php and then later go back and redo stuff better ways et
c

omitted that one :P
so everything would be like form method="POST" enctype="multipart/form-data" action="myfileuploadscript.php"
have you checked that for me

ok and where in mail() do I list the files

imagealphablending($im,false); (where $im is the image resource).

base64_encode them ?

guess I will have to read up on base64 encoding

guess you will

imagesavealpha($im,true);

hey thanks a lot

that's what system does , it writes the answer to stdout , you're gonna have to consider a different scheme , or bind stdout to /dev/null or something and then restore it before the echo

BigMac, in mail the base64 encoded string will go in the message
BigMac, read that sitepoint article I posted please
all 6 pages

thats nothing :P
^-^

I don't understand most of it is the problem

hypomanic

BigMac, well then find a class that does it all for you.

looks like i just needed to use `

or hire someone that knows how to do it :p

instead of system("blah"); i did system(`blah`);
and it works now

Try finding a class at phpclasses.org that handles mailing attachments for you if writing your own attachment emails is to difficult.

but thx tho

oh , maybe you're write I haven't tried that before
write=right

yea dude im a newb hardcore
lol

I guess I could try, but it usually seems harder for me to get a class to work then code it myself

im just donig shit whatever way
then of course later gonna redo things. im just learning right now

BigMac, well then it sounds you need practice in both areas then

Eh phpclasses.org isn;t that bad, 99% of the classes comewith sample/demo scripts on how to use them and some good documentation. Most of the time you can just copy and paste the code over. Though this doesn't mean your off the hook, as cyth says, you could use more pratice

Yup probably do, I have only learned bits and pieces of php to get me by. I am more of an html guy

i don't think system(`command`) is correct. $a = `command`; would execute it already. what you did looks like it would happen twice

BigMac, unfortunately I recommend against that for lots of reasons. coding doesn't go well learning bits and peices, you end up with bad code and security holes.
so out with that mentality and become a coder guy!

i agree with cyth

I had planned on learning php over summer break, but learned ruby and some python instead

also, creating HTML is a lot easier once you understand php

BigMac, so use ruby and python instead

oh

deadroot, personally I'd say creating PHP is much easier once you understand HTML
deadroot, I see a lot of people who start PHP first without learning HTML and end up with too many questions

don't know rails yet:p

fair point

BigMac, you don't need to know rails to do webdev with ruby

like where does $_POST come from

Its like capring apples and oranges there, it doesn't really make it any easier, since PHP is a serverside language but you can use PHP to help do more dynamic layouts and such. You still need to know HTML to utilize it.

just use it in a fastcgid or mod_ruby and just code like you would php.
rails is nicer though

Hmm, maybe I could do that.

ok I hate goto

HarryR, lol, $_POST has nothing to do with HTML really more with HTTP

and I think the idea of having it in PHP 6 is evil
and btw PHP 5.2.4RC1 is out

which knowing how HTTP works is essential to both client and serverside web logic.

so a good PHP dev needs to know PHP, HTML, CSS, HTTP and a smattering of image codecs

ScottMac, you don't have to use it, thing is people will use it

deadroot, nah, a good php developer needs SQL as well

just like that guy the other day was using exception handeling for code execution control

cyth want to know why?
http://xkcd.com/292/

oops. missed that one ^^

why isn't that valid?

lol

zedboy, why isn't what valid?

execution control with exceptions

zedboy… exceptions should only be triggered for exceptional errors. catch is a nonlocal transfer of code execution, it has the same problems of goto if exceptions are used incorrectly.
spaghetti cooooooode

it's pretty normal in functional programming

zedboy, i bet it's not, it's a common anti-pattern
and if it's pretty normal than that normalicy means nothing, antipatterns are common by nature.

http://xkcd.com/297/ ROFL

deadroot, have i destroyed your productivity?

it's a shame more people don't use asserts in PHP

"normal" in functional programming is often weird to others …

deadroot, see http://xkcd.com/208/
i have that on a T-shirt

90% of the stuff that I do wrong, instead of having weird errors appearing that I do or dont detect, I get 3-4 asserts
showing me exactly where shit happened, without the overheads of exceptions

not at all. i visit xkcd occasionally.

uh, sorry about the language

assert ?

HarryR, we use both here. We throw exceptions for SQL errors

I use exceptions for form validation (kill me I know)

zedboy, misuse of exceptions is misuse, I don't care what the paradigm is. Nothing in functional programming I know of has exceptional code control as a 'feature'
HarryR, that is the wrong use of exceptions

basically you just have a function to validate each field, you throw an exception if it's bad, then you loop through all the fields call the validation function for that field and collect the exceptions

anybody know of a tutorial on creating your first php class?

cyth, no… bad data is exceptional circumstances and makes code 100x cleaner
and makes the validation routines situation agnostic
e.g. "i dont care where you call me from, if I get bad data somebody will know about it"

Is there a ny way to make use of a variable set outside a function within it without padding it int he form functionname($var); ?

HarryR, no no no. bad data is not exceptional unless you don't expect the data to be bad. and if the data is coming from a user on the form, than such validation mistakes should be expected.

cyth, I don't just use it for user input forms

HarryR, the correct usage for exceptions is if your parsing data… like an xml file, or a sql result resource, and it's found that the data is bad and cannot continue…

or.. if you're checking some dependancy against another field after serialization, or validating data after serialization

if the user entered bad data, the scripts cannot continue

HarryR, validation errors aren't really exceptional either… an exceptional error would be if the validator couldn't even begin to parse the file to validate it.

and considering all I'm doing when handling forms is serializing $_POST into a class, and having the class do the validation, I think it's perfectly ok
an exceptional state would be "you gave me (the class) bad data which breaks me. idiot!"

\ha

that said, I don't use exceptions at all in C++

deadroot, HarryR those should be expected often on normal circumstances… their not exceptional

ok, originally I made it with assert

asserts are worse

*they're

\L\O\L

shell_exec('sudo useradd ".$_SESSION['user']."'); who can fix this for me..?

assertions should only be used for HOLYFUCK HOW DID THIS HAPPEN errors.

i work with neither. i still don't get how to write my own objects without killing performance… T_T

costel, arghhhhh my eyes are bleeding!
cyth, ok yeah I guess I'm abusing exceptions then

costel, delete all your code now and start over

ajaja

is just an example…

has anyone ever made an irc server purely in PHP?

try, shell_exec('sudo useradd "'.$_SESSION['user'].'"');

Fushuing, no, but I'm writing one in C++ now

thanks that is what i wanted

Hi all if I do return $variable; is there any reason why print $variable; won't do anything outside the function, I know the $variable isn't empty since if I put print $variable' INSIDE the function it works fine?

it sounds like a nice challenge to do in PHP

writing an irc server in PHP isn't hard

HarryR, I see alot of misuse of exceptions… enough so I wrote a blog article on exceptions last night, I figured with all the abuse, maybe another article out there on the blogosphere surely couldn't hurt.

writing one that won't fall over every 10 minutes is

maybe the var is not defined yet?

There was one that was being made
don't know what happened to it

cyth; link ?

How so? I put print $variable; after running hte function …

:|
what's it called?

cyth, originally I didn't write it with exceptions, I just passed an array to each validation function which then put it's error messages back if it encountered an error

sikkle, http://www.codeangel.org/article/misconceptions-about-exceptions

cyth, but made code very brittle so I started experimenting with detecting when assert failed, and just gave up and used exceptions

anyone?

HarryR, that original way would be somewhat better. what was brittle about it?

cyth, it has made that specific situation much much easier to understand and allowed me to re-use the same piece of code more (making it very flexible)

it's a bit easier in Python, but there are too many in python already

sorry dood im not sure…

HarryR, there's better documented ways to handle that… filter and validation chains are nice for that

I can't remember the name and can't find it online anymore either
guess it died out

cyth, yes I'm using validation chains but implemented as normal PHP code
hangon I'll see if I can find some code

when you think abou tit PHP can use shared memory and can be decent at handleing sockets
would be fun

suphp question. How can I prevent a php script from reading a file that doesn't belong to the user ?

cyth; use of Auth and ACL on this CAorg ?

makes sure that file has the right permissions

SeanB, I'm using /dev/epoll and distributing the load over #insert number of cpus here# threads with thread-local storage for buffers to make stuff faster
SeanB, PHP really is the wrong tool for the job (tm)

permissions of 0400 would make that file only readable to the owner (but not writable or executable by anybody)

Yeah but would be fun lol

cyth, files uploaded belong to the user. If I set i.e 700 on the file, apache can't read it (html files). If I set 744, apache can read the html file, but so can everyone else.

SeanB, if you need to use multiple PHP processes, you're doing something wrong
you should be using non-blocking sockets to avoid horrible locking issues

I never have had to but in cases could see it needed

cyth, the problem is because of the umask I need to set on my ftp server. If I set it to 744, people can cat each others php files, and extract passwords. If I set it to 700, apache can't read html files and sites won't work unless the user manually chmods.

Mill|ooo, if their storing passwords in php files in plain text… they deserve it :p

If I remember there is a command in the PHP FS functions to get the owner

quick question, is there a method for creating directories? such as fopen/fwrite can create a new file

www.php.net/mkdir

oh heh
duh
tanx

SeanB, like a setting in php.ini ?

http://us2.php.net/manual/en/function.fileowner.php

SeanB, yeah .. that's not at all what I want

Mill|ooo, what is it you are trying to do?

php.net/stat

anyone know how i can add kontera ads into my smf forum?
i keep getting parse errors when i try

Wrong channel

its in php

!+g10

Guideline #10) We don't support script(s). We help you *write* PHP, not recommend or download and install/hack/modify/adapt/use pre-written scripts. Contact the authors of the script for support options they provide.

Evilx, prevent one user from running a cat on another users file using i.e system(). The problem arises because of the umask my ftp server sets. If I set 744, files are public and readable by everyone, if I set 700, html files aren't read by apache.

ech0dish, if you knew php, then you would know how to add it.

right thanks for the help guys
fuckin' dicks bye

HI all. How do I take an array and convert it to a string?

php.net/join

tnx

How can i run my own mYSQL server?

vigilant, by installing it

vigilant, install it

If apache can read the file, then any one who can upload PHP scripts will be able to get Apache to read it for them.

okay, isntall the mysql5.45 or w?E
then i can run it locally?

Mill|ooo, there is only a few ways around such issue, and it sorta involves having roots rights on the system.
vigilant, yeah

Evilx, I have root.

im a newb oop tis fun

do you know much about jail/chroot enviroments?
heh

open_basedir is a good way to restrict file access

thanks Evilx

Evilx, I'm going to have to chroot to prevent that stuff? ugh, that sounds overkill.

201 CLOSE_WAIT

wrong channel?

is theer any PHP buffer to dont get CPU to much Hight "cpu 99% up"
Kobaz my server side is php code write

Mill|ooo, do you understand how linux permission work?

you'll have to rephrase your questions, i have no idea what you're asking

Evilx, yes

finding someone to talk to in your native language may help

thebest, is your script using sockets?

No, there's nothing in PHP that you can do to tell it "don't use up 99% of the CPU"

if i want to preg_match just integers, isn't it just d+?

Evilx yes i use Socket server side.

you're close. See php.net/pcre.pattern.syntax

TML i dont whant to have CPU 99% ..but when conection is Lost. then he jump CPU up.

aahh….. sweet, id idn' tknow that page existed. thanks

hi

My suggestion would be "Don't write services in PHP"
It's not a particularly good langauge for it, as you're discovering

tml , you mean web services?
or like system services?

for some reason a new persistent connection is created every time i issue pg_pconnect(), which fills my database with inactive connections.. is this the correct behavious?
-s+r

No, I mean daemons

oh, yeah.. bad idea

Don't use pconnect

use perl

is ther a regular expressions channel?

d-media: #regex

why not?

you can run into a ton of potential issues with pconnect

Because it's broken

php isnt designed to really work well for a services, you cant even create a thread .

you can make threads

php has threads

PHP doesn't have userland threads, it's simply thread-safe

since when?

More accurately, it's written for a very specific subset of people who understand the full implications of enabling it.

http://us.php.net/manual/en/function.pcntl-fork.php

That's not a thread
That's a fork

hi guys… having trouble with a site… i developped a site, and on two servers it works great, on another server i sometimes get blank pages.. if i refresh them, they appear.. any ideas on what might be the problem?

so the best wai is server side with sockets write in Java code ? or perl ?

different time limit settings
?

php is probably crashing

way*

seriously?

check the error logs
yeap

Check your server's error logs

it's not my server :/

i crash php pretty often, and that's what happens

hm

hehe the good old fork vs thread, heh.

but then it would be the error of the server? not the script? or would it be script?
because it's working on 2 other servers

server problem
i mean, you can change your script to not crash php, which is what I wind up doing

A number of things can cause it, but they'll all show up in the error log

yeah that's what i would think
hm and i prolly can't check that without server admin rights right?

You could probably ask the admin to tell you what's going on

hi to all..

i was doing a large eval and it would make php crash and burn

They'll usually want to help you resolve that, since it's likely causing other problems.

is it in the apache error log?

anyone knows if i can install php on Mac Os default apache?

yeah

ah i think i can access that in the backend.. let me see

most hosting places have your access/error log seperate

Evilx Thanks

How could I take "1+1" and split into an array?

explode()

Thanks all.

Ok, thank you.

Yes, there should be something in the Apache error log

application/x-trash when i access the root

Note: "*should*"

i really have to point to the index.php before it opens it :/

misconfigured web server

That's a server configuration thing.

cannot read directory for multi:"
see that a lot in the error log

it doesnt have index.php as a default index file
get a new hosting place :P

Kobaz, apache not setup right.

I concur with Kobaz
Get a new provider
They're a dime-a-dozen

yeah i also told the company that outsourced this to me that this seems to be crappy hosting… but because my server knowledge is not optimal, i can't pinpoint it ..
cannot read dir