Re: [PHP] Can't find the server path when, in http.conf, using Alias and DirectoryIndex
2009/8/26 Paul Gardiner : > Paul Gardiner wrote: >> >> I want to write a simple indexing script to display a >> directory full of photos as a gallery of thumbnails. >> (There are various solutions out there for this, but >> they're all a bit more complicated than I need). >> >> I've added a file in /etc/apache2/conf.d that >> looks like this: >> >> Alias /photos /home/public/photos >> >> AllowOverride None >> Order allow,deny >> Allow from all >> >> DirectoryIndex /cgi-bin/index.php >> >> >> >> I use "Alias" so that I can leave the photos where they are >> and not have to move them to DocumentRoot. I use "DirectoryIndex" >> so that the script doesn't have to be in with the photos. My >> problem is that the running script seems to have no way to >> work out the photos are in /home/public/photos. >> >> $_SERVER[REQUEST_URI] is "/photos/", but I can't see how to >> derive the server path from that, since $_SERVER[DOCUMENT_ROOT] >> is "/srv/www/htdocs". >> >> $_SERVER[PHP_SELF] is "/cgi-bin/index.php", so no use either. >> >> >> How can I do this? Is there a way to interrogate the alias, >> or can I set a variable in the conf file that PHP can pick up? > > I've sussed it. If I use this apache2 conf file, where I > tag the server path onto the end of the index url: > > Alias /photos /home/public/photos > > AllowOverride None > Order allow,deny > Allow from all > > DirectoryIndex /cgi-bin/index.php/home/public/photos > > > then the script can pick up the path as $_SERVER[PATH_INFO] > > P. Hi Paul, Glad you got it working. I would add one note: I don't know if this is what your actual code contains or if it's just in your emails, but not quoting string indices in arrays is a Bad Idea (TM). i.e. I'd recommend avoiding the use of something like $_SERVER[PATH_INFO] and instead use $_SERVER['PATH_INFO']. While the unquoted version will work much of the time, it's untrustworthy. In this case, PHP sees the label PATH_INFO and looks for a constant named PATH_INFO. If it doesn't find one, then it interprets the label as a string--which allows things to work. However, if at some point you include code which does a define('PATH_INFO', 'foo'); then what PHP will see is $_SERVER['foo'], which probably isn't what you wanted. This example is of course a little contrived, but unless you know that there is a constant defined with the value you're using, and you want to use that as your array index, then you should always quote string array indices. For more information check out http://www.php.net/manual/en/language.types.array.php#language.types.array.donts Of course, if you just left out the quotes for the purposes of posting then you may happily ignore this message and carry on. :) Cheers (I'm done butting in now), Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't find the server path when, in http.conf, using Alias and DirectoryIndex
2009/8/27 Paul Gardiner : > Torben Wilson wrote: >> >> 2009/8/26 Paul Gardiner : >>> >>> Paul Gardiner wrote: >>>> >>>> I want to write a simple indexing script to display a >>>> directory full of photos as a gallery of thumbnails. >>>> (There are various solutions out there for this, but >>>> they're all a bit more complicated than I need). >>>> >>>> I've added a file in /etc/apache2/conf.d that >>>> looks like this: >>>> >>>> Alias /photos /home/public/photos >>>> >>>> AllowOverride None >>>> Order allow,deny >>>> Allow from all >>>> >>>> DirectoryIndex /cgi-bin/index.php >>>> >>>> >>>> >>>> I use "Alias" so that I can leave the photos where they are >>>> and not have to move them to DocumentRoot. I use "DirectoryIndex" >>>> so that the script doesn't have to be in with the photos. My >>>> problem is that the running script seems to have no way to >>>> work out the photos are in /home/public/photos. >>>> >>>> $_SERVER[REQUEST_URI] is "/photos/", but I can't see how to >>>> derive the server path from that, since $_SERVER[DOCUMENT_ROOT] >>>> is "/srv/www/htdocs". >>>> >>>> $_SERVER[PHP_SELF] is "/cgi-bin/index.php", so no use either. >>>> >>>> >>>> How can I do this? Is there a way to interrogate the alias, >>>> or can I set a variable in the conf file that PHP can pick up? >>> >>> I've sussed it. If I use this apache2 conf file, where I >>> tag the server path onto the end of the index url: >>> >>> Alias /photos /home/public/photos >>> >>> AllowOverride None >>> Order allow,deny >>> Allow from all >>> >>> DirectoryIndex /cgi-bin/index.php/home/public/photos >>> >>> >>> then the script can pick up the path as $_SERVER[PATH_INFO] >>> >>> P. >> >> Hi Paul, >> >> Glad you got it working. > > Actually, since posting, I've given up on that method, > partly because I realised that in doing so I was opening up > a security hole and being close to allowing enumeration of > any apache-readable directory on my server, via direct use > of the url http://cgi-bin/index.php//. I've > found a much better way (using SetEnv): > > Alias /photos /home/public/photos > > AllowOverride None > Order allow,deny > Allow from all > > SetEnv GalleryPath /home/public/photos > DirectoryIndex /cgi-bin/index.php > > > And then the script can pick up the path as $_SERVER['GalleryPath'] > >> I would add one note: I don't know if this is >> what your actual code contains or if it's just in your emails, but not >> quoting string indices in arrays is a Bad Idea (TM). i.e. I'd >> recommend avoiding the use of something like $_SERVER[PATH_INFO] and >> instead use $_SERVER['PATH_INFO']. While the unquoted version will >> work much of the time, it's untrustworthy. In this case, PHP sees the >> label PATH_INFO and looks for a constant named PATH_INFO. > > Thanks for the advice. I've always been a little uncertain of that. I > don't generally leave the quotes out, but I had been tending to, just > for accessing $_SERVER (not sure why - some example code I must have > read I think). Anyway, I'll put the quotes in. > > What about the case of including an array within a string, e.g., > > $line = "$array['name']$array['address']"; Hi Paul, For that, you use curly braces inside strings: $line = "{$array['name']}{$array['address']}"; http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing Regards, Torben > I've read something about that not working with the quotes in place. > Is that best avoided too? > > Cheers, > Paul. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie: Array of objects iteration
2009/10/10 MEM : >> >> MEM, >> >> http://www.php.net/language.oop5.reflection >> >> >> Regards, >> Tommy >> >> > > > And brand new world opens in from of my eyes... O.O. > > I will search more info on this on the net... just for the records, as > properties names is concern, I couldn't find any better I suppose: > http://pt.php.net/manual/en/reflectionproperty.getname.php > > > I'm just wondering, we call it like this? > $property = new ReflectionProperty($myproperty); > $proptertyName = $property->getName(); > > > Can we called statically like this? > $propertyName = ReflectionProperty::getName($myproperty); -> this would > be nice. :) > > The documentation is a little bit lacking, and I'm a little bit newbie, is > this correct? > > Note: > The array_keys as a possibility to retrieve ALL keys from a given array. It > would be nice to retrieve ALL properties names at once as well... > :) > > > > Regards, > Márcio Hi Márcio, You may also find the following useful: http://php.net/get_class_vars http://php.net/get_object_vars http://php.net/reflectionclass.getproperties Regards, Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Probs with a form
On Fri, 2003-07-04 at 15:02, LPA wrote: > Hey, > > I must send datas threw a form, but I dont want to have a submit button.. Is > there a way to 'simulate' the click of a submit button? > > Thnx for your help > > Laurent Hi there, This is really an HTML question, and not a PHP question, but use an instead and it should work for you. The link below will take you to everything you need to know. http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 If you want examples etc, google for something like 'image submit html' and you'll get tons of info. Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] looping through values from a field? Need hellp.
On Sat, 2003-07-05 at 15:55, Micah Montoy wrote: > I have this javascript that enables browsing and selecting of a file. This > file location and name are then transferred further down in the form as an > . Multiple files may be chosen as they are just added one below the > other. Anyway, when the form is submitted it is only retrieving the last > file name from the form. How can I get PHP to return all the values from > the part. Basically this is what is happening: > > 1. Choose a file > 2. File location and name are displayed in the > as > c:\images\filename.gif > The javascript creates the option and a new option is added and appended > when a new file is chosen. > 3. Submit form to php script to send location and stuff to database. > > Anyone have any ideas of how I can get PHP to loop through and pull out each > option value? They are separated by a comma. Right now, it only grabs the > last file even though all files are highlighted before submission. > > thanks http://ca2.php.net/manual/en/faq.html.php#faq.html.select-multiple Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] looping through values from a field? Need hellp.
On Sat, 2003-07-05 at 17:13, Micah Montoya wrote: > Ok. I gave it a shot but have run into one other question that I wasn't > able to find that was addressed by the article. > > My select statement looks like this: > > > > When I create the php file, I am trying something like below but it isn't > working and I am receiving an error. What am I not doing? > > $filename = $_POST["imgList"]; > > for each ($filename as $value) { > echo $value; > } > > thanks Impossible to say without know what the error says. :) Anyway, if that code is cut-and-pasted, then 'foreach' should have no space in it. That would cause a parse error. Otherwise, you could be getting a Notice if you're actually passing something in via method="GET" but checking the $_POST array instead. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error on array loop through foreach?
On Mon, 2003-07-07 at 00:16, Micah Montoy wrote: > I'm using the foreach to loop through a array that is passed from a form. > The form has a multiple select field and the field sends a list of selected > image locations (i.e. c:\\myimages\\rabbit.gif). All the fields are > selected by use of JavaScript before the form is submitted. Anyway, I am > getting the error: Hi there, > Parse error: parse error, unexpected T_FOREACH in > c:\inetpub\wwwroot\webpage10\example\u_images\act_load_imgs.php on line 39 > > Here is the code that I am using. The foreach statement is line 39. > > //loop through all the chosen file names and input them individually > $count = 0 You need a semicolon at the end of the above line. > foreach ($filename as $filevalue){ > > //get file size function > function fsize($file) { > $a = array("B", "KB", "MB"); > $pos = 0; > $size = filesize($file); > while ($size >= 1024) { >$size /= 1024; >$pos++; > } This function definition should not be inside the foreach(), since the second time the loop executes, it will stop and tell you that you can't redeclare an already defined function (and it was defined on the first loop). I haven't checked the rest of it; try the above ideas and see if they help. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what licence for documentation ?
On Mon, 2003-07-07 at 05:49, E.D. wrote: > Hi, > > I'd like to know which licence has the documentation. > PHP licence ? free licence ? public domain ? other ? > > In other words, I want to include some parts in a commercial product, > can I ? > > Please answer only if you *know*, I can't go with suppositions. > > -- > E.D. Ask for permission on the phpdoc mailing list, since that's where the people who know are. This is actually a big topic for discussion right now, since there are few people who would like to put the manual into commercial products. Also, simply searching the PHP site for the license will give results very quickly, and it's linked to from the front manual page. Here's the text of the copyright (note that this is NOT the whole of the license: -- Copyright Copyright © 1997 - 2003 by the PHP Documentation Group. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). Distribution of substantively modified versions of this document is prohibited without the explicit permission of the copyright holder. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder. The members of the PHP Documentation Group are listed on the front page of this manual. In case you would like to contact the group, please write to [EMAIL PROTECTED] The 'Extending PHP 4.0' section of this manual is copyright © 2000 by Zend Technologies, Ltd. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). ------ Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error on array loop through foreach?
On Mon, 2003-07-07 at 21:31, Micah Montoy wrote: > It did help and I altered the script a bit. It now reads as: [snip] > Now I am receiving the error message of: > > Warning: Invalid argument supplied for foreach() in > c:\inetpub\wwwroot\webpage10\example\u_images\act_load_imgs.php on line 43 > > > Anyone have an idea of what may be causing this? > > thanks Are you 100% sure that $filename is an array when you give it to foreach? Check to make sure that $filename exists and is an array first. That should help. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retaining formatting problem
On Tue, 2003-07-08 at 02:29, [EMAIL PROTECTED] wrote: > Hello everyone, > > I have a long running problem that i just want to get covered, I have a standard > text box for people to insert long lengths of text. > > This text box is in a standard but when I insert it into the > database the line returns dissapear, eg > > "this > > little amount of > > text" > > will enter like > > "this little amount of text will enter like" > > Please help me it is p!!$$!ng me right off :P > > Cheers in advance Try this: http://www.php.net/nl2br Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What did I do wrong to cause a parse error?
Hi there, On Thu, 2003-07-10 at 21:53, Phil Powell wrote: > foreach ($profileArray[$i][attributes] as $key => $val) { ^^ You should quote the word 'attributes': http://www.php.net/manual/en/language.types.array.php#language.types.array.donts Sorry...that link might wrap. Anyway, I doubt that's the problem... > $singleProfileHTML .= $key . "=\"" . str_replace("'", ''', > str_replace('"', '"', $val)) . "\"\n"; > } No idea. All I did was copy-paste your code and add a test definition for the other vars, and I just got this: [Script] array('attributes' => array('height' => '"168" cm', 'weight' => '\'65\' kg'))); $singleProfileHTML = ''; $i = 1; foreach ($profileArray[$i][attributes] as $key => $val) { $singleProfileHTML .= $key . "=\"" . str_replace("'", ''', str_replace('"', '"', $val)) . "\"\n"; } print_r($singleProfileHTML); ?> [Output] Notice: Use of undefined constant attributes - assumed 'attributes' in /home/torben/public_html/phptest/__phplist.html on line 36 height=""168" cm" weight="'65' kg" > The parsing error occurs in the "$singleProfileHTML.." line. I'm > completely don't get it; I see absolutely nothing wrong with this, > what did I miss? > > Phil I don't see anything wrong. Perhaps you have a non-printable control character embedded in your code? Try copy-pasting the above code (but quote that array key) and see if that helps. Also, check the code before that line for unclosed quotes and braces/parens or other problems; some parse errors can show up far from where they actually occurred. Other than that, without knowing anything else, it's hard to say off the top of my head. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array key names - can they be called as strings?
On Thu, 2003-07-17 at 14:38, Mike Morton wrote: > Perhaps I was not that clear on the subject :) > > I have the following array: > > $SAVEVARS[headerimage]=$_POST[headerimage]; > $SAVEVARS[backgroundimage]=$_POST[backgroundimage]; > > I want to iterate through it to save to a database config: > > Forach($SAVEVARS as $whatever) { > $query="update table set $whatever=$whatever[$whatever]"; > } > > Where the 'set $whatever' would become 'set headerimage' and > '=$whatever[$whatever]' would become the value that was posted through and > set on the line above. > > The question is the - the assigned string key - is there a way to retrieve > that in a loop? Foreach, for, while or otherwise? > > -- > Cheers > > Mike Morton foreach ($SAVEVARS as $key => $value) { $query = "update table set $key = '$value'"; } Also, unless you have constants named 'headerimage' and 'backgroundimage', you should quote the array subscripts: $SAVEVARS['headerimage'] = $_POST['headerimage']; etc. See the manual for why: http://www.php.net/manual/en/language.types.array.php#language.types.array.donts Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Too much of $GLOBALS[] a problem??
On Thu, 2003-07-17 at 18:35, Ow Mun Heng wrote: > Hi All, > > Just a quick question on this. In my scripts, I'm using A LOT Of > $GLOBALS['my_parameter'] to get the declared values/string. 1 example below > : The only real problem is if you ever want to use that code in anything else. Using lots of globals will make that harder, since it will mean that you cannot simply lift that function out and drop it into some other chunk of code without making sure that the new global space contains all those globals, and that they contain what you expect. This is called 'tightly-coupled' code. It's just harder to reuse. 'Loosely-coupled' code relied much less on the environment around it. It would typically receive its values through an argument list, array of values it needs, or perhaps by being a method in a class which has attribute values for all of the necessary stuff. Other than that, it's not a huge issue. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Too much of $GLOBALS[] a problem??
On Thu, 2003-07-17 at 21:10, Ow Mun Heng wrote: > > 'Loosely-coupled' code relied much less on the environment around it. > > It would typically receive its values through an argument list, array > > of values it needs, or perhaps by being a method in a class which has > > attribute values for all of the necessary stuff. > > The $GLOBALS['parameter'] is actually defined in ONE(a config file that > houses all the parameters and another a language file) place where it can be > changed. So, i would say that's an argument list, is it not? No, it's a configuration file. An argument list is the bit between the parentheses when you write a function call: $retval = some_func($this, $is, $the, $argument, $list); If your config file had all of those variables in an array or something, and you passed that array to your function, *that* would be an argument list. See below: config.php: 1, 'overall_summary' => 'Here is the summary', etc); ?> script.php: Problem solved. The only thing left which can conflict is the name $config, and you could solve that by calling it something you're sure nobody else will be using (maybe $_omh_config or something). Now, you can lift your config file and display_menu_html() function and drop them into pretty much any script and be much more sure that you won't have to crawl through all the code making sure there are no variable name conflicts. > The other way would be to write a function that obtains that from the > argument list. But as I see it, it's basically the same thing? NO? No, because say you want to use this function in another script. First you need to make sure that this new script isn't already using any globals with any of the names you want to use--otherwise, you'll have variable clashes--where you expect one thing to be in $logout, for instance, but the script is using the name $logout for something else, and the value isn't what you expect. > Class.. That's not somewhere I would want to venture, not right now anyway. > Just starting out. > > Cheers, > Mun Heng, Ow > H/M Engineering > Western Digital M'sia > DID : 03-7870 5168 There was a discussion on this list about programming practices and books about programming--I think last week or the week before. Try a search on the archives. Anyway, there are lot of great books on programming which should help--and excellent and easy-to-read book which covers a lot of things which you *don't* want to have to figure out yourself is 'Code Complete', by Steve McConnell. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] list server problem
On Sun, 2003-07-20 at 11:04, Andu wrote: > --On Monday, July 21, 2003 01:34:11 +0800 Jason Wong > <[EMAIL PROTECTED]> wrote: > > > On Monday 21 July 2003 00:39, Andu wrote: > > > >> > The executive summary is that there is nothing to be fixed. If you're > >> > using a less than adequate mail client which does not understand the > >> > mailing list info contained in the headers then you should either > >> > change clients or, even easier, just add the mailing list address > >> > into your address book. > >> > >> Nonsense, all clients understand reply-to if it's there and that is the > >> obligation of the sender which in this case is the list server not my > >> client. > > > > Please read the archives. > > There's several thousand emails in there, give me a subject or something. I > already attempted to do that but the search only takes 2 words, it looks > like and chances I use the relevant ones are low, just spent some time > without any relevant success. I searched using the terms 'list' and 'reply-to', and the thread was on the first page. But it depends on which archive you're searching, of course, and you didn't specify which one you are looking in. The one I used was http://marc.theaimsgroup.com/?l=php-general&r=1&w=2 > So what you're saying is that all the lists i've been on in the past 7-8 > years were doing it wrong but this one doesn't. This is correct. Many lists have used reply-to in a broken fashion, and many people have become trained to expect this behaviour. Please do a search on the net for a document entitled 'Reply-to Considered Harmful' for more discussion on the topic. I've seen arguments about this every couple of months for the last 10 years and quite frankly am too sick of it to bother anymore. (And no, I don't run this list, I just work on the manual.) > The list is not the originator of my message but an inteligent list > server knows that the vast majority of the clients want to reply to > the list not the originator of the message. This is not a valid assumption. I would consider any list broken which tried to outthink my decisions like that. > > It is the mail client's job (or the list subscriber to be more precise) > > to direct a reply to the appropriate place and not the list's > > responsibility to second-guess where a reply should be directed. > > So what do I do if I have one account only? Should I keep changing the > Reply-To for each email I send so that replies to other unrelated mail > don't end up on php list? The list should second-guess members of the list > want to reply to the list 99% of the time without being wrong. I disagree. Oddly, I've known people who have been operating using the correct methodology for well over a decade with no ill effects. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Global variable question question
On Wed, 2003-07-23 at 12:19, Jason Giangrande wrote: > When registered globals is set to off this does not effect the $PHP_SELF > variable right? In other words I should be able to call $PHP_SELF with > out having to do this $_SERVER['PHP_SELF'], right? > > Thanks, > Jason Giangrande Without going into why you didn't read the manual or just try it, the answer is 'wrong'. ;) If register_globals is off, $_SERVER['PHP_SELF'] is what you will need. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm really getting annoyed with PHP
On Thu, 2003-07-24 at 12:41, Beauford.2005 wrote: > Yes, I'm still screwing around with this stupid redirection thing, and > either I'm just a total idiot or there are some serious problems with > PHP. I have now tried to do it another way and - yes - you guessed it. > It does not work. I doubt rather a lot that either of these things is true. But given that header redirects work fine for everybody but you (well, that's overstating it, but I bet that's what it feels like)...something is hooped. If you send me the smallest complete script which manifests the problem, I will check it out for you. The code you've posted so far looks OK. > I mean really, it can not be this hard to redirect a user to another > page. If it is, then I must look into using something else as I just > can't be wasting days and days on one minor detail that should take 30 > seconds to complete. > > If anyone has some concrete suggestion on how to get this to work It > would be greatly appreciated. In the mean time I have given up on it as > I am just totally pissed off at it. > > TIA -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I'm really getting annoyed with PHP
On Thu, 2003-07-24 at 15:12, Beauford.2005 wrote: > action="post" name="seasons"> Try ACTION="/season_write.php" instead. What happens? -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I'm really getting annoyed with PHP
On Wed, 2003-07-23 at 18:21, Daryl Meese wrote: > Well, I know I am not running the latest version of PHP but I don't believe > this is accurate. I believe PHP case sensitivity is based on the os that > processes the file. Can anyone clear this up. > > Daryl OK: you're mistaken. If you're correct, it's a bug. I'm pretty sure we would have heard about it by now. :) But give it a try and post your results (I don't have a Win PHP box set up right now, myself). -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I'm really getting annoyed with PHP
On Thu, 2003-07-24 at 20:24, Beauford.2005 wrote: > It's obvious though that PHP can not handle it. This is why I am forced > to use javascript. I have already spent a week on this and am not going > to waste any further time. I have posted all my code and if someone can > see a problem I'll look at it, but it just ain't worth the effort at > this point. Again, post a script which displays the problem. I've only seen little snippets which do not consitute a working example. It will be seen by many and fixed within minutes. I have had this functionality active every day for years over many different version of PHP in many different environments. The good news is that the problem is not with PHP. That means it's the code, which is easy to fix. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm really getting annoyed with PHP
On Thu, 2003-07-24 at 04:18, Comex wrote: > <[EMAIL PROTECTED]> > Lars Torben Wilson: > > On Wed, 2003-07-23 at 18:21, Daryl Meese wrote: > >> Well, I know I am not running the latest version of PHP but I don't > >> believe this is accurate. I believe PHP case sensitivity is based > >> on the os that processes the file. Can anyone clear this up. > >> > >> Daryl > > > > > > OK: you're mistaken. If you're correct, it's a bug. I'm pretty sure we > > would have heard about it by now. :) > > > > But give it a try and post your results (I don't have a Win PHP box > > set up right now, myself). > > PHP 4.3.2 and 5.0.0b1 on Windows > > $a = "set"; > print '$A is '; print isset($A) ? 'set' : 'unset'; print ''; > print '$a is '; print isset($a) ? 'set' : 'unset'; > ?> > > $A is unset > $a is set Thanks. The same file on Linux PHP 4.3.2 produces the same output. The manual is correct: variable names in PHP are case-sensitive, full stop. It is not dependent upon the OS. This is explained here: http://www.php.net/manual/en/language.variables.php Thanks for the Win test, Comex! Cheers, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP should know my data!
On Thu, 2003-07-24 at 15:04, John Manko wrote: > I just wrote a web app, but I'm completely disgusted with PHP. The > application works great, but PHP is not smart enough to know what data > belongs in my database. Really, I have to enter the stuff in myself. I > spent 2 long days writing this (sweating and crying), and you mean to > tell me that it doesn't auto-populate my database information? Come on, > people! Data entry is the thing of the past! Maybe I'll convert my > codebase to COBOL or something. At least, it has proven experience with > user data! Sometimes I wonder how long this "innovative" technology > will last when there are incompetent languages like PHP, Perl, and > Java. Color me disappointed. > > John Manko > IT Professional I'm not sure what you mean that PHP should automatically know what goes into the database, but if you post a detailed description of the problem you're facing, chances are that someone (or several someones, more likely) will provide suggestion to help you out. Feel free to post details if you would like a hand with it. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP should know my data!
On Thu, 2003-07-24 at 15:24, John Manko wrote: > LOL :) - Now that's funny! > > Robert Cummings wrote: > > >Unfortunately I don't think some people "got" the joke. Next thing you > >know their going to complain that PHP should have told them the > >punchline ;) > > > >Cheers, > >Rob. Oh fer Pete's sake. lol--got me. The sad thing is that sometimes things get to a point on the list where this sort of thing would seem likely... -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] List Administrator
On Wed, 2003-07-30 at 11:11, Chris W. Parker wrote: > Johnny Martinez <mailto:[EMAIL PROTECTED]> > on Wednesday, July 30, 2003 11:07 AM said: > > > Google spidered the web view to the list and is indexing our email > > addresses. Any chance you can edit the code to change > > "[EMAIL PROTECTED]" to show as "user at domain dot com" as many of the > > public message boards do? This will help reduce the spam we get. > > Until all the email harvesters start to recognize those types of email > addresses too. > > > Chris. 'Until' is a bit optimistic. They've been doing that for quite some time now. :) -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] List Administrator
On Wed, 2003-07-30 at 11:07, Johnny Martinez wrote: > List Administrator, > Google spidered the web view to the list and is indexing our email > addresses. Any chance you can edit the code to change "[EMAIL PROTECTED]" to > show as "user at domain dot com" as many of the public message boards do? > This will help reduce the spam we get. > > Johnny The problem is that this list is archived in a zillion places, and the list moderators don't have any control over the archives. It's up to the individual archive maintainers to deal with this kind of thing. For instance, marc.theaimsgroup.com, phpbuilder.com, and anybody who runs an NNTP web interface which includes this list--just to name a few--have web-accessible archives of this list, and are unaffiliated with the PHP group. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using register_globals
On Thu, 2003-06-05 at 01:09, [EMAIL PROTECTED] wrote: > One thing that hasn't been mentioned explicitly about register_globals > turned to off is the readablity of the code and thus the reuse of code. > When you use GET, POST, etc... everybody reading your script knows exactly > where the data is coming from and can make a fairly good assumption to its > use. On the other hand when using register_globals on, you have no way of > knowing without having to step through the whole script. > And lets be honest, most developers tend to be sloppy on commenting their > code since they think it is perfectly self explanatory. (including me btw) > > > Another issue I haven't read so far is that making your scrip work when > register_globals is off makes it to be more compatible since scripts using > GET and POST array should still work on systems that have register_globals > turned on. > > Regards > Stefan At the risk of sending a 'me too' message to the list, I would just like to say that I think these are excellent points. Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Morph an object
On Wed, 2003-06-04 at 17:18, [EMAIL PROTECTED] wrote: > You have the problem right. What do you mean by a "server push"? Sounds > interesting... > > Anyway I have to display something. Since its a login, the user needs their > interface. I think I'll have to introduce another page... I'd love to > avoid that though... > > /T Search for "server push" (use quotes) on google...essentially, it means that the server can update information in the browser. Unfortunately, it is extremely limited and usually not worth the hassle. My suggestion would be to do something like this: have a page which shows a login form. The form posts back to itself (the same page). When there is no input, the script displays a blank login form. If there is input, the script attempts to validate the login data. If the data validates, the script somehow calls the next page (sends a redirect header, or include()s the code, or instantiates that page's class, etc...). If not, it redisplays the form, perhaps with some added information about what went wrong. It's important to note that nothing is ever sent to the browser until all needed information is known...that way, you always have the option to alter the output, or send a redirect header, or whatever. Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Using register_globals
On Thu, 2003-06-05 at 05:28, Jay Blanchard wrote: > [snip] > Another issue I haven't read so far is that making your script work when > register_globals is off makes it to be more compatible since scripts > using GET and POST array should still work on systems that have > register_globals turned on. > [/snip] > > So what you're asking for is a variable handler that will take care of > things whether or not register_globals is turned on or off and you want > the variables considered across a range of PHP versions? If so there > have been many of those ideas posted, check the archives. > > HTH! > > Jay I think he was just saying the using $_GET and $_POST is a better way to make sure that your script is compatible across as many installations and version than using register_globals = on, since it will always work. :) Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help with display of results
On Fri, 2003-06-06 at 14:32, Gloria L. McMillan wrote: > Hi, again! > > I did not see my question as yet so I will repost it. > > I have had help writing HTML code to display the results of my PHP--> McSQL actions. > > But when I attempt to show the DATE and q40 (comments) with the HTML code below, > all I see on screen is: ]in the upper left corner. You should probably be seeing a parse error...see below. > URL: http://DakotaCom.net/~glomc/forms/Adj03.html (A poll on part-time faculty) > > Here's the code for the display that is not working... > But the "]" may refer to earlier code in this long php file. > I did not send the whole file, only the HTML part. > > /* Printing results in HTML */ > > > /* COMMENTED 2002-05-02 > print "\n"; > while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { > print "\t\n"; > foreach ($line as $col_value) { > print "\t\t$col_value\n"; > } > print "\t\n"; > } > print "\n"; > */ > while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { > printf(" > > > DATECOMMENTS\n > > %s%s > > > > > > \n", >$row['added']); >$row['q40']); The ); closes the printf(), but the next line continues on to attempt to add more arguments. You would either need to do this: $row['added'], $row['q40']); ...or, better yet, something like this, so you aren't printing out the whole table for each row in the results: echo " DATECOMMENTS\n "; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo " {$row['time_stamp']}{$row['heading']}\n"; } echo " "; Hope this helps, Torben > } > > /* Free resultset */ > > mysql_free_result($result); > > > /* Close the database connection */ > > mysql_close($link); > > ?> > > > > -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need help with display of results
On Fri, 2003-06-06 at 18:45, Lars Torben Wilson wrote: [snip] > while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { > echo " > {$row['time_stamp']}{$row['heading']}\n"; > } Whoops...replace 'time_stamp' with 'added' and 'heading' with 'q40', of course. :) Sorry, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] foreach and mysql_fetch_array problem
On Tue, 2003-06-03 at 02:12, Bix wrote: > I'm fine with using while loops, use them for most of my listing work, but I > wanted to try using a foreach loop instead but it seemed not to work as > expected. For ym table generation, I need the $key to do some maths on in > order to get my table looking right. All the guts are done, but for some > reason, when usng a foreach loop, foreach (mysql_fetch_array($result) as > $key => $value) $value is not an array of the fields. Whereas with a while > loop, it works fine. Is this a problem with foreach? > > If it is, i'll stick to while, but with a counter to generate a key. Nope...it's working perfectly. mysql_fetch_array() returns an array. foreach() operates on an array. What you have: foreach (mysql_fetch_array($result) as $key => $article) { //. . . } ...is the same as saying this: $arr = mysql_fetch_array($result); foreach ($arr as $key => $article) { //. . . } So it is iterating over the correct array (the returned row array) instead of the array over which you want it to be iterating (the array of rows). Using the counter is probably your best bet. mysql_fetch_array() doesn't return any information on which row it's currently returning. Hope this clears it up a bit, Torben > "Justin French" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > This is correct: > > > > while($myrow = mysql_fetch_array($result)) > > { > > // ... > > } > > > > The iteration of the while loop represents one returned row from the mysql > > result, with $myrow being an array of values returned. > > > > Rather than a SELECT * query, let's look at a something where we know the > > column names: > > > > > $sql = " > > SELECT first, surname, age > > FROM employee > > WHERE age >= 18 > > LIMIT 50 > > "; > > $result = mysql_query($sql); > > while($myrow = mysql_fetch_array($result)) > > { > > echo "Name: {$myrow['first']} {$myrow['surname']}. Age: > > {$myrow['age']}"; > > } > > ?> > > > > > > Now, given the above code, what else do you need to do? > > > > > > Justin > > > > > > > > > > on 03/06/03 8:25 AM, Bix ([EMAIL PROTECTED]) wrote: > > > > > Hi all, > > > > > > I am trying to build up a table using values from a db as follows... > > > > > > mysql_select_db($db, $sql_connection); > > > $result = mysql_query("SELECT * FROM $table WHERE $query LIMIT > > > $limit",$sql_connection); > > > $output = " > > width=\"370\">\n"; > > > foreach(mysql_fetch_array($result) as $key => $article){ > > > //stuff > > > } > > > > > > now if I use a while loop ie: > > > > > > while ($array = mysql_fetch_array($result)){ > > > //stuff > > > } > > > > > > all the matched rows are processed, however with the foreach model, > $article > > > isnt an array, it is the first row all merged together. > > > > > > Any ideas? > > > > > > ;o) > > > > > > > > > -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OK guys, thank you so far
On Tue, 2003-06-03 at 13:20, David Nicholson wrote: > Hello, > > This is a reply to an e-mail that you wrote on Tue, 3 Jun 2003 at 20:04, > lines prefixed by '>' were originally written by you. > > I've tried and here's the output: > > Undefined index: input > > if ($HTTP_GET_VARS['printout'] != "yeah") { include("header.php"); } > > You have error reporting set to E_ALL, turn it down a bit. > > More information at: > http://uk2.php.net/error_reporting > > David. This is a good idea for a production machine, but for your development environment, turning down error reporting is not a good idea. :) You will kill yourself trying to track down subtle errors when they aren't displayed. Try checking your variables before using them: if (isset($_GET['printout']) && $_GET['printout'] != 'yeah') { // . . . } Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Validating user input
On Tue, 2003-06-03 at 02:46, Sichta Daniel wrote: > Another way is to do it on client side (javascript) > > DS Indeed, but then you have to be prepared for it not to work if the user doesn't have js enabled. Torben > -Original Message- > From: Shaun [mailto:[EMAIL PROTECTED] > Sent: Tuesday, June 03, 2003 11:21 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Validating user input > > > Hi, > > I am creating a timesheet application, how can I make sure that a user has > entered a number, and that the number is a whole number or a decimal up to 2 > places, and that the number is less than 24? > > Thanks for your help > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Change object state
On Tue, 2003-06-03 at 14:34, [EMAIL PROTECTED] wrote: > Is there any way I can change the state of an already instantiated object? > > ex: > > $thisone = new Object(); > > $content = something; > > $thisone -> SetContent($content); > > $thisone -> Display(); > > > That creates the object. Now if I want to change its content: > > $content = something different; > > $thisone -> SetContent($content); > > $thisone -> Display(); > > This does not work but it illustrates what I want to do. I need to change > the content property of the "thisone" object. This should definitely work. However, without the code to the Object class there is little way to tell where the problem is. Presumably the SetContent() method is deciding not to work a second time for some reason (perhaps the new content fails to satisfy some kind of requirement for valid content input?) Torben > R/T > -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doing simple math
On Tue, 2003-06-03 at 19:49, Chris Cameron wrote: > I'm having a problem I don't think I should be having. Basically, I'm > doing some simple math, and I'm having issues in making PHP do it (with > the brackets in particular). > > An example that looks like it -should- work: > > $Math = sqrt(81)(5+4)-1; > > Well of course that doesn't work because of the (I believe) brackets. > I'm unable to think of any easy alternative that wouldn't make > reading/writing these things terribly messy/hard. > > The above examples I just pulled out of the air, but I need to deal with > many groupings with brackets, various functions (pow() and sqrt() > mostly) and basic addition and subtraction, which adds a greater > complexity. > > Have I missed something obvious? Or am I doomed to do a bunch of smaller > math things so that I can do these bigger ones? What is the relation between the sqrt(81) and the (5+4)-1? i.e. there is no operator there...which operator *should* be there? Torben > Thanks, > Chris > > -- > Chris Cameron > UpNIX Internet Administrator > ardvark.upnix.net > bitbucket.upnix.net > -- > http://www.upnix.com -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Doing simple math
On Tue, 2003-06-03 at 20:02, Chris Cameron wrote: > On Tue, 2003-06-03 at 20:59, Lars Torben Wilson wrote: > > On Tue, 2003-06-03 at 19:49, Chris Cameron wrote: > > > > > > An example that looks like it -should- work: > > > > > > $Math = sqrt(81)(5+4)-1; > > > > > > What is the relation between the sqrt(81) and the (5+4)-1? i.e. there > > is no operator there...which operator *should* be there? > > > > Hmm, I'm thinking multiplication. It's been a while since I've been in a > classroom, but "9(9)" would mean '81' to me. Although it's looking as > though PHP doesn't do things like that. > > Being able to do that though really "cleans" things up for me though. Unfortunately, that's not how PHP works...for one thing, the parser would need some kind of insight into when something next to a set of parentheses should be multiplied with the contents of the parens...:) FWIW, 9(9) means '9 * (9)' to me, but only on paper, and in the context of algebra. In the context of programming, I would typically read it as 'call the function named 9 with the argument 9'. The multiplication operator in PHP is *. Hope this helps, Torben > > Torben > > > > > Thanks, > > > Chris > > > > > > -- > > > Chris Cameron > > > UpNIX Internet Administrator > > > ardvark.upnix.net > > > bitbucket.upnix.net > > > -- > > > http://www.upnix.com > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calling HTML pages
On Wed, 2003-06-04 at 13:15, Daniel J. Rychlik wrote: > I was looking for a function that will take you to a html page. For instance. > > I have a function that checks for !empty values in $_POST; What I would like to do > is if the field is empty then > > go back to the form. I have a function > > function display_error ($err) { > > echo $err; # I need to redirect or automatically go to the previous page. > > } > > Is their a PHP function already written that does this ? One idea: header("Location: form.html"); With this one, you have to jump through some (admittedly not difficult) hoops to get your data across the redirect (post it). Another: Write a function to generate the form for you and call that. Another: include("form.html"); exit(); With these two, the data is already available within the script, so it will be easier to show what data was wrong/missing/et cetera. It's usually easier to have the script which generates the form handle its input as well, and then pass the resulting data whereever it needs to go. > TIA > Daniel Just some thoughts, Torben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Migration once again
On Wed, 2003-06-04 at 12:51, Øystein Håland wrote: > I'm sorry Dan, but it don.t make any difference. Here's almost the complete > code: The easiest way to fix it is to enclose the $_SERVER['PHP_SELF'] in curly braces when you embed it into a string. See the manual: http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex Hope this helps, Torben > $target = "se"; > $languagefile = "../recycle/language_" . $target . ".php"; > include("$languagefile"); > > echo " > > > "; > if (ereg("/math", $_SERVER['PHP_SELF']) == true) { > echo " > some javascript here "; > } > else if (ereg("/prov/", $_SERVER['PHP_SELF']) == true) { > echo " > some more javascript here "; > } > echo " > > > > > "; > ?> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Using register_globals
On Wed, 2003-06-04 at 10:43, Rouvas Stathis wrote: > Armand Turpel wrote: > > > > > On Wed, 4 Jun 2003, Jay Blanchard wrote: > > > > [snip] > > > > Have register globals set to ON is one way of leaving your script open > > > > to being exploitable. > > > > [/snip] > > > > > > > > Please explain this, how does it make it more exploitable? I think that > > > > this is only true if the code is sloppy. > > > > > > Correct, if you properly initialize your internal variables there is > > > nothing insecure about leaving register_globals on. > > > > But how you know, if you have a few tausends of php code lines, which part > > have some sloppy code. Nobody is perfect. In my opinion you should turn > > register_globals to off if it's possible. It's much more secure. > > I strongly disagree with that. > Consider the following code (assuming $foo is 'external' variable): I think his point had more to do with the fact that there is some benefit to having register_globals = off in that everybody is going to screw up sometime, and with register_globals = off at least you have a bit more help when you do. >From my point of view, this whole thing is being looked at the wrong way 'round. The question shouldn't be "what is the advantage of register_globals = off?", but "what is the advantage of register_globals = on?" The answer, of course, is that there isn't any. While the advantages of 'off' have been way overblown, at least there are some. :) Torben > 1: if ($foo=='yes') transfer_money_to_me(); > > 2: if ($_GET['foo']=='yes']) transfer_money_to_me(); > > Why (2) is safer than (1)? Answer: It is *not*. > > As Rasmus has correctly pointed out, the usage of "register_globals=off" > per se cannot be considered a security measure. If you don't initialize > and/or check *all* user-supported variables, you're dead. It's as simple > as that. Is it annoying? Maybe. Is it necessary? *yes* > > Anyway, IIRC the whole issue of register_globals started when some guy > presented a paper named "A Study in Scarlet". A whole lot of issues > where presented in that paper, which in my opinion, have been blown > quite out of perspective. register_globals is one of them. > > Oh boy, this is starting to look like an urban myth : "-Hey do you know > that register_globals=on is bad? - Really? -Yeah, and you know what? It > allows the bad boys do vil things". > > -Stathis. > > > > > > > > > -Rasmus > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Morph an object
On Wed, 2003-06-04 at 14:43, [EMAIL PROTECTED] wrote: > All ye noble Knights of PHP: > > Got an interesting problem, > > I am creating a login routine for my PHP website. Each page is an extension > of the root page object. I am creating a loginpage.php which is an object > with a constructor: > > class Login extends Page > { > > function Login($file) > { > if(isset($file)){ > if(!isset($this->content)){ > $this->content = $this -> Display($this -> SetContent($file)); > print ($this->content); > } else { > $this -> DisplayNothing(); > $this->content = $this -> Display($this -> SetContent($file)); > print ($this->content); > } > } else { > mysql_error(); > } > } > > Note the DisplayNothing(); function call, I am attempting to remove what is > currently displayed on the browser window and replace it with new content. > I am trying to do this by invoking the constructor in another script with a > different argument. To modify the browser window content after you've already sent it, you'd need to use one of client-side scripting, server push, or client pull. In general, however, once PHP has sent output to the browser, it's gone. The browser has it, and that's it. :) Perhaps you could defer sending your content to the client until after all your tests have passed and the script knows what it needs to display? Pardon if I've misunderstood the problem. Torben > It is not working and I am wondering is anyone can give me some insight into > morphing an object? > > > Thanks!/T -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need a safe way to get user supplied data into a varaible.
On Sun, 2003-06-08 at 17:15, Simon Coggins wrote: > Hi, [snipped for brevity] > I need some way of putting a block of text into a variable without > having to read it in from a file. From the template point of view, all > that happends is a token is replaced with the body of the text. So > reading that in from a file is hard. > > Thanks Single quotes will do this; http://ca.php.net/manual/en/language.types.string.php#language.types.string.syntax.single $body = ' Some text here. '; Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stripping newlines from a string
On Sun, 2003-06-08 at 22:44, Charles Kline wrote: > Hi all, > > How would i go about stripping all newlines from a string? > > Thanks, > Charles Something like this: Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about current() and key()
On Mon, 2003-06-09 at 14:38, Jim Lucas wrote: > Does anybody know any benifits to using current() and key() See below: > I will show two examples of what I mean. > > > echo ""; > > $arr1 = array(array(1 => 10), > array(2 => 12), > array(3 => 13), > array(4 => 14), > array(5 => 15), > array(6 => 16), > array(7 => 17), > array(8 => 18), > array(9 => 19) > ); > > foreach ( $arr1 AS $value ) { > echo pow(key($value) , current($value))."\n"; > } > > $arr2 = array(1 => 10, > 2 => 12, > 3 => 13, > 4 => 14, > 5 => 15, > 6 => 16, > 7 => 17, > 8 => 18, > 9 => 19 > ); > > foreach ( $arr2 AS $key => $value ) { > echo pow($key , $value)."\n"; > } > > ?> > > > Now for me, these return the same results. > > I would think that it would be overhead to use current() and key() in the > above example. > > Can anybody point out why the first one would be better to use and why. No, you're right. There are situations where you might want to use these two functions, but this isn't one of them. Doesn't buy you a thing in this situation. :) There are times I've found them useful, though, although I won't contrive an example for you...you'll usually know when you've found one. > Jim Lucas -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is It Possible to Tell PHP To Output x Decimal Places PerFloat?
On Mon, 2003-06-09 at 15:22, Dan Anderson wrote: > Is it possible to tell PHP when converting a number to a string (i.e. in > an echo or print command) to use x decimal places? > > Specifically, if I > >echo '$' . $some_price; > ?> > > And some_price is $1.50, it outputs: > > $1.5 > > Thanks in advance, > > Dan http://ca2.php.net/manual/en/function.number-format.php ...i.e.: Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Warning Spammer
On Tue, 2003-06-10 at 04:33, myphp wrote: > The email address I use on this list is never used > anywhere else in the world so only a list member must > have used it to send me the message below. It did not > come through the php lists. Come again? I don't follow your logic. Anyone could have gotten your email address if you have ever posted to the list. There is no reason for you to suppose that it is a list member. It's spam. Either track it down and hunt it, or ignore it and delete it. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Questions, questions, questions...
On Tue, 2003-06-10 at 16:34, Sparky Kopetzky wrote: > Ok - let the war begin... > > Question: Why doesn't the PHP community support using an Hungarian > style of programming if it prevents errors?? I've gotten too darn many Haven't really seen this one flamed over on this list before, but maybe someone will step in an freak out later on. At any rate, you make the assumption here that Hungarian notation somehow inherently prevents errors. This is believed by some to be true, and by others, to be false. Hungarian notation does provide a set of tools for helping to prevent errors, true--but any proper coding convention does that. Past that, there is little to choose between them except personal preference. There are compelling arguments both for and against any given convention, and all have their adherents. In the end, one must be chosen--and for this project, one has been. Personally, I think it is an excellent choice. > times now by a type mismatch using what the 'Bible' of PHP programming > style recommends - PHP Coding Standard by Fredrik Kristiansen. I'm > sorry - $MonkeyBrains doesn't tell me anything about what type is or > what type it holds. $intMonkeyBrains DOES and I can tell instantly > that $intValue shouldn't hold $strValue without a type coersion. (I > know PHP will blindly stick the string in and replace the integer...) That's the price of a loosely-typed language. Buys you more than it costs IMHO, but I understand if you differ. :) > Question: Is there a better way in classes to access/modify var's other > than get_var, put_var functions? Works great for me and I know whether > I'm saving a variable or accessing it. Sure, I'd like to be able to > use a VB style Set/Get property but who wouldn't?? Well, you could check out the experimental overload extension at http://www.php.net/manual/en/ref.overload.php, which may be what you're looking for. Otherwise, just be careful with your references to try to keep array/object copies down, and use accessor methods. > Feel free to email me directly if this will generate a firestorm in the > maillist. Well, at least you didn't mention emacs or vi. ;) Regards, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Questions, questions, questions...
On Wed, 2003-06-11 at 05:21, Jay Blanchard wrote: > I think that part of the problem is that many PHP developers come to > programming from the largely self-taught web community (not that there > is anything wrong with that). They have never programmed before (doing > HTML and CSS is NOT programming) and probably have scant little > experience with using databases. Therefore these folks have missed a lot > of what experienced and learned programmers know and do. (See my > previous rants on planning, documentation, modeling, flowcharting, etc.) > > These things all become especially important when you have multiple > code-jockeys working the same project. You have to have checks and > balances. Stating the notation style is one check, confirming at the end > of the day that the variables contain what you expect them to at every > step is another. It takes us a couple of extra steps to generate > accountability for these things in PHP because variables are not > strongly typed, but we have come up with methods to handle this. > > I think that it is incumbent upon those of us who have these "best > practices" in place to encourage and educate those who do not. > > Jay I'm not going to get into this argument on the list, but feel free to email me off-list. At any rate, I'm not sure what your point is except to attempt to educate me that coding standards are a Good Thing, which is rather obvious. My point is that there has been no conclusive argument made that Hungarian notation is a quantitatively better method than any other. Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined variable: action
On Wed, 2003-06-11 at 12:22, Ryan M wrote: > Thanks for the advice... The link worked Now it is saying this: > > Notice: Undefined index: action in > > It only says this if there is no action...it goes away once I click the link > and the action=someaction Is there a way to fix my php so that I dont > have to change all of the web sites hosted on my server?? Thanks! > > Ryan Check and initialize your input variables: if (!isset($_GET['action'])) { $action = ''; } else { $action = $_GET['action']; } switch ($action) { case 'something': do_something(); break; case 'something_else': do_something_else(); break; default: echo "Unrecognized action given"; break; } If this is something you need to do for every page on your site, put the if() check into an auto-prepended file or something. Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array sort help...
On Wed, 2003-06-11 at 12:10, Dan Joseph wrote: > Hi, > > I cannot figure this out... Need some assistance. > > I have an array: > > $jack[#] = array( > "loan_info" => 101, > "first_name" => jack, > "last_name" => mother > ); > > # = 0 thru 12 > > I want to sort the array by loan_info. Could someone please explain this > to me? I kind of understand array sorting, but I am still lost... > > -Dan Joseph If you want to maintain key order, use uasort(); if, however, you want the array to be reindexed sequentially when you sort it, use usort(): http://www.php.net/manual/en/function.uasort.php http://www.php.net/manual/en/function.usort.php A short example (with the usual caveats about 'make sure you add error checking): 104, 'first_name' => 'jack', 'last_name' => 'mother'), array('loan_info' => 102, 'first_name' => 'jill', 'last_name' => 'brother'), array('loan_info' => 108, 'first_name' => 'jim', 'last_name' => 'the'), array('loan_info' => 107, 'first_name' => 'bob', 'last_name' => 'whole'), array('loan_info' => 105, 'first_name' => 'alice', 'last_name' => 'fam'), array('loan_info' => 103, 'first_name' => 'ellen', 'last_name' => 'damily')); function cmp($a, $b) { return strcmp($a['loan_info'], $b['loan_info']); } uasort($data, 'cmp'); print_r($data); ?> Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] undefined variable: action
On Wed, 2003-06-11 at 13:40, Mark wrote: > Or you can simply turn off NOTICE error reporting in the php.ini file > or use ini_set or error_reporting() to not include notices. This > should not affect functionality. That's not a good idea; it's treating the symptom, not the problem. A better idea is to crank up error reporting all the way on your dev box, write your code so that it doesn't generate any NOTICES etc, and then turn off display_errors on the production box. It's a good idea to log the errors or write a handler or something for when errors aren't being displayed. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sending TCP/IP string using PHP??
On Wed, 2003-06-11 at 15:58, AES Security - Brian Celenza wrote: > Okay hopefully I can explain this system well enough. > > What I am trying to do is send a tcp/ip request to a visual basic program > using php. > > Is there anyway to send raw data over tcp/ip using php, or how would i be > able to make some sort of adapter to take the request and be able to read it > from a vb program running on the server? > > Thanks, sorry if this is confusing. > > Brian Everything you need should be in the manual: http://www.php.net/manual/en/ref.sockets.php http://www.php.net/manual/en/ref.stream.php Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting file contents
On Wed, 2003-06-11 at 10:45, Matt Palermo wrote: > I would just copy the file, but I am not sure how to copy the file and paste > it in the same folder with a different name. Any advice you can give for > that? Thanks. > > Matt I may be missing something, but: copy('/path/to/origname.txt', '/path/to/newname.txt'); ...should do it. http://www.php.net/copy Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 4 hours staring - can't see clear.
On Wed, 2003-06-11 at 15:55, jtjohnston wrote: > Can someone see clearly through what I'm trying to do please? > I've been at this for 4 hours trying to see where I have gone wrong. [snipped] Might something like this work? array ( 'Description' => 'Title: (TI)', 'Option' => 'ST', ), 'AU' => array ( 'Description' => 'Author(s): (AU)', 'Option' => 'AU', ), 'PB' => array ( 'Description' => 'Publication Information: (PB)', 'Option' => 'BT', ), 'SOM' => array ( 'Description' => 'Source (Bibliographic Citation): (SO)', 'Option' => 'JR', ) ); $filename = 'test_enreg.txt'; $fh = fopen($filename, 'r'); $fileContents = fread($fh, filesize($filename)); $lines = explode("Enregistrement", $fileContents); $dbtable = 'test_table'; foreach($lines as $line) { $line = stripslashes($line); $line = str_replace("\r", "", $line); $newlines = explode("\n", $line); // Init to keep clean--if you really need them as separate scalars, // try extract()ing $record, although they'll get overwritten on // each iteration. $record = array('ST' => '', 'AU' => '', 'BT' => '', 'JR' => ''); $found = false; // Just a flag to avoid empty SQL statements. foreach($newlines as $newline) { if (empty($newline)) { continue; } list($key, $val) = explode(':', $newline); if (isset($var[$key]['Option'])) { // Flag that we got one this time round. $found = true; // Get the translated name from $var. $record[$var[$key]['Option']] = trim($val); } }#end of foreach($newlines as $newline) if ($found) { $sql = "INSERT INTO $dbtable (ST, AU, BT, JR) VALUES ('{$record['ST']}', '{$record['AU']}', '{$record['BT']}', '{$record['JR']}')"; echo "$sql\n"; } }#end of foreach($lines as $line) ?> -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 4 hours staring - can't see clear.
On Wed, 2003-06-11 at 21:00, John Taylor-Johnston wrote: > Lars, > > Thanks. I am getting this error however: > > Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in > > It does not like addslashes() because of the {}? What is a sensible work around? Or > do I even need addslashes?? > > if ($found) > { > $sql = "INSERT INTO $dbtable > > (RNum,YR,AU,ST,SD,SC,BT,BD,BC,AT,AD,AC,SR,PL,PR,JR,VNum,INum,DT,PG,LG,SF,OL,KW,AUS,GEO,AN,RB,CO,RR) > VALUES > > ('{addslashes($record['RNum'])}','{addslashes($record['YR'])}','{addslashes($record['AU'])}','{addslashes($record['ST'])}','{addslashes($record['SD'])}','{addslashes($record['SC'])}','{addslashes($record['BT'])}','{addslashes($record['BD'])}','{addslashes($record['BC'])}','{addslashes($record['AT'])}','{addslashes($record['AD'])}','{addslashes($record['AC'])}','{addslashes($record['SR'])}','{addslashes($record['PL'])}','{addslashes($record['PR'])}','{addslashes($record['JR'])}','{addslashes($record['VNum'])}','{addslashes($record['INum'])}','{addslashes($record['DT'])}','{addslashes($record['PG'])}','{addslashes($record['LG'])}','{addslashes($record['SF'])}','{addslashes($record['OL'])}','{addslashes($record['KW'])}','{addslashes($record['AUS'])}','{addslashes($record['GEO'])}','{addslashes($record['AN'])}','{addslashes($record['RB'])}','{addslashes($record['CO'])}','{addslashes($record['RR'])}')"; > echo "$sql\n"; > } Ah...in this case, the addslashes() is being called from within the quotes, so it won't get called. In this case, I would suggest moving it to the assignment above: if (isset($var[$key]['Option'])) { // Flag that we got one this time round. $found = true; // Get the translated name from $var. $record[$var[$key]['Option']] = addslashes(trim($val)); } ...that way, you know it's been called on everything, and you don't have to hunt around and change it in a bunch of places if you decide on something else later on. Cheers, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION as $key=>$value
On Fri, 2003-06-13 at 16:28, Daniel J. Rychlik wrote: > I read the document 4 times. I understand how it works and now Im excited > about applying this to my application, however Im running into a problem. > Im recieving an error on my page. > > I have this in my form. > /> > > and when running, I recieve > Notice: Undefined index: fname This is because when the form is first submitted, nothing has been submitted, and thus $HTTP_POST_VARS['fname'] has no value. PHP is simply warning you that you're trying to use an unitialized value. Check the value first and you'll not have a problem with it: If the first line looks odd, check out: http://ca2.php.net/manual/en/language.expressions.php You could just turn down your error reporting, but all that does is hide from you the fact that you're using code with problems in it. You should make sure the code executes in a development environment with full error reporting on without warnings or notices, before you turn off error display on the production box. Torben > I also used the example from here > http://www.zend.com/zend/spotlight/form-pro-php4.php and I recieved the same > message. > > Any Ideas, to help me break through these barriers? > > Thanks so much > Dan > > > > - Original Message - > From: "Ralph" <[EMAIL PROTECTED]> > To: "'Daniel J. Rychlik'" <[EMAIL PROTECTED]>; > <[EMAIL PROTECTED]> > Sent: Friday, June 13, 2003 1:50 AM > Subject: RE: [PHP] $_SESSION as $key=>$value > > > > Daniel, > > > > Rather than sending them to a new page to validate the form and then > > sending them back if a field is invalid, do the error checking from the > > same script. > > > > Here's an example, a bit simple but just to give you an idea. > > > > For a better explanation, you should read this article which elaborates > > on this method: > > > > http://www.zend.com/zend/spotlight/form-pro-php4.php > > > > > > > > > if($HTTP_POST_VARS){ > > > > // check for required fields > > if(!HTTP_POST_VARS['name'] || !HTTP_POST_VARS['email']) > > $error_message = 'You did not provide all required fields' > > } > > > > // any other error checking you want to do > > > > ?> > > > > > > > > > // if error, print out error message > > if($error_message){ > > echo $error_message; > > } > > > > ?> > > > > > > > > > > and so on > > > > > > > > -Original Message- > > From: Daniel J. Rychlik [mailto:[EMAIL PROTECTED] > > Sent: Thursday, June 12, 2003 2:40 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP] $_SESSION as $key=>$value > > > > Is this valid to iterate over a form variables.? > > > > foreach ($_SESSION as $key=>$value) > > > > and another question, do I need this > method="post"> in my form? > > > > Im really struggling with $_SESSION. Im trying to program smarter and > > make friendlier applications. > > > > Ive submitted several emails dealing with this function and I apologize > > for beating a dead horse, so to speak. > > > > I have a form with a few form fields. Im working on an error function > > that will take the data that was entered and pass it back to the form so > > that the user will not have to input the data again. If an error is > > found I use the header function to go back to the form. Im having > > trouble with passing back the data. Do I in my form setup a $_GET or > > should I use the $_SESSION to call it. I am also going to setup a few > > css styles that highlight which field was found in error. > > > > Again, I apologize for my lack of vision and maybe a spark of light will > > go off, and I will be able to make some connections to get this done. > > > > Dan > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php editor?
On Sat, 2003-06-14 at 12:59, electroteque wrote: > boy how painfully dweebish is vi why make it harder for yourself :O Please don't start this again. If you want arguments about editors just read the old ones in the archives. It's highly unlikely that any useful new arguments will be made if we start a new flamewar over it. :) Just suggesting one or two editors you like is more useful. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reverse DNS lookup with PHP
On Sat, 2003-06-14 at 14:38, Tom Ray [Lists] wrote: > $_SERVER[REMOTE_HOST]; > > This will do a reverse lookup on their IP. > > Manual Link: > http://ca3.php.net/manual/en/reserved.variables.php#reserved.variables.server Actually, this isn't true. $_SERVER['REMOTE_HOST'] will contain the hostname of the client if and only if the web server has placed that value there. Simply referring to the variable does not cause a lookup to be done. To do the lookup yourself, use gethostbyaddr(): http://www.php.net/gethostbyaddr Hope this clarifies it a bit, Torben > Hope it helps > > Tim Thorburn wrote: > > > Hi, > > > > I'm setting up a simple tracking program for a website I'm working > > on. Currently it records a visitors IP address, but I would like to > > be able to do a DNS lookup of these IP addresses. Is this possible > > with PHP and if so, how is it done? I've been looking through Google, > > and the very few real results I've come across are large perl programs > > which make little to no sense to me. > > > > Any help would be greatly appreciated. > > > > Thanks > > -Tim -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] is my server working
On Sun, 2003-06-15 at 01:07, Alex Ciurea wrote: > try to use echo instead of print() : > > >>>>>> > echo $myString; > >>>>>> > > or, if u realy want to use the print function, try this: > > >>>>>> > print("$myString", %s); > >>>>>> > > maybe will work > > > Alex Ciurea Greets You > www.netonwave.com I think you might be getting confused with printf(). In that case, the above would be: printf("%s", $myString); In any event, the choice will have no impact here. It simply appears that the original poster has not got PHP installed properly, or else the system is not configured to pass that page of through PHP. http://www.php.net/print http://www.php.net/printf -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Test message
On Sun, 2003-06-15 at 13:28, jb wrote: > Testing news reader Please use a test group for your testing. misc.test is a good bet. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fwd: Re: [PHP] is my server working
On Sun, 2003-06-15 at 19:56, Khoo Merry wrote: > Hei, everyone > My configuration is working now. Thank's for everybody helps. > My apache is able to parse the .php4 extension. > I found that i shouldn't save my .php4 in document format. I have to > use notepad instead of world pad. I dun know why it works in notepad > but not in world pad. Can anyone tell me why? Yes: your scripts need to be in plain text format, and was saving the formatting and other information along with the text--probably in some binary format that only Microsoft fully understands. There might be an option to save to plain text (*.txt) but it's been a couple of years since I've used it and I'm not sure. Torben P.S. Please turn off HTML email when emailing this list. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHPFI? How to build on Win32?
On Sun, 2003-06-15 at 06:44, DvDmanDT wrote: > Hello... Today I downloaded 'phpfi' from CVS and I was wondering how to > build it? It included no dsw/dsp files so I tried cygwin > ./configure > make > cd src > make > > but it doesn't work... Says like no rules or something... Or that it doesn't > know how to build... So, how? > > Thanks in advance // DvDmanDT phpfi? Are you sure you want to be building a version of PHP that's been obsolete for half a decade? If you're sure you know what you're doing and my snide comment hasn't already put you off, the README indicates that you should be able to do it with cygwin (although I don't know what might have changed between the time that was written in 1998 and now). Give that a read--might have something you can use. Other than that, all I can say is that PHP/FI was never really recommended for use on Win32 except as kind of an experiment. Unless you need to do it for a very good reason, I'd say stick with PHP 4. :) Cheers, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php editor?
On Sun, 2003-06-15 at 22:34, M-Ali Mahmoodi wrote: > if no newer editors? > so the old messages suggest the older! I wasn't suggesting that people not suggest new editors. People just don't need to argue about it (at least, not on the list). Cheers, Torben > "Lars Torben Wilson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Sat, 2003-06-14 at 12:59, electroteque wrote: > > > boy how painfully dweebish is vi why make it harder for yourself :O > > > > Please don't start this again. If you want arguments about editors just > > read the old ones in the archives. It's highly unlikely that any useful > > new arguments will be made if we start a new flamewar over it. :) Just > > suggesting one or two editors you like is more useful. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need config file parsing code.
wErrors(); ?> > when the script is finished I'll post it up for anyone to use on their > own servers... > > by the way, does anyone know why "arp -n" (what i'm using) shows > machines that are NOT even turned on? like my notebook shows up despite > having been off for several hours? Is there a way to get a real time > list of the machines on my network? I thought that's what arp did, but > apparently not. :( > > d IIRC it's because arp deals with the kernel cache, not necessarily the live data. Wouldn't bet my life on it though. Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace() problems actually *_replace() problems to bemore accurate
On Mon, 2003-06-16 at 11:49, Thomas Bolioli wrote: > I am a perl/java/c++ programmer who is doing something in php and have > run accross something I am stumped with. I am trying to replace carriage > returns with or tags (p's in groups of two and br's for any > unmatched cr's). I have tried all of the *_replace() functions including > string_*, ereg_* and preg_*. None have worked the way they seem to > should. Note, I am a perl programmer and preg_replace() did not work > while a test perl script did. I have tried multiple forms of patterns > from "\r\n" to "\n" to "\r" to "/\r?\n/ei" (in the *reg_* functions). I > even took code verbatim from examples in the docs to no avail. I have > included the entire block of code (and mysql_dump output) since there is > something I have apparently not done right and it may not be in the > pattern matches. > Thanks in advance, > Tom Hi Tom, There's only one thing you didn't try...see below: > *The offending code:* > > }elseif($_REQUEST['add']){ > $desc = $_REQUEST['description']; > str_replace("\r\n\r\n", "", $desc); > str_replace("\r\n", "", $desc); You need to assign the result of the replacement to something before you can use it; arguments are not modified in place. So something like this: $desc = str_replace("\r\n\r\n", "", $desc); $desc = str_replace("\r\n", "", $desc); This change shouild be all you need. However, if you want to be able to accept input from other than windows users, you can do the whole thing with strtr(). I haven't tested with preg_replace(), but I suspect that using regexps for this would be overkill. $trans = array("\n\n" => '', "\n" => '', "\r\r" => '', "\r" => '', "\r\n\r\n" => '', "\r\n" => ''); $desc = strtr($desc, $trans); Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to avoid Socket Post output?
On Mon, 2003-06-16 at 13:46, Kevin Stone wrote: > Hello list, > > I'm attempting to use the PostToHost() function to send a request to a > remote script. The purpose for this is to request and retrieve information > from a remote database without the need for messy HTTP & HTML methods. I > realize that I could use an HTML form, put the data in hidden fields, and > send the request that way, but then I would have to redirect back from the > master script recording an unwanted page in the 'Back Button' history. I'd > like to avoid that so I'm investigating methods of POST'ing through a manual > socket connection. > > Here is that PostToHost() function.. > > /* > PostToHost($host, $path, $data_to_send) > $host; valid domain (ie. www.domain.com) > $path; relative URL (ie. /myfile.php) > $data_to_send; urlencoded key/val string (ie. > "key=val&key2=val2&key3=val3") > */ > function PostToHost($host, $path, $data_to_send) > { Add here: $ret_string = ''; > ob_end_flush(); > $fp = fsockopen($host,80); > fputs($fp, "POST $path HTTP/1.0\n"); > fputs($fp, "Host: $host\n"); > fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); > fputs($fp, "Content-length: " . strlen($data_to_send) . "\n"); > fputs($fp, "Connection: close\n\n"); > fputs($fp, $data_to_send); > while(!feof($fp)) > { > echo fgets($fp, 128); Replace the echo line above with: $ret_string .= fgets($fp, 2048) . "\n"; > } > fclose($fp); Add here: return $ret_string; > } > > > It works great! The only problem is I get output from the socket connection > and I don't know how to skip over it... > > HTTP/1.1 200 OK > Date: Mon, 16 Jun 2003 20:10:36 GMT > Server: Apache/1.3.20 (Unix) ApacheJServ/1.1.2 PHP/4.2.3 > FrontPage/5.0.2.2510 Rewrit/1.1a > X-Powered-By: PHP/4.2.3 > Connection: close > Content-Type: text/html > > I'm very much a newbie to all of this so you'll have to forgive me. But I'm > wondering if there is anyway to avoid this output and have a completely > invisible manual socket POST? I'm assuming with the above that you want to get the returned text from the POST into a string for use instead of outputting it directly to the browser; these changes should do that. Note: I haven't actually tested it. :) Good luck, Torben > Thanks, > Kevin Stone > [EMAIL PROTECTED] -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I delete a mySQL table?
On Mon, 2003-06-16 at 14:22, zavaboy wrote: > How do I delete a mySQL table? (Just what's in the subject) Well, this is a MySQL question, not a PHP question, but in PHP you would do it like this: mysql_query("DROP TABLE $table_name", $dbh); Just make sure that the user PHP is running as has permission to drop tables. The MySQL manual page for DROP TABLE: http://www.mysql.com/doc/en/DROP_TABLE.html Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] need config file parsing code.
On Mon, 2003-06-16 at 15:23, Daevid Vincent wrote: > Off the top of your head huh? Damn... That's some code you churned out > there. Just glanced through it, but I'm impressed you took that much time! > Thanks! I'll clean it up and give it a go. > > d Well, I had just finished writing the core of the code for a similar thing a few days before, so I just fixed it up for your file format. If you have any questions fire away. You should be able to just cut the class into its own file, include_once(), and call the class on your file. I left in some of the debug output (commented out) to give some insight into what's going on inside if you want it. Cheers, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String containing PHP Code
On Mon, 2003-06-16 at 16:45, Suhas Pharkute wrote: > Hello, > > I have a php script which generates a string which has php code in it. I need to > run that code. > > For example: > > > $str = " "; > ?> > > > Is there any way that we can do it? I know I can do it by writing it to file but > then it is no more secured. > > Please let me know, > > Thanks > Suhas You want eval(). It should all be explained here: http://www.php.net/eval Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] functions, opinion...
On Mon, 2003-06-16 at 23:20, Jason Wong wrote: > On Tuesday 17 June 2003 12:50, DvDmanDT wrote: > > I was replying to "If you don't do it this way, you'll > > find yourself re-writing a function sooner or later because you need it > > to return the data instead of displaying it."... Then you don't need to > > modify the function if you turn on ob, call function, then get contents, > > then clear ob... Ok, it's a rather bad way to do it, but it works for me... > > Even the php crew had to rewrite functions because it displayed data instead > of returning. Case in point: print_r() recently had a extra argument added to > specify whether the output was printed or returned. I agree with your point, but the adding of the second argument was more of a convenience thing than an admission that printing when calling a print statement was bad behaviour. :) Besides, it's more consistent since the introduction of var_export() with its similar abilities. As to your actual point (no more hair splitting): I agree. If the function has something to say, it's better to store that somehow and then use it when you need it. You get to determine when (and if) it gets output, and how. As someone else noted, you will sometimes find it necessary to break this rule (quick debugging statements, or functions whose purpose is to actually output something), but in general I wouldn't expect to see any benefit to having your functions doing their own output--beyond the initial convenience. For one thing, it can make effective use of templates a bloody pain. Just some thoughts, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email Valadation
On Tue, 2003-06-17 at 02:42, Philip J. Newman wrote: > How would i valadate an email string to see if it has invalid charactors? > > / Philip Read RFC 822 and grok it thoroughly. Then decide exactly how lax you can afford to be in your checking, or find a checker to download-- because unless you crave the challenge it's probably easier to either do a really simple check, or just download a checker. It's a much harder question than it sounds like. For a couple of perl examples of how it can be done, check here: http://examples.oreilly.com/regex/readme.html I would suggest checking on ps.sklar.com, Zend.com, phpclasses.org, etc for some rfc822 checkers. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email Valadation
On Tue, 2003-06-17 at 02:54, Lars Torben Wilson wrote: [snip] > I would suggest checking on ps.sklar.com, Zend.com, phpclasses.org, etc > for some rfc822 checkers. I meant 'px.sklar.com', of course. :/ Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Password generator
On Tue, 2003-06-17 at 02:45, Davy Obdam wrote: > Hi people, > > I have to make a password generator, but i have a little problem. > > - It needs to generate password 8 characters long, and including 1 or 2 > special characters(like #$%&*@). > - Those special characters can never appear as the first or last > character in the string... anywhere between is fine. > > I have a password generator script now that does the first thing... but > the special character can be in front or back of the string wich it > shouldnt.. i have been looking on the web for this but i havent found > the answer. Below is my scripts so far.. > > Any help is appreciated, thanks for your time, > > Best regards, > > Davy Obdam Please don't crosspost. Pick the suitable list (in this case, it would have been php-general). Anyway, just tell it not to use anything beyone the first 26 characters of your allowable characters string. Below is one way to do it. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] error with null $HTTP_GET_VARS['field']
On Tue, 2003-06-17 at 11:55, Logan McKinley wrote: > right now if a the 'field' key does not exist at all in the querystring it > returns the following error: > Notice: Undefined index: Register in c:\inetpub\wwwroot\PHP\Register.php on > line 3 > I think i can use the empty function but i pass in 11 different variables > and it seems like there must be a more eligant way to prevent the error then > with 11 individual if statements. Is there a way in which it will return a > value even if the key does not exist in the querystring. > Thanks in advance, > ~Logan What you are seeing is the correct behaviour: since the variable has not been initialized, attempting to access it without checking it is not good. Usually it's not much of an issue in PHP, though. Anyway, one of the better ways to deal with it is to loop over your input arrays and checking the values, something like this: You could also just turn down error_reporting to skip the NOTICE-level errors, but that's only really recommendable on a production box (where you should probably have display_errors off too)...but on a development server, hiding the problem is not likely to help in the long run. :) Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] bcmod()
On Tue, 2003-06-17 at 11:42, Thomas Bolioli wrote: > The docs (see below) for bcmod() are rather skimpy. Does anyone have a > clue as to how it works. Basically I want to do this (below code). PS: I > am new to PHP but not to programming in general. > Tom Unless you're using arbitrary-precision math, the overhead of using bcmod() is probably not worth it. In general you would just use the modulus operator '%': http://www.php.net/manual/en/language.operators.arithmetic.php bcmod(a, b) is the arbitrary-precision version of a % b; At any rate, what is the code doing that you're not expecting? Torben > $i = 1; > while (something true){ > $modulus = the_modulus_of($i / 4); // does php do % instead of /? > if($modulus == 0){ > do_this_this_time(); > } > $i++; > } > > *bcmod* > > (PHP 3, PHP 4 ) > bcmod -- Get modulus of an arbitrary precision number > Description > string bcmod ( string left_operand, string modulus) > > Get the modulus of the left_operand using modulus. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: refreshing fopen
On Tue, 2003-06-17 at 14:10, Bryan Koschmann - GKT wrote: > On Tue, 17 Jun 2003, Terje Torkelsen wrote: > > > > > PHP is server-side language, so this would be possible. Would go for meta tag > > or a javascript. > > > I know, but I thought I saw somewhere there was a way to do this using > flush() and something else, maybe for use with a progress bar type thing? > > I know http is not an always open type protocol, but I still thought there > was a way. Meta refresh just won't work correctly.. > > Thanks, I think you're talking about server push. In general you can only use this with Netscape and Mozilla, but the page I link to below intimates that you might be able to tie in with some Java or somesuch to make IE do it too. Myself, I've never tried it, so YMMV. Anyway, do some googling on 'server push' and check this out for a ready-made script: http://web.they.org/software/php-push.html Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ini_set with mutiple include directories
On Tue, 2003-06-17 at 12:08, Mike Morton wrote: > I have an application that I set the include directory using the ini_set > (the application assumes that the client does not have access to the php.ini > files). > > I can set the first include path of course: > ini_set("include_path","/Library/WebServer/Documents/includes"); > > But how do I set additional paths like in the ini file? If I try to do > another ini set, then it replaces the initial one, and I cannot seem to find > any way to set more than one path in the initial ini_set above > > Does anyone know how this can be done? Thanks :) Separate the paths with semicolons or colons depending on your OS. You can also check existing values using ini_get() and modify based on that. I like to use something like the following: Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Connection
On Tue, 2003-06-17 at 17:13, [EMAIL PROTECTED] wrote: > Hello, > > Would be grateful if someone couldkindly point me in the right direction. Check the MySQL documentation. You also might want to ask on the MySQL mailing list. http://www.mysql.com/doc/en/Default_privileges.html http://www.mysql.com/doc/en/Access_denied.html It appears, however, that mysqld is not recognizing the authority of whoever you're connected as to modify the grant tables. Try connecting as the admin user. Good luck, Torben > Whenever I try to connect to mysql server, I get these messsage back > > 1. > mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana"; > ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO) > mysql> > > 2. > mysql> GRANT ALL PRIVILEGES ON *.* TO moses@"%" IDENTIFIED BY "cludiana"; > ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO) > mysql> > > what could be wrong. Help please . > > Regards > > Moses -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Connection
On Tue, 2003-06-17 at 18:19, [EMAIL PROTECTED] wrote: > Hello, This seems not to be working, I am using win2000 and a newbie. please > simplify this process. > > ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO) > mysql> GRANT ALL PRIVILEGES ON *.* TO [EMAIL PROTECTED] > -> IDENTIFIED BY 'cludiana' WITH GRANT OPTION; > ERROR 1045: Access denied for user: '@127.0.0.1' (Using password: NO) > mysql> > > Regards You've read the MySQL documentation, right? If not, do so. Trust me. You'll need it. Right now it looks like you need this section: http://www.mysql.com/doc/en/General_security.html Also, I was serious when I suggested asking on the MySQL mailing list. This list is for PHP. Finally, when you do ask, be sure to provide some more information. You need to tell them what you've done so far, where on the network the database server is, and your username when logged in. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Help with my code
On Wed, 2003-06-18 at 08:23, Terje Torkelsen wrote: > To echo multiple lines you have to write > > echo << > > > > > > ... > .. > > END; No offense, but this is completely false. Double-quotes will work just fine. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] print all variables
On Wed, 2003-06-18 at 08:51, Matt Palermo wrote: > Could anyone tell me how to print all the variables and values from a submitted > form, so that I can check them? > > Thanks, > > Matt print_r($_REQUEST); ...or, depending on the method your form is using, one of: print_r($_POST); // or print_r($_GET); This information, for the record, is readily available in the manual. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mySQL: Rows and columns
On Wed, 2003-06-18 at 10:03, zavaboy wrote: > I know this is more of a mySQL question but, how do I delete and add rows > and columns? > > -- > > - Zavaboy > [EMAIL PROTECTED] > www.zavaboy.com Using the mysql_*() function and the SQL language. The mysql_*() functions are documented here: http://www.php.net/mysql You can find a PHP/SQL tutorial here: http://phpdev.gold.ac.uk/tutorial/sql/ There are likely a bunch more on Google. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need someone with a fresh mind on tacking this arrayproblem...
On Wed, 2003-06-18 at 10:32, Scott Fletcher wrote: [snip] > if ($ArrayCheck == 0) { > $ArrayDataCount['$ODBC_RESULT'] = "0"; What happens when you remove the single-quotes? You're currently defining only one array value, with the key being the literal string '$ODBC_RESULT'--when you probably want to be using the contents of $ODBC_RESULT. I haven't tested it, but it's the first thing I see. Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions?
On Wed, 2003-06-18 at 11:06, Lee Elenbaas wrote: > Hi, > > I have failed to find the information I am looking for on session management > by PHP do they use cookies? Is there a way to use URL rewriting? How do I > find the timeout time? is there a way to close a session manually? > It seem to me like all those questions got to have answers for them > somewhere, I just look in the wrong place > Help is appreciated :-) > > lee All of this information is in the manual: http://www.php.net/session Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need someone with a fresh mind on tacking thisarrayproblem...
On Wed, 2003-06-18 at 11:11, Scott Fletcher wrote: > Well, the PHP Manual said we should be using the quote (single or double) > inside the array no matter what, it also reduce the side-effect problem. > It's what I read at php.net in the past. That's referring to string literals, but that might not be all that obvious. I've been fixing the array type page today, so I'll take a look at the wording on this. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Need someone with a fresh mind on tacking thisarrayproblem...
On Wed, 2003-06-18 at 11:45, Scott Fletcher wrote: > Bingo!! I did some PHP re-arrangement and I also do what you were saying > about taking out the quote. It doesn't work with the quote inside and it > work without the quote. What so interesting is that the year is actually a > string so I figured that putting it in a sting will work, but I guess not... > > Thanks, > Scott Glad to hear it works! The reason the variable was not being interpreted is that it was single-quoted, not double-quoted; variables are only interpolated inside double-quoted strings (and heredocs, but that's another story). You could also have replaced the single-quotes with double quotes, but it would be pointless and isn't recommended. For more information, check out: http://www.php.net/manual/en/language.types.string.php And: http://www.php.net/manual/en/language.types.array.php I have just done some fairly hefty work on this last page; however, it won't appear online until the next time the manual is generated. Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Agh! Driving me crazy!
On Wed, 2003-06-18 at 12:56, Michael Sweeney wrote: > Also, you might have problems with the array reference $place[1] not > expanding from within the string - you might need to concatenate the > string around it: > > ...'$cases', '". $place[1] ."', '$iice'... > > ..michael.. No, his syntax with that part is fine. For more information on how variables work in PHP strings: http://www.php.net/manual/en/language.types.string.php -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Difference between $_POST[foo] and $_POST['foo']?
On Tue, 2003-06-17 at 07:47, Chris Hayes wrote: > At 16:37 17-6-03, you wrote: > >On Tue, 2003-06-17 at 09:09, nabil wrote: > > > A side question along with this ,,, how can I include > > $_POST['foo'] in the > > > : > > > $sql ="select * from db where apple = '$_POST['foo']' "; > > > > > > without getting an error ?? > > > should I append it as $var= $_POST['foo']; before??? > > > > > > >The rule of thumb I follow with these and other Associative Arrays is: > > > >when setting the variable its $_POST['foo'] > >when accessing the variable its $_POST[foo] > > May i rephrase that to: > > "Use quotes whenever possible, with one exception: within double quotes." > > Reason: your rule of thumb fails with: > $val=$_POST['val']; > > Plus: when using CONSTANTs as keys, do not try to access them within quoted > strings. You've gotten the closest so far. :) o Use quotes when the key is a string literal, and one of the following is true: A) the array reference is not inside a string or heredoc; or B) the array reference _is_ within a string or heredoc, but is written using complex syntax (see below). o If the key is an integer, you do not need quotes, but you may use them if you wish. o If the key is a constant, do not use quotes. o If the key is a variable, single-quotes will prevent PHP from interpreting the variable, and the result will not be what you want. Use no quotes around variable keys (or double-quotes, but that's pointless). o If the key is some other kind of expression (function call, math operation, etc) do not use quotes. o Inside a double-quoted string or heredoc, you can opt to leave out the quotes if you're using a string literal key. o In general within strings and heredocs, you may want to adopt the practice of always using the complex syntax to express array references: $str = "This is a string {$array['user_name']}"; (Complex syntax isn't complex; just wrap the array reference between a { and a }). Note that in this case, you again need the quotes. Always using the complex syntax for array (and object) referencing within strings will help prevent odd errors with the arrays not being interpreted correctly, and indeed, if you want to go any further than one level deep into an array or object within a string, you must use the complex syntax. I've spent some time this morning cleaning up the Array type page, so hopefully some of this will be a bit clearer (at least, after the docs get generated). There is also definitive information on the string variable interpolation topic here: http://www.php.net/manual/en/language.types.string.php Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] picture help
On Wed, 2003-06-18 at 13:39, Edward Peloke wrote: > Hello all, I have this code that takes an image sent from a form and resizes > it for a thumbnail and for display, the problem is the pictures look nice > until this does the resizing, then the quality is horrible...can I fix it? > > Thanks, > Eddie If you have GD version 2.0.1 or later and PHP 4.0.6 or later, try using imagecopyresampled() instead of imagecopyresized(). You may get better results. Good luck, Torben > if(!empty($myimage)){ > $id=$HTTP_GET_VARS['id']; > $imgname="image_".$id.".jpg"; > copy($myimage,$imgname); > unlink($myimage); > function thumbnail($i,$nw,$p,$nn) { > $img=imagecreatefromjpeg("$i"); > $ow=imagesx($img); > $oh=imagesy($img); > $scale=$nw/$ow; > $nh=ceil($oh*$scale); > $newimg=imagecreate($nw,$nh); > imagecopyresized($newimg,$img,0,0,0,0,$nw,$nh,$ow,$oh); > imagejpeg($newimg, $nn); > return true; > } > > #thumbnail(filetouse,newwidth,newpath,newname); > thumbnail($imgname,100,"/imges/","t_".$imgname); > thumbnail($imgname,250,"/imges/",$imgname); > > } > ?> -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] .htaccess files
On Wed, 2003-06-18 at 15:34, Steve Marquez wrote: > Hello everyone, > > Could someone point me in the direction of some info on .htaccess files? > Could someone send me one, tell me where to put it in my > server? I hope this is not a stupid question. I am running Apache on a Mac > with Jaguar OSX. > > Thanks for your help, > > -Steve Marquez [EMAIL PROTECTED] Your Apache manual contains all which you wish to know. If you're not sure where it got installed, hit http://www.apache.org and check it out there; the documentation is at: http://httpd.apache.org/docs-project/ Good luck, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] User's Screen Resolution Size
On Wed, 2003-06-18 at 21:13, Leif K-Brooks wrote: > You're using PHP, but not everything you do has to do with PHP! You may > use PHP, but that doesn't mean you post to the PHP list about home > decorating! I have no idea where you folks have gotten the idea that asking how to get Javascript to interact with PHP would be particularly off-topic here. Were it the vile transgression this thread has made it out to be, we probably wouldn't have included the answer in the FAQ. It wouldn't be all that off-topic on a Javascript list either, but you'd still have a bunch of guys jumping up and yelling 'Ask on a PHP list, you loser', without actually providing any useful information. At worst, give a simple link or direction to a more appropriate resource. Courtesty does go a long way. You can as easily direct a guy to the appropriate resource without strutting up and down like some unsolicited mailing list Rent-A-Cop. This list is about helping people learn to use PHP. Please use it as such. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] User's Screen Resolution Size
On Wed, 2003-06-18 at 21:42, Leif K-Brooks wrote: > Lars Torben Wilson wrote: > > >I have no idea where you folks have gotten the idea that asking how to > >get Javascript to interact with PHP would be particularly off-topic > >here. Were it the vile transgression this thread has made it out to be, > >we probably wouldn't have included the answer in the FAQ. > > > That's not the problem, that is on topic. The problem is asking how to > get the resolution from JS. Find that out first, then ask how to get > that value into PHP here. My reply is off-list. > >It wouldn't be all that off-topic on a Javascript list either, but > >you'd still have a bunch of guys jumping up and yelling 'Ask on a PHP > >list, you loser', without actually providing any useful information. At > >worst, give a simple link or direction to a more appropriate resource. > > > If you did what I said above, what you posted on either list wouldn't be OT. > > >Courtesty does go a long way. You can as easily direct a guy to the > >appropriate resource without strutting up and down like some > >unsolicited mailing list Rent-A-Cop. > > > Then don't act like an unsolicited mailing list OTer. > > >This list is about helping people learn to use PHP. Please use it as > >such. > > > That's exactly what I'm asking you to do. > > -- > The above message is encrypted with double rot13 encoding. Any unauthorized attempt > to decrypt it will be prosecuted to the full extent of the law. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms addslashes ?
On Thu, 2003-06-19 at 05:27, Mukta Telang wrote: > Hi, > I want to add slashes to a string, if it contains quotation marks and > which is received as input from a form, so that I can enter it to a > database. > What I am doing is as follows: > > echo "; > $title=addslashes($title); > > But the string that gets added has a lot of slashes! > How should this be done? > Mukta Do you mean that there are two slashes everywhere there should be one, or that they are inserted where you do not expect them? It's slashes doubling up on you, you may have magic_quotes_gpc enabled in php.ini. magic_quotes_gpc is explained here: http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc You can check whether it's turned on with: http://www.php.net/get_magic_quotes_gpc http://www.php.net/get_magic_quotes_runtime So if that's the case, you could either disable magic_quotes in php.ini, or else test whether it's turned on and then decide whether to call addslashes(). Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [Newman] Passing an image through a php file.
On Thu, 2003-06-19 at 20:19, Mark Tehara wrote: > > $myimage="..//..//site//images//2.jpg"; > > header("Content-type: image/jpeg"); > fopen ("$myimage", "r"); > readfile("$myimage") ; > fclose("$myimage"); > > ?> > > This seemed to do the trick for me. Thank you. > > / Mark Even better, you don't even need the fopen() and fclose() calls; readfile() is doing this with just the filename. http://www.php.net/readfile -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [Newman] Passing an image through a php file.
On Fri, 2003-06-20 at 12:07, Mark Tehara wrote: > Ahh, the Docs don't tell you that. > > They are a little weard wehen it comes to that How so? int readfile ( string filename [, bool use_include_path [, resource context]]) It does say 'filename', not 'resource'. Seems pretty unequivocal. However, if there is something wrong with the presentation or if you have suggestions for improvements, I can take a look at it for you. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Chomp, Chomp, Chomp
On Fri, 2003-06-20 at 15:37, Sparky Kopetzky wrote: > Does anyone have a piece of code that emulates a Perl 'Chomp' function? I need one. > > Thanks in advance!! > > Robin E. Kopetzky > Black Mesa Computers/Internet Services > www.blackmesa-isp.net This should do it for you: http://www.php.net/rtrim Good luck! Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Chomp, Chomp, Chomp
On Fri, 2003-06-20 at 15:47, Sparky Kopetzky wrote: > I looked at the documentation on rtrim. It trims ALL whitespace characters > from the end, not just the '\n'. I need only the '\n' trimmed. Look again, but check out the second argument: Good luck, Torben > Sparky > - Original Message - > From: "Lars Torben Wilson" <[EMAIL PROTECTED]> > To: "Sparky Kopetzky" <[EMAIL PROTECTED]> > Cc: "PHP General" <[EMAIL PROTECTED]> > Sent: Friday, June 20, 2003 16:47 > Subject: Re: [PHP] Chomp, Chomp, Chomp > > > > On Fri, 2003-06-20 at 15:37, Sparky Kopetzky wrote: > > > Does anyone have a piece of code that emulates a Perl 'Chomp' function? > I need one. > > > > > > Thanks in advance!! > > > > > > Robin E. Kopetzky > > > Black Mesa Computers/Internet Services > > > www.blackmesa-isp.net > > > > This should do it for you: http://www.php.net/rtrim > > > > > > Good luck! > > > > > > Torben > > > > > > -- > > Torben Wilson <[EMAIL PROTECTED]> +1.604.709.0506 > > http://www.thebuttlesschaps.com http://www.inflatableeye.com > > http://www.hybrid17.com http://www.themainonmain.com > > - Boycott Starbucks! http://www.haidabuckscafe.com - > > > > > > -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Chomp, Chomp, Chomp
On Fri, 2003-06-20 at 16:16, Aaron Axelsen wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > The php chop function is suppose to act like the perl chomp. No, chop() is an alias for rtrim(), and is identical in every way (save for its name, of course...) http://www.php.net/chop Cheers, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Not incrementing?
On Fri, 2003-06-20 at 17:07, Kyle Babich wrote: > I have a file, current.txt, that at the start has only the digit 1 in it. Here is > my code: Hi there, > $current = readfile('setupData/current.txt'); This will cause $current to contain the number of bytes read from the file, not the contents of the file. http://www.php.net/readfile Instead, use fopen()/fread(); or file()/implode(); or if you have PHP 4.3.x or newer, use file_get_contents(). http://www.php.net/file_get_contents http://www.php.net/fopen http://www.php.net/fread http://www.php.net/file http://www.php.net/implode > foreach ($HTTP_POST_VARS as $index => $value) { > $index = $HTTP_POST_VARS['$index']; > } This will do two things you probably don't want: first, it will repeatedly assign values to $index, overwriting it on each iteration; and, it will always use the same value to do so, since $HTTP_POST_VARS['$index'] has the single-quotes, which prevents PHP from interpreting the contents of $index--so it's literally using the string value '$index' instead of the value of the $index variable. You probably want variable variables: $$index = $HTTP_POST_VARS[$index]; ...although even easier would be: $$index = $value; http://www.php.net/manual/en/language.variables.variable.php [snip] > Thanks, > -- > Kyle Hope this helps, Torben -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] securing a graphic
On Sat, 2003-06-21 at 00:51, Justin French wrote: > I'm with Steve on this. Call them (the numerous "hacks" mentioned in this > thread) deterrents if you like, but there is NO WAY to secure images. > > You can brand them with a big watermark, and make sure your copyright and > terms of use notice are prominent on the page, but the nature of the web is > that they ALREADY HAVE downloaded a copy. > > Justin Yup. If my computer can display it, I can save it. -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: FW: [PHP] How do I get the exit code of an external program?
On Sun, 2003-06-22 at 20:19, Daevid Vincent wrote: [snip] > http://us3.php.net/manual/en/function.exec.php > string exec ( string command [, array output [, int return_var]]) > exec() executes the given command, however it does not output anything. It > simply returns the last line from the result of the command. > > However, you are correct in that there is the optional parameter that I've > never used before. Thanks for pointing that out... > > http://us3.php.net/manual/en/function.system.php > string system ( string command [, int return_var]) > system() is just like the C version of the function in that it executes the > given command and outputs the result. If a variable is provided as the > second argument, then the return status code of the executed command will be > written to this variable. > > The problem is that system want's to dump the output to the screen!!! I need > a command that will allow me to execute/system the command "silently" and > then *I* can do something based upon the exit code... No offense, but why not just use exec() and its third argument, as suggested and as you yourself noted? It does, in fact, do what you are asking for. You are quite correct that system() is not the function you want. Just wondering. :) Torben > function active_nMap() > { > $test = exec("/usr/bin/nmap -sP ".$this->IP); > if ( strstr($test,"1 host up") ) > $this->active = true; > else > $this->active = false; > > return $this->active; > } > > function active_ping() > { > $test = `ping -n -c 1 -w 1 -q $this->IP`; > if ( strstr($test,"100% loss") ) > $this->active = false; > else > $this->active = true; > > return $this->active; > } > > > function active_ping_exit() > { > //http://us3.php.net/manual/en/function.system.php > $test = system("ping -n -c 1 -w 1 -q $this->IP", $code); > if ( $code == 0 ) > $this->active = true; > else > $this->active = false; > > return $this->active; > } > > -- Torben Wilson <[EMAIL PROTECTED]>+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php