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
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
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
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
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 &"');
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 …
if apache does send it to the php script it does if not it doesn't
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
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
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
^-^
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
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 directory for multi:" ? what does it refer to
haha, that's even worse
that it's a customer site, that sucks
it doesnt have index.php as a default index file
it skips 2 desktops at a time, instead of one!
sorry ppl - wrong channel
a customer site?
your company's customer… or did i misread that
or is it just a one level outsource
what i was getting at was…
it's not your own site, and it's someone elses… so that makes it hard to switch
euh, a company outsourced the project of their client to my company…
yeah
exactly
my hosting is excellent
http://defindit.com/readme_files/apache_13_error.html
hehe
Google knoweth all
thnx, gonna read up on that
what php ide for windows would you reccomend besides PHPEclipse?
zend studio
PDT
!+editors
Editor discussion usually degrades rapidly due to personal preference. It is not a valid topic for ##php. Please try http://freshmeat.net/browse/63/ , http://www.php-editors.com/ or http://en.wikipedia.org/wiki/List_of_text_editors and find your own preference
hello. i am using php 5.2.3 on lighttpd with fastcgi. trying to use SoapClient and SoapServer classes with a simple non-WSDL example. it keeps timing out, with this in the error log: Uncaught SoapFault exception: [HTTP] Error Fetching http headers.
TML, sorry
No worries. Now you know.
TML, ah ok, so this error isn't really all that bad.. problem for this is just that there are no default files selected (which is still very unprofessional, but…)
let me try to get the other problem, and see if another error message appears
I wonder why soap is so popular as of late… seems we get 10 questions daily about soap
heh
soap is good for you
nah
rest is better for you
well, i am open to other web service options. i know soap is supposed to be slower
you can get clean with showergel, rest is necessary
if only i could get gsoap compiled on hpux
then i would be golden
cyth without soap, you would stink.
but that's okay
everything ive seen on rest with php is completely 'roll your own' anything to make using rest as easy as SoapClient/Server seems to be
MatteusX, if you have a choice! don't use soap! use RESTful services
matt_, Zend_Rest
ok. ive read bad things re soap (speed/size).
err MatteusX
ok thanks!
are we talking about soap or soap?
Evilx, soap
not cleaning soap?
you could clean with it
wsdl is aweful standard, soap is overly complicated while rest is really really simple.
hm, i think the error log doesn't update realtime
on the backend
would i be better off using a framework like cake ?
with all this soap and rest. I think i am going to go take a shower and then take a nap.
Better off than what?
and eat some cake
I'd bet that your server is dying before it gives a response. Check the apache error logs.
though I wouldn't recommend rest if you don't want resource oriented services… xml-rpc is good for remote procedure oriented services.
better than trying to code access control logic and all that good stuff on my own
A common mistake is setting memory_limit too low, as SOAP is a massive memory hog
interesting. we're direct on lighttpd, btw.
i wrote a soap interface to paypal's services api
i just skipped using the soap client and just did curl and simplexml
i ugess what i'm curious is people's experiences with using these frameworks that are out there
i've been wanting to try cake, but i'm not sure if it will speed up my development time
fedya, the definition of a framework is that you have to use that framework's architecture to build the application, and if that wheel doesn't fit your car… well your still rollling on your own.
I like Zend Framework because it's far more relaxed about the architecture you use for it…. it's not so tightly coupled and makes extending and interfacing to meet your needs easy.
i've never really used a framework, been wanting to try it to see if it will reduce the amount of code i'd have to write
fedya. cyth makes a good point. i want to make one other: theres always going to be a learning curve (some bigger than others) when picking up a framework. it can be discouraging, but once you master the framework development time can be greatly reduced
as long as your needs don't outgrow what the framework can offer
hi
fedya, MatteusX is right about framework learning curve, it can be like learning another language in alot of ways.
can some one tell me a best book to learn php
I am a newbie
man this provider sucks… doesn't even have index.html as default page
so is it a matter of personal preference?, it seems to me that cake has a good community out there, i like that they have some screencasts on their site, but i haven't been able to find any demos
I've never seen a good PHP book. Just use the website.
default.htm
php.net
hi.. where the heck can someone go in the bay area to find a web design course for front end design… the look/feel issues..