Re: [PHP] Military - Standard times
PS - I think the best ever name for a Exception class is 'Tantrum': throw new Tantrum('Ra Ra Ra Aaaargh'); Lol. -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 17th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirecting from unreachable page on website
... Really, for URLs that don't exist you should be showing a 404, This way the user doesn't falsely believe that the URL is a valid one and keep using it. By using the ErrorDocument directive like Per suggested, you can customise it to be distinct helpful, like this: http://www.phpguru.org/oh%20crap Using this method allows users to easily get to where they actually need to be, plus you can potentially promote anything of yours that you want to. -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 17th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] About printing functions
2009/1/21 Thodoris t...@kinetix.gr: ?php ob_start(); badFunctionThatSpitsInsteadOfReturning(); $sReturned = ob_get_contents(); ob_end_clean(); ? That's a good though thanks. Although I was aware of output buffering I used to ignore that ob_end_clean actually exists... You can even make it shorter by using ob_start(); echo 1; $retVar = ob_get_clean(); http://de.php.net/ob_get_clean() Byebye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirecting from unreachable page on website
Richard Heyes wrote: ... Really, for URLs that don't exist you should be showing a 404, This way the user doesn't falsely believe that the URL is a valid one and keep using it. By using the ErrorDocument directive like Per suggested, you can customise it to be distinct helpful Apache also comes with a good example of how to cobble that with content negotiation to present error documents in the users preferred language. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to use SVN + PHP
Another tidbit... I am fairly new to SVN or any Version Control System. Whether its CVS, SVN, or GIT a VCS is essential even for solo projects. My setup is as follows, [and it seems to work pretty well]: 1. svn repo lives on dev server. 2. everything is in the trunk. I haven't touched branches and / or tags yet. 3. users connect to repo via http using htaccess users passwords 4. post-commit script runs svn update after anyone commits to the repo. This runs svn update on the dev server. 5. after the boss approves the dev server work, the production server runs svn update too. The production has a checked out working copy of the source repo. I chose this method because our clients also FTP some files to the server, and using svn export would be too complicated. The production server connects to the repo via an ssh user using an ssh key and restricted to this command svnserve -t -r /var/svnrepo. The svn up on the production server is a manual process. I login via ssh, cd to the webroot, and type svn up. Our dev team is using eclipse-pdt and subclipse plugin which integrates eclipse and subversion. Subversion or any VCS is essential. After 15 years of using FTP/SFTP/SCP, SVN has replaced it for all my web projects. On Tue, Jan 20, 2009 at 3:31 AM, Ross McKay ro...@zeta.org.au wrote: On Mon, 19 Jan 2009 22:32:49 +0100, Edmund Hertle wrote: I'm thinking about implementing Subversion to an existing php project for obvious reasons. Yay! What Nathan said, plus a couple of comments from me... [...] My ideas about using SVN are these: - Repository is managing trunk, branch and tag - Live-server works as client of the rep, getting the latest tag - Develop-server uses mainly latest trunk and of course branches as needed Personally, I'd just work in the trunk. Even with multiple developers, stick to working in the trunk. On release, copy the trunk to a tag to preserve its state. Branches are great for long-running diversions from the trunk, e.g. when creating a whole new release with new features and potentially different architecture, copy the trunk to a branch so that maintenance work can continue on the branch, and perform new work on the trunk. Of course, you can do that the other way around, new work on the branch and maintenance on the trunk, but that means merging the branch into the trunk at the end and potentially creating a new branch for maintenance... i.e. the same result as the other method, but with more effort. Putting it another way: working in branches is good for maintaining separate codebases concurrently, either because of feature differences or platform differences (e.g. a Linux branch and a Windows branch). NB: in Subversion, there really isn't proper support for either branches or tags; we just emulate it by copying a folder to another folder. A tag is then just a copied folder that is never altered again, and a branch is a copied folder that is later modified. Convention has us calling these things tags and branches, and calling the original folder the trunk. For simple websites, I tend to drop the trunk/tag/branch model entirely and just work in the trunk. Some things just don't warrant the extra work :) but they still benefit from revision control. [...] Is it possible to configure one client (here develop-server) to automatically updating from rep if something is committed? IMHO, that would be a Bad Thing(R) because it means only committing to the repository when it works. Alternatively, it could mean releasing untested changes to production, an even more Bad Thing(R). Better is to commit early, commit often and thus get deep undo through Subversion's history of changes. Once you've tested your changes and are happy that everything is working, and committed them all to the trunk, copy the trunk to a tag and put that on the server. -- Ross McKay, Toronto, NSW Australia Let the laddie play wi the knife - he'll learn - The Wee Book of Calvin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- life your own way. http://www.talkderby2me.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] developers life
Like many others, you also described exactly how I work. with one exception... php is my only choice for server side scripting / programming. Sure there are others, perhaps better for some things, languages, but I am sticking with PHP through snow, mud, earthquakes, tsunamis, and solar radiation. With each new project, I try to do something new and different with PHP than my previous projects. Whether the new projects are improvements is another discussion for someone other than me :) Thanks for the post, I am glad I am not the only one. derby On Mon, Jan 19, 2009 at 3:28 PM, Nathan Rixham nrix...@gmail.com wrote: well just for the hell of it; and because I'm feeling worn.. anybody else find the following true when you're a developer? - frequent bursts of side-tracking onto more interesting subjects - vast amount of inhuman focus, followed by inability to remain focussed - general tendancy to keep taking on projects, often for no good reason - inability to flip out of work mode at 5pm like the rest of the world -- [sub] not feeling normal unless worked you've extra; while other professions demand overtime as little as an extra 15 minutes - constant learning (positive thing) - unlimited skill scope, if its on a computer you'll give it a go - amazing ability to prioritise (the wrong things) - all projects suddenly become uninteresting and all motivation is lost at approx 65-85 percent completion - the code seems more important than the app (even though its not) - lots more but lost interest / focus ps: expectantly installed windows 7 over the weekend, brief moment of excitement coupled with the thought i wonder what it's like; anticlimax + reality check, it was just a taskbar, start menu and desktop.. you'd think I'd know by now. regards :-) i so have more important things to do -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- life your own way. http://www.talkderby2me.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to use SVN + PHP
derby wrote: Our dev team is using eclipse-pdt and subclipse plugin which integrates eclipse and subversion. Subversion or any VCS is essential. After 15 years of using FTP/SFTP/SCP, SVN has replaced it for all my web projects. you can get the RSE plugin for eclipse-pdt as well; I'd really recommend it, in short it's remote system explorer and allows you to connect to any server by almost any protocol, so you can ssh, ftp, scp, sftp, webdav whatever from inside eclipse. further there's the communications plugin which let's you msn, xmpp, aim etc from inside eclipse too finally make sure you have the zend eclipse debugger plugin for eclipse installed as well, let's you run php right in eclipse and debug etc, doesn't come with pdt-1 if i remember correctly -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Create $var with some function
Hi there, Someone know if can (if possible, how) i create a $var on my script like this: function createvar($var) { $var = 'foo'; global $var; //or global $$var, i don't know it yet. } so i'd call, createvar('myvar'); so i'd could call $myvar, like this: echo $myvar; // prints 'foo' is it possible? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create $var with some function
function createvar($var) { ${$var} = 'foo'; global ${$var}; //or global $$var, i don't know it yet. } This should work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RES: [PHP] Create $var with some function
No, that's not the point yet. -Mensagem original- De: Robert Stankiewicz [mailto:robe...@belfabriek.nl] Enviada em: quinta-feira, 22 de janeiro de 2009 10:49 Para: Jônatas Zechim; php-general@lists.php.net Assunto: Re: [PHP] Create $var with some function function createvar($var) { ${$var} = 'foo'; global ${$var}; //or global $$var, i don't know it yet. } This should work. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] importing from XML-files
Hi everybody, I am creating an import script which is getting data out of an xml file. Now I do have a problem with a file where 2 images are included. I need to access the second image name, but can not find out how. I do: $xml = simplexml_load_file($files[$i]); $data[pic1_base64] = $xml-anbieter-anhang-anhanginhalt; This get's me the first image in line. But how could I get the second one? Thank you for any help, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Create $var with some function
Hi, function createvar($name, $value) { $GLOBALS[$name] = $value; } Or do it without a function: $GLOBALS['name'] = $value; -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 17th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] About printing functions
2009/1/22 Jan G.B. ro0ot.w...@googlemail.com 2009/1/21 Thodoris t...@kinetix.gr: ?php ob_start(); badFunctionThatSpitsInsteadOfReturning(); $sReturned = ob_get_contents(); ob_end_clean(); ? That's a good though thanks. Although I was aware of output buffering I used to ignore that ob_end_clean actually exists... You can even make it shorter by using ob_start(); echo 1; $retVar = ob_get_clean(); http://de.php.net/ob_get_clean() http://de.php.net/ob_get_clean%28%29 Yes, but that leaves output buffering on, and that's a bad thing, especially if you are on the console, but anyhow, why leave it on when you don't need it, or even if you do, why create more levels? Byebye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Torok, Alpar Istvan
RE: [PHP] importing from XML-files.
Maybe you can itterate over the childnodes from the parent element ? -Original Message- From: Merlin Morgenstern [mailto:merli...@fastmail.fm] Sent: Thursday, January 22, 2009 1:53 PM To: php-general@lists.php.net Subject: [SPAM] - [PHP] importing from XML-files - Der Bayes'sche Filter hat Spam erkannt. Hi everybody, I am creating an import script which is getting data out of an xml file. Now I do have a problem with a file where 2 images are included. I need to access the second image name, but can not find out how. I do: $xml = simplexml_load_file($files[$i]); $data[pic1_base64] = $xml-anbieter-anhang-anhanginhalt; This get's me the first image in line. But how could I get the second one? Thank you for any help, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] About printing functions
2009/1/22 Török Alpár torokal...@gmail.com: 2009/1/22 Jan G.B. ro0ot.w...@googlemail.com 2009/1/21 Thodoris t...@kinetix.gr: $sReturned = ob_get_contents(); ob_end_clean(); That's a good though thanks. Although I was aware of output buffering I used to ignore that ob_end_clean actually exists... You can even make it shorter by using $retVar = ob_get_clean(); http://de.php.net/ob_get_clean() Yes, but that leaves output buffering on, and that's a bad thing, especially if you are on the console, but anyhow, why leave it on when you don't need it, or even if you do, why create more levels? That's not true. From the PHP Manual (link above): string ob_get_clean ( void ) Gets the current buffer contents and delete current output buffer. *ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean().* bye -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Military - Standard times
At 12:35 AM +0100 1/22/09, Jochem Maas wrote: tedd schreef: Hey, you called me schreef and that means an end of a stroke (Arrggg, that has all sorts of meanings). :-) which translation service came up with that?? it is funny though :-) http://nl.wikipedia.org/wiki/Schreef -- I'm into pointless stuff -- I'm symmetrically challenged. I don't like doing anything that can't be undone. and how many kids do you have :-P LOL -- but kids shouldn't be undone. -- since I left Windows I find it works against me less. I teach at the local college where they use windows (Vista) and that's the closest I want to come to it. I've always been with Apple (1977 to today). - Besides, oddly enough I can understand return $t; better than return strftime('%R', strtotime($t)); now that's plain weird. is it because '$t' vaguely resembles a rock[tm]? No, it's because I have some old habits. I don't like one line functions. All *my* functions should have enough substance in them for me to understand what they are doing. If I'm going to use a one line function, then why not make it one line and not a function? I use $t for time stuff, $d for date and so on, but one character variables are usually one-time variables. Similarly I use $i, $j, $k for counters -- a remnant from my FORTRAN days. When I need a temporary nondescript variable (intermediate calculation), I use $a, $b, $c, and so on. For more consistent variables I try to be semantic with underscores ($last_name) and camel-case for functions (militaryToStandardTime() ). It's just a set of old habits that I've applied to various languages. --- PPS - I have a little rock with the words the ball is round carved into it? not your work by any chance? No, mine had only 1 or 0 carved into it -- we called that documentation back then. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: importing from XML-files
Merlin Morgenstern schrieb: Hi everybody, I am creating an import script which is getting data out of an xml file. Now I do have a problem with a file where 2 images are included. I need to access the second image name, but can not find out how. I do: $xml = simplexml_load_file($files[$i]); $data[pic1_base64] = $xml-anbieter-anhang-anhanginhalt; This get's me the first image in line. But how could I get the second one? Thank you for any help, Merlin Hi Merlin, well please tell us how shows the XML DOC?. I can see that the XML read a node like anbieter. Is the Anhang an Object or Array? Is this Empty? viele Gruesse Carlos Medina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL class. Thoughts?
Chris wrote: That won't tell you where a query comes from ;) Add a debug_backtrace into the class to also pinpoint where the query was called from. Complicated queries built on variables (or even just long queries built over multiple lines) will be hard to find just by looking at the mysql query log. I agree with chris and I do the same thing, also with a class or a wrapper function/s that handle your queries you can also decided on what databases the query should run, say you have Master-Slave replication setup with mysql, you could run selects on the slaves and updates/delete in the master without the class deciding which one it should run on Clive -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: importing from XML-files
Carlos Medina wrote: Merlin Morgenstern schrieb: Hi everybody, I am creating an import script which is getting data out of an xml file. Now I do have a problem with a file where 2 images are included. I need to access the second image name, but can not find out how. I do: $xml = simplexml_load_file($files[$i]); $data[pic1_base64] = $xml-anbieter-anhang-anhanginhalt; This get's me the first image in line. But how could I get the second one? Thank you for any help, Merlin Hi Merlin, well please tell us how shows the XML DOC?. I can see that the XML read a node like anbieter. Is the Anhang an Object or Array? Is this Empty? viele Gruesse Carlos Medina Hello Carlos, the xml structure looks like this: - anhaenge anhang location=EXTERN gruppe=TITELBILD anhangtitelAnsicht_Strassenseite/anhangtitel formatjpg/format daten pfad_1006-kurz_ansicht_strassenseite.jpg/pfad /daten /anhang anhang location=EXTERN gruppe=GRUNDRISS anhangtitelGrundriss_Modern-kuehl/anhangtitel formatjpg/format daten pfad_1006-lang2_grundriss_modern-kuehl.jpg/pfad /daten /anhang /anhaenge -- Thank you for your help, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirecting from unreachable page on website
What if the file exists, but it's kinda file to update database, like // get request $_REQUEST // execute sql statement to update database // redirect to the other page, showing results? in this case 404 approach does not mean to do correctly, so what else is suggested? 2009/1/22 Per Jessen p...@computer.org Richard Heyes wrote: ... Really, for URLs that don't exist you should be showing a 404, This way the user doesn't falsely believe that the URL is a valid one and keep using it. By using the ErrorDocument directive like Per suggested, you can customise it to be distinct helpful Apache also comes with a good example of how to cobble that with content negotiation to present error documents in the users preferred language. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] can I do this without eval?
I'm trying to build a prepared statment and dynamically bind the variables to it since I use this on severaly different pages I didn't want to build a huge bind statement hard coded on each page and then have to maintain it every time there was a change. I despise having to use eval() and was hoping one of you had stumbled upon this and found a better workaround for it. I've seen references to call_user_function_array, but couldn't find a tutorial, or description that could make me understand how to use it. I think the big problem with all of them was they expected me to know oop, and that is on my plate to learn after I finnish this project. Frank //initialize a variable to let us know this is the first time through on //the SET construction $i = true; //step through all the FILTERED values to build the SET statment foreach($FILTERED as $key=$value){ //make sure we single quote the string fields if($i){ $sqlstring .= $key = ?; $i = false; }else{ $sqlstring .= , $key = ?; }; //build the list of variables to bound durring the mysqli prepared staments $params[] = \$FILTERED[' . $key . ']; //build the list of types for use durring the mysqli perepared statments switch($key){ case in_array($key, $stringfields): $ptype[] = 's'; break; case in_array($key, $doublefields): $ptype[] = 'd'; break; default: $ptype[] = 'i'; }; }; //make sure we only update the row we are working on $sqlstring .= ' WHERE BoL=' . $FILTERED['BoL']; //connect to the db include('c:\inetpub\security\connection.php'); //ok...let's do this query //use mysqli so we can use a prepared statment and avoid sql insert attacks $stmt = mysqli_prepare($iuserConnect, $sqlstring); if(!$stmt){ die(mysqli_stmt_error($stmt)); }; //implode the two variables to be used in the mysqli bind statment so they are in //the proper formats $params = implode(, , $params); $ptype = implode('', $ptype); --- - is there a better way to accomplish this? - --- //run an eval to build the mysqli bind statment with the string list of variables //to be bound eval(\$check = mysqli_stmt_bind_param(\$stmt, '$ptype', $params);); if(!$check){ die(mysqli_stmt_error($stmt) . 'brbr'); }; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Military - Standard times
Richard Heyes rich...@php.net wrote in message news:af8726440901220050i71d99bf7m5425620f67350...@mail.gmail.com... PS - I think the best ever name for a Exception class is 'Tantrum': throw new Tantrum('Ra Ra Ra Aaaargh'); Lol. -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 17th) I got tired of an app throwing errors about one line of code that needed to be the way it was so I set up an error handeling routine called just_f*ing_die() once. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] killing a child process from pcntl_exec
Hi.. I fork a child process, using pcntl_exec. I see the process from the cmdline (using pgrep 123), but I can't seem to kill the pid from the cmdline, using kill -9 123.. Is there something that I need to implement within the php test in order for the kill signal to be effective? If I wait, the child eventually dies.. but I'd like to be able to kill it from the cmdline. thoughts/pointers/comments... thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: importing from XML-files
Merlin Morgenstern schrieb: Carlos Medina wrote: Merlin Morgenstern schrieb: Hi everybody, I am creating an import script which is getting data out of an xml file. Now I do have a problem with a file where 2 images are included. I need to access the second image name, but can not find out how. I do: $xml = simplexml_load_file($files[$i]); $data[pic1_base64] = $xml-anbieter-anhang-anhanginhalt; This get's me the first image in line. But how could I get the second one? Thank you for any help, Merlin Hi Merlin, well please tell us how shows the XML DOC?. I can see that the XML read a node like anbieter. Is the Anhang an Object or Array? Is this Empty? viele Gruesse Carlos Medina Hello Carlos, the xml structure looks like this: - anhaenge anhang location=EXTERN gruppe=TITELBILD anhangtitelAnsicht_Strassenseite/anhangtitel formatjpg/format daten pfad_1006-kurz_ansicht_strassenseite.jpg/pfad /daten /anhang anhang location=EXTERN gruppe=GRUNDRISS anhangtitelGrundriss_Modern-kuehl/anhangtitel formatjpg/format daten pfad_1006-lang2_grundriss_modern-kuehl.jpg/pfad /daten /anhang /anhaenge -- Thank you for your help, Merlin Hi Merlin, what about? foreach( $xml-anbieter-anhang as $data ){ echo $data-anhangtitel . 'br'; } regards Carlos Medina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: killing a child process from pcntl_exec
bruce schrieb: Hi.. I fork a child process, using pcntl_exec. I see the process from the cmdline (using pgrep 123), but I can't seem to kill the pid from the cmdline, using kill -9 123.. Is there something that I need to implement within the php test in order for the kill signal to be effective? If I wait, the child eventually dies.. but I'd like to be able to kill it from the cmdline. thoughts/pointers/comments... thanks Hi Bruce, my ask: it is the pnum really 123? Check it out with ps -aux or ps -aix Regards Carlos Medina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirecting from unreachable page on website
What if the file exists, but it's kinda file to update database, like GET requests shouldn't really modify data. -- Richard Heyes HTML5 Graphing for Firefox, Chrome, Opera and Safari: http://www.rgraph.org (Updated January 17th) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: killing a child process from pcntl_exec
hi carlos.. yeah.. the pid is correct. it appears that spawning/creating a child process using pcntl_exec(foo) results in a child process that you can see running from the cmdline, but that you can't kill using kill -9. php might allow some other function within the parent app to allow the kill signal to be received by the child, but i'm not familiar enough with php to know. if i spawn the child process using something like system() then i can kill the child, but i essentially have a bunch of parent processes running as well. (ie, one parent process for each child process in the pid tbl) what i really want, is the ability to spawn/create multiple external child apps, each with their own child process ID, so I can kill it from the cmdline. I'd also like to have a single parent processID in the pid tbl... thoughts/comments/etc... thanks -Original Message- From: Carlos Medina [mailto:i...@simply-networks.de] Sent: Thursday, January 22, 2009 8:04 AM To: php-general@lists.php.net Subject: [PHP] Re: killing a child process from pcntl_exec bruce schrieb: Hi.. I fork a child process, using pcntl_exec. I see the process from the cmdline (using pgrep 123), but I can't seem to kill the pid from the cmdline, using kill -9 123.. Is there something that I need to implement within the php test in order for the kill signal to be effective? If I wait, the child eventually dies.. but I'd like to be able to kill it from the cmdline. thoughts/pointers/comments... thanks Hi Bruce, my ask: it is the pnum really 123? Check it out with ps -aux or ps -aix Regards Carlos Medina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP 5.2.8 fails to find libiconv
Hi, I'm attempting to install PHP 5.2.8 on CentOS 5.2 x86_64. The glibc iconv doesn't seem to function very well, leading to a bunch of failed tests when running 'make test' (see below). After a bit of Googling I stumbled upon http://nl2.php.net/manual/en/intro.iconv.php which suggests to install libiconv instead of relying on glibc's iconv, when things go wrong. My configure line reads as follows: ./configure --prefix=/chroot/apache2/php --with-apxs2=/chroot/apache2/bin/apxs --disable-cgi --with-zlib --with-gettext --enable-sockets --with-xmlrpc --with-xsl --with-config-file-path=/php/etc --with-mcrypt --enable-mbregex --with-gd --with-mime-magic=/usr/share/mime/magic --enable-mbstring=all --with-openssl --with-mysql=/chroot/mysql --with-curl=/usr/lib64 --enable-zip --with-freetype-dir=/usr/lib64 --with-png-dir --with-jpeg-dir --with-libdir=lib64 --with-gnu-ld --with-iconv=/usr/local/lib which yields the following result: checking for iconv support... yes configure: error: Please reinstall the iconv library. Configure runs fine when I omit the path in the --with-iconv directive, but that will use glibc's iconv, which results in the following failed tests when running make check: Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt] iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt] Test session_decode() function : variation [ext/session/tests/session_decode_variation3.phpt] Test session_encode() function : variation [ext/session/tests/session_encode_variation8.phpt] Test tempnam() function: usage variations - permissions( to 0777) of dir [ext/standard/tests/file/tempnam_variation4.phpt] htmlentities() test 2 (setlocale / fr_FR.ISO-8859-15) [ext/standard/tests/strings/htmlentities02.phpt] (warn: possibly braindead libc) htmlentities() test 4 (setlocale / ja_JP.EUC-JP) [ext/standard/tests/strings/htmlentities04.phpt] (warn: possibly braindead libc) htmlentities() test 15 (setlocale / KOI8-R) [ext/standard/tests/strings/htmlentities15.phpt] (warn: possibly braindead libc) Any thoughts/suggestions/ideas on how to solve this would be greatly appreciated! Regards, Ro -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] developers life
On Thu, Jan 22, 2009 at 06:46, derby derby...@gmail.com wrote: http://www.talkderby2me.com Heh. I like the domain name, Derby. Welcome to the list. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirecting from unreachable page on website
Morris wrote: What if the file exists, but it's kinda file to update database, like // get request $_REQUEST // execute sql statement to update database // redirect to the other page, showing results? in this case 404 approach does not mean to do correctly, so what else is suggested? I would use a 303 redirect, just like after processing a POST. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] killing a child process from pcntl_exec
There are functions/settings in pcntl docs about how to listen for specific signals. If you don't listen for -9, maybe you don't get it. http://php.net/manual/en/function.pcntl-signal.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP IRC Bot - Listening on a Socket
Hey, I'm writing an IRC bot from scratch in PHP. I'd like to be able to announce events, such as SVN commit notifications, through the bot. The only way to do this that I can think of is to have the bot listen on a socket and have the program (in this example, the SVN post-commit hook script) send some data over the socket. I know a bit about connecting via sockets in PHP, but not about listening on sockets. What would be the best way to setup a non-blocking listening socket, while being connected via IRC (and parsing input/output) simultaneously? Or, does anyone have any suggestions on alternative ways to send data to the IRC Bot (other than sockets)? I could possibly have the external scripts store data in a text file, then just have the PHP Bot read and delete the data on a timer. Thank you for any and all help/suggestions, ~Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] killing a child process from pcntl_exec
i'm pretty sure that's not the issue... i should be able to spawn/fork any kind of external app/process... kill -9 pid, especially if done as root, should terminate the process... i suspect that the issue has to do with zombie processes, and how php/pnctl_exec/etc.. operates. -Original Message- From: c...@l-i-e.com [mailto:c...@l-i-e.com] Sent: Thursday, January 22, 2009 10:00 AM To: php-general@lists.php.net Subject: Re: [PHP] killing a child process from pcntl_exec There are functions/settings in pcntl docs about how to listen for specific signals. If you don't listen for -9, maybe you don't get it. http://php.net/manual/en/function.pcntl-signal.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I do this without eval?
On Thu, Jan 22, 2009 at 8:35 AM, Frank Stanovcak blindspot...@comcast.netwrote: I'm trying to build a prepared statment and dynamically bind the variables to it since I use this on severaly different pages I didn't want to build a huge bind statement hard coded on each page and then have to maintain it every time there was a change. I despise having to use eval() and was hoping one of you had stumbled upon this and found a better workaround for it. I've seen references to call_user_function_array, but couldn't find a tutorial, or description that could make me understand how to use it. I think the big problem with all of them was they expected me to know oop, and that is on my plate to learn after I finnish this project. Frank //initialize a variable to let us know this is the first time through on //the SET construction $i = true; //step through all the FILTERED values to build the SET statment foreach($FILTERED as $key=$value){ //make sure we single quote the string fields if($i){ $sqlstring .= $key = ?; $i = false; }else{ $sqlstring .= , $key = ?; }; //build the list of variables to bound durring the mysqli prepared staments $params[] = \$FILTERED[' . $key . ']; //build the list of types for use durring the mysqli perepared statments switch($key){ case in_array($key, $stringfields): $ptype[] = 's'; break; case in_array($key, $doublefields): $ptype[] = 'd'; break; default: $ptype[] = 'i'; }; }; //make sure we only update the row we are working on $sqlstring .= ' WHERE BoL=' . $FILTERED['BoL']; //connect to the db include('c:\inetpub\security\connection.php'); //ok...let's do this query //use mysqli so we can use a prepared statment and avoid sql insert attacks $stmt = mysqli_prepare($iuserConnect, $sqlstring); if(!$stmt){ die(mysqli_stmt_error($stmt)); }; //implode the two variables to be used in the mysqli bind statment so they are in //the proper formats $params = implode(, , $params); $ptype = implode('', $ptype); --- - is there a better way to accomplish this? - --- //run an eval to build the mysqli bind statment with the string list of variables //to be bound eval(\$check = mysqli_stmt_bind_param(\$stmt, '$ptype', $params);); if(!$check){ die(mysqli_stmt_error($stmt) . 'brbr'); }; yeah, id try call_user_func_array(), omit the line to create a string out of the $params, then merge the later arguments into an array w/ the first 2 args #$params = implode(, , $params); $check = call_user_func_array('mysqli_stmt_bind_param', array_merge(array($stmt, $ptype), $params)); something like that i think should do the trick. -nathan
Re: [PHP] can I do this without eval?
Nathan Nobbe quickshif...@gmail.com wrote in message news:7dd2dc0b0901221048g2f089cf9s36ecb9a5b35ab...@mail.gmail.com... On Thu, Jan 22, 2009 at 8:35 AM, Frank Stanovcak blindspot...@comcast.netwrote: I'm trying to build a prepared statment and dynamically bind the variables to it since I use this on severaly different pages I didn't want to build a huge bind statement hard coded on each page and then have to maintain it every time there was a change. I despise having to use eval() and was hoping one of you had stumbled upon this and found a better workaround for it. I've seen references to call_user_function_array, but couldn't find a tutorial, or description that could make me understand how to use it. I think the big problem with all of them was they expected me to know oop, and that is on my plate to learn after I finnish this project. Frank //initialize a variable to let us know this is the first time through on //the SET construction $i = true; //step through all the FILTERED values to build the SET statment foreach($FILTERED as $key=$value){ //make sure we single quote the string fields if($i){ $sqlstring .= $key = ?; $i = false; }else{ $sqlstring .= , $key = ?; }; //build the list of variables to bound durring the mysqli prepared staments $params[] = \$FILTERED[' . $key . ']; //build the list of types for use durring the mysqli perepared statments switch($key){ case in_array($key, $stringfields): $ptype[] = 's'; break; case in_array($key, $doublefields): $ptype[] = 'd'; break; default: $ptype[] = 'i'; }; }; //make sure we only update the row we are working on $sqlstring .= ' WHERE BoL=' . $FILTERED['BoL']; //connect to the db include('c:\inetpub\security\connection.php'); //ok...let's do this query //use mysqli so we can use a prepared statment and avoid sql insert attacks $stmt = mysqli_prepare($iuserConnect, $sqlstring); if(!$stmt){ die(mysqli_stmt_error($stmt)); }; //implode the two variables to be used in the mysqli bind statment so they are in //the proper formats $params = implode(, , $params); $ptype = implode('', $ptype); --- - is there a better way to accomplish this? - --- //run an eval to build the mysqli bind statment with the string list of variables //to be bound eval(\$check = mysqli_stmt_bind_param(\$stmt, '$ptype', $params);); if(!$check){ die(mysqli_stmt_error($stmt) . 'brbr'); }; yeah, id try call_user_func_array(), omit the line to create a string out of the $params, then merge the later arguments into an array w/ the first 2 args #$params = implode(, , $params); $check = call_user_func_array('mysqli_stmt_bind_param', array_merge(array($stmt, $ptype), $params)); something like that i think should do the trick. -nathan Thanks Nathan! Just to make sure I understand call_user_func_array, and how it opperates. It's first paramer is the name of the function...any function, which is part of what made it so confusing to me...and the second paramter is an array that will be used to populate the the parameters of the called function as a comma seperated list. Please tell me if I got any of that wrong. This is how I learn! Frank -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: killing a child process from pcntl_exec
bruce wrote: Hi.. I fork a child process If I wait, the child eventually dies.. but I'd like to be able to kill it thoughts/pointers/comments... thanks yeah - stop killing children -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php spawing/forking issues
Hi... Playing around with a test app to spawn external child processes. I'd like to be able to spawn/fork/run am external child process, that: -allows the child processes to run as separate independent processes (pid) -allows the child process(es) to be terminated via cmdline (kill -9 pid) i've got a dynamic situation, where i'm reading from an array, and for each item in the array, i want to spawn/fork the child process. i'd like to be able to have 10 copies of the spawned child process running at the same time. the only way i've been able to get my test working, is to spawn a group of processes, and then to iterate through the group, using an array of pids, and doing a wait for each pid in the array. however, this doesn't satisfy me wanting to have a certain number of simultaneous processes running at the same time.. thoughts/comments/pointers to articles that might demonstrate this would be useful. thanks... i can easily post the sample chunk of code i'm playing with if someone wants to look at it! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I do this without eval?[RESOLVED]
Nathan Nobbe quickshif...@gmail.com wrote in message news:7dd2dc0b0901221048g2f089cf9s36ecb9a5b35ab...@mail.gmail.com... yeah, id try call_user_func_array(), omit the line to create a string out of the $params, then merge the later arguments into an array w/ the first 2 args #$params = implode(, , $params); $check = call_user_func_array('mysqli_stmt_bind_param', array_merge(array($stmt, $ptype), $params)); something like that i think should do the trick. -nathan Ok. I only had to make minimal chnages to the offered solution...highlighted below...I would still appreciate anyone letting me know if my understanding of call_user_func_array() is incorrect though. :) Thanks everyone! Frank //put the string fields directly in as we will be preparing the sql statment //and that will protect us from injection attempts if($continue){ foreach($stringfields as $value){ $FILTERED[$value] = $_POST[$value]; }; }; //ok...we've made it this far, so let's start building that update query! $vartype = ''; if($continue){ //start building the SQL statement to update the bol table $sqlstring = UPDATE bol SET; //initialize a variable to let us know this is the first time through on //the SET construction $i = true; //step through all the FILTERED values to build the SET statment //and accompanying bind statment foreach($FILTERED as $key=$value){ //make sure we don't put a comma in the first time through if($i){ $sqlstring .= $key = ?; $i = false; }else{ $sqlstring .= , $key = ?; }; //build the list of types for use durring the mysqli perepared statments switch($key){ case in_array($key, $stringfields): $ptype[] = 's'; break; case in_array($key, $doublefields): $ptype[] = 'd'; break; default: $ptype[] = 'i'; }; }; //make sure we only update the row we are working on $sqlstring .= ' WHERE BoL=' . $FILTERED['BoL']; //connect to the db include('c:\inetpub\security\connection.php'); //ok...let's do this query //use mysqli so we can use a prepared statment and avoid sql insert attacks $stmt = mysqli_prepare($iuserConnect, $sqlstring); if(!$stmt){ die(mysqli_stmt_error($stmt)); }; //implode the field types so that we have a useable string for the bind $ptype = implode('', $ptype); - I completely did away with the $param and inserted -- - $FILTERED directly and everything worked great! -- //bind the variables using a call to call_user_func_array to put all the //$FILTERED variables in $check = call_user_func_array('mysqli_stmt_bind_param', array_merge(array($stmt, $ptype), $FILTERED)); if(!$check){ die(mysqli_stmt_error($stmt) . 'brbr'); }; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] distinguish between null variable and unset variable
Daniel Brown wrote: On Wed, Jan 21, 2009 at 20:27, Jack Bates ms...@freezone.co.uk wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? Unfortunately, in PHP - like other languages - you can't. A variable is considered to be null if: * it has been assigned the constant NULL. * it has not been set to any value yet. * it has been unset(). I'm not in a position to test right now, but using Dan's logic I would turn it around and test for isset first and then is_null. This makes sense to me, but maybe it is flawed: if (isset($var) is_null($var)) { echo $var is set and is null; } Or maybe a function to return is the $var === null: function eq_null($var) { return (isset($var) is_null($var)) ? true : false; } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] distinguish between null variable and unset variable
Shawn McKenzie wrote: Daniel Brown wrote: On Wed, Jan 21, 2009 at 20:27, Jack Bates ms...@freezone.co.uk wrote: How can I tell the difference between a variable whose value is null and a variable which is not set? Unfortunately, in PHP - like other languages - you can't. A variable is considered to be null if: * it has been assigned the constant NULL. * it has not been set to any value yet. * it has been unset(). I'm not in a position to test right now, but using Dan's logic I would turn it around and test for isset first and then is_null. This makes sense to me, but maybe it is flawed: if (isset($var) is_null($var)) { echo $var is set and is null; } Or maybe a function to return is the $var === null: function eq_null($var) { return (isset($var) is_null($var)) ? true : false; } Or something like this (dunno, just brainstorming): function setornull($var) { if (!isset($var)) { return false; } elseif (is_null($var)) { return null; } return true; } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] distinguish between null variable and unset variable
On Thu, Jan 22, 2009 at 15:11, Shawn McKenzie nos...@mckenzies.net wrote: Or something like this (dunno, just brainstorming): function setornull($var) { if (!isset($var)) { return false; } elseif (is_null($var)) { return null; } return true; } Unfortunately, neither solution would work. isset() will return FALSE even for an instantiated and explicitly-defined NULL variable. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] distinguish between null variable and unset variable
On Thu, Jan 22, 2009 at 15:12, Daniel Brown danbr...@php.net wrote: Unfortunately, neither solution would work. isset() will return FALSE even for an instantiated and explicitly-defined NULL variable. Forgot to mention that, in addition, is_null() will return TRUE for both explicitly-set NULL variables and undefined variables alike. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Unadvertised dedicated server deals, too low to print - email me to find out! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] distinguish between null variable and unset variable
Daniel Brown wrote: On Thu, Jan 22, 2009 at 15:11, Shawn McKenzie nos...@mckenzies.net wrote: Or something like this (dunno, just brainstorming): function setornull($var) { if (!isset($var)) { return false; } elseif (is_null($var)) { return null; } return true; } Unfortunately, neither solution would work. isset() will return FALSE even for an instantiated and explicitly-defined NULL variable. Yes, damn it! -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] distinguish between null variable and unset variable
Daniel Brown wrote: On Thu, Jan 22, 2009 at 15:12, Daniel Brown danbr...@php.net wrote: Unfortunately, neither solution would work. isset() will return FALSE even for an instantiated and explicitly-defined NULL variable. Forgot to mention that, in addition, is_null() will return TRUE for both explicitly-set NULL variables and undefined variables alike. That's why I was testing isset() fist, however as you pointed out, that is crap also. :-( -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I do this without eval?
On Thu, Jan 22, 2009 at 12:06 PM, Frank Stanovcak blindspot...@comcast.netwrote: Nathan Nobbe quickshif...@gmail.com wrote in message news:7dd2dc0b0901221048g2f089cf9s36ecb9a5b35ab...@mail.gmail.com... On Thu, Jan 22, 2009 at 8:35 AM, Frank Stanovcak blindspot...@comcast.netwrote: I'm trying to build a prepared statment and dynamically bind the variables to it since I use this on severaly different pages I didn't want to build a huge bind statement hard coded on each page and then have to maintain it every time there was a change. I despise having to use eval() and was hoping one of you had stumbled upon this and found a better workaround for it. I've seen references to call_user_function_array, but couldn't find a tutorial, or description that could make me understand how to use it. I think the big problem with all of them was they expected me to know oop, and that is on my plate to learn after I finnish this project. Frank //initialize a variable to let us know this is the first time through on //the SET construction $i = true; //step through all the FILTERED values to build the SET statment foreach($FILTERED as $key=$value){ //make sure we single quote the string fields if($i){ $sqlstring .= $key = ?; $i = false; }else{ $sqlstring .= , $key = ?; }; //build the list of variables to bound durring the mysqli prepared staments $params[] = \$FILTERED[' . $key . ']; //build the list of types for use durring the mysqli perepared statments switch($key){ case in_array($key, $stringfields): $ptype[] = 's'; break; case in_array($key, $doublefields): $ptype[] = 'd'; break; default: $ptype[] = 'i'; }; }; //make sure we only update the row we are working on $sqlstring .= ' WHERE BoL=' . $FILTERED['BoL']; //connect to the db include('c:\inetpub\security\connection.php'); //ok...let's do this query //use mysqli so we can use a prepared statment and avoid sql insert attacks $stmt = mysqli_prepare($iuserConnect, $sqlstring); if(!$stmt){ die(mysqli_stmt_error($stmt)); }; //implode the two variables to be used in the mysqli bind statment so they are in //the proper formats $params = implode(, , $params); $ptype = implode('', $ptype); --- - is there a better way to accomplish this? - --- //run an eval to build the mysqli bind statment with the string list of variables //to be bound eval(\$check = mysqli_stmt_bind_param(\$stmt, '$ptype', $params);); if(!$check){ die(mysqli_stmt_error($stmt) . 'brbr'); }; yeah, id try call_user_func_array(), omit the line to create a string out of the $params, then merge the later arguments into an array w/ the first 2 args #$params = implode(, , $params); $check = call_user_func_array('mysqli_stmt_bind_param', array_merge(array($stmt, $ptype), $params)); something like that i think should do the trick. -nathan Thanks Nathan! np, please keep responses on list tho, so the conversations end up in the archives for future benefit. Just to make sure I understand call_user_func_array, and how it opperates. It's first paramer is the name of the function...any function, which is part of what made it so confusing to me...and the second paramter is an array that will be used to populate the the parameters of the called function as a comma seperated list. yes, thats correct, however the first argument is of the php pseudo-type callback. which can take one of 3 forms . string of a global function name . array containing, [handle to an object, name of an instance method (string)] . array containing, [name of a class (string), name of a static method (string)] you can find more on the php manual page about pseudo types http://us2.php.net/manual/en/language.pseudo-types.php#language.types.callback -nathan
Re: [PHP] distinguish between null variable and unset variable
Shawn McKenzie schrieb: Daniel Brown wrote: On Thu, Jan 22, 2009 at 15:12, Daniel Brown danbr...@php.net wrote: Unfortunately, neither solution would work. isset() will return FALSE even for an instantiated and explicitly-defined NULL variable. Forgot to mention that, in addition, is_null() will return TRUE for both explicitly-set NULL variables and undefined variables alike. That's why I was testing isset() fist, however as you pointed out, that is crap also. :-( $testvariable1; $testvariable2 = null; $testvariable3 = ''; var_dump($testvariable1); var_dump($testvariable2); var_dump($testvariable3); var_dump( isset( $testvariable1)); var_dump( isset( $testvariable2)); var_dump( isset( $testvariable3)); var_dump( is_null( $testvariable1)); var_dump( is_null( $testvariable2)); var_dump( is_null( $testvariable3)); NULL NULL string(0) bool(false) bool(false) bool(true) bool(true) bool(true) bool(false) Regards Carlos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php spawing/forking issues
bruce wrote: Hi... Playing around with a test app to spawn external child processes. I'd like to be able to spawn/fork/run am external child process, that: -allows the child processes to run as separate independent processes (pid) -allows the child process(es) to be terminated via cmdline (kill -9 pid) i've got a dynamic situation, where i'm reading from an array, and for each item in the array, i want to spawn/fork the child process. i'd like to be able to have 10 copies of the spawned child process running at the same time. the only way i've been able to get my test working, is to spawn a group of processes, and then to iterate through the group, using an array of pids, and doing a wait for each pid in the array. however, this doesn't satisfy me wanting to have a certain number of simultaneous processes running at the same time.. thoughts/comments/pointers to articles that might demonstrate this would be useful. thanks... i can easily post the sample chunk of code i'm playing with if someone wants to look at it! yep send the code; done it a few times in the past but need to see the method you've taken so far -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Redirecting from unreachable page on website
Richard Heyes schreef: ... Really, for URLs that don't exist you should be showing a 404, This way the user doesn't falsely believe that the URL is a valid one and keep using it. if the invalid URL (which outputs a 404 header) then automatically redirects to another URL then I think it's pretty clear that the original invalid URL is not being shown, even grandma understands the change in the addressbar (which is normally highlighted by a background progress-bar effect). technically you are right, often there are reasons for doing it wrong ... usually we refer to them as clients :-P By using the ErrorDocument directive like Per suggested, you can customise it to be distinct helpful, like this: http://www.phpguru.org/oh%20crap Using this method allows users to easily get to where they actually need to be, plus you can potentially promote anything of yours that you want to. yeehaw promote some crap I don't want ... we don't have enough of that on the tubes ... chocolate-covered adWord anyone? :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] To check for existing user in database
2009/1/16 Shawn McKenzie nos...@mckenzies.net: Lars Torben Wilson wrote: 2009/1/15 tedd tedd.sperl...@gmail.com: At 9:46 AM -0800 1/15/09, Chris Carter wrote: Chris: That's not the way I would do it. After establishing a connection with the database, I would use the query: $query SELECT email FROM owners WHERE email = '$emailAddress' : $result = mysql_query($query) or die(mysql_error()); if(mysql_affected_rows()) { // then report a duplicate email/record. } else { // else insert a new record in the dB. } HTH's tedd You want to use mysql_num_rows() there instead of mysql_affected_rows(). (Just a typo in this case, I suspect, but for the benefit of the less experienced it's worth pointing out.) For the newer PHP users, mysql_num_rows() tells you the number of rows you found with a SELECT query, while mysql_affected_rows() tells you how many rows you affected with an INSERT, UPDATE, REPLACE INTO, or DELETE query. Regards, Torben mysql_num_rows() may make more sense, however mysql_affected_rows() will work the same with a select. The PHP mysql_affected_rows() calls the MySQL mysql_affected_rows(), which states: For SELECT statements, mysql_affected_rows() works like mysql_num_rows(). (My apologies for not following the thread for a week. . .) Yes, you are right, except that the restriction isn't with MySQL, it's within PHP. The problem is that if you leave out the optional resource argument it works like you describe, but if you include the argument, PHP barfs. It's good practice to use the one intended for the purpose at hand, even if the other will work in some (or even most) situations. I suppose this is a bug in PHP in that it should really behave the way that the MySQL API does to avoid surprises, but it does illustrate the point that using the intended function is easier in the long run: you know it's been tested against its intended usage and not necessarily against others. Regards, Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php