php-general Digest 26 May 2002 20:04:59 -0000 Issue 1368
Topics (messages 99286 through 99317): PHP and JavaScript 99286 by: mp 99287 by: SP 99293 by: Vincent Kruger Re: please help!! 99288 by: Olexandr Vynnychenko Re: Need some advice concerning forms (multi select pulldown) and arrays 99289 by: Victor Spång Arthursson 99294 by: John Holmes 99296 by: Victor Spång Arthursson 99301 by: Victor Spång Arthursson 99303 by: Miguel Cruz Re: inspirational 99290 by: Michael Virnstein 99291 by: Michael Virnstein 99292 by: Michael Virnstein 99295 by: John Holmes arrays 99297 by: Michael Hall 99299 by: Michael Virnstein 99307 by: Philip Olson E-mail via WAP 99298 by: Rosen Re: NewBie-UPLOADING IMAGE 99300 by: Evan Re: Extract ZIP archives 99302 by: Analysis & Solutions Re: 4.2.1 Vars 99304 by: Philip Olson regex help 99305 by: Jeff Field 99306 by: Miguel Cruz Parsing PHP output 99308 by: Mark 99309 by: Ray Hunter ini_set('register_globals',0) doesn't work 99310 by: Jens Lehmann Calendar 99311 by: jtjohnston 99312 by: jtjohnston 99313 by: jtjohnston 99314 by: jtjohnston Simulating a FORM POST thing (HELP!) 99315 by: Georgie Casey 99316 by: Peter 99317 by: Georgie Casey Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] ----------------------------------------------------------------------
--- Begin Message ---Hi, php-general, I make this kind of PHP script(script.php): script.php <? $variable = "Some some long long Text Blah blah"; echo "document.write(\"".$variable."\")"; ?> And in HTML (other.html) file I write: <script language="JavaScript" src="script.php"></script> But there is some mistake. Does anybody can help me? Thanks...--- End Message ---
--- Begin Message ---It worked for me, what error are you getting? In the other.html, did you have this? <html> <head> <title></title> <script language="JavaScript" src="script.php"></script> </head> <body> </body> </html> -----Original Message----- From: mp [mailto:[EMAIL PROTECTED]] Sent: May 26, 2002 3:05 AM To: [EMAIL PROTECTED] Subject: [PHP] PHP and JavaScript Hi, php-general, I make this kind of PHP script(script.php): script.php <? $variable = "Some some long long Text Blah blah"; echo "document.write(\"".$variable."\")"; ?> And in HTML (other.html) file I write: <script language="JavaScript" src="script.php"></script> But there is some mistake. Does anybody can help me? Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php--- End Message ---
--- Begin Message ---You need to define the type of file you are creating. Like when you create wml pages with php. Header("Content-Type: text/javascript"); or summing to that effect. have a look at www.weberdev.com "Mp" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, php-general, > > I make this kind of PHP script(script.php): > script.php > <? > $variable = "Some some long long Text Blah blah"; > echo "document.write(\"".$variable."\")"; > ?> > > And in HTML (other.html) file I write: > <script language="JavaScript" src="script.php"></script> > > But there is some mistake. Does anybody can help me? > Thanks... >--- End Message ---
--- Begin Message ---Hello Jolly, Sunday, May 26, 2002, 10:58:45 AM, you wrote: JN> Olexandr, JN> <?PHP JN> /* I can get the values from these */ JN> foreach ($HTTP_POST_VARS as $var => $value) { JN> echo "$var = $value<br>\n"; JN> } JN> /**************************/ JN> /*however empty for this sentence*/ JN> echo "equals ".($t1+$t2); JN> /**************************/ JN> echo "<form action='$PHP_SELF' METHOD='POST'>\n"; JN> echo "<input type='text' name='t1'>\n"; JN> echo "<input type='text' name='t2'>\n"; JN> echo "<input type='submit' name='Submit' value='Submit'>\n"; JN> echo "</form></p>\n"; ?>> JN> P.S. I have set "register_globals = On", but still not work JN> The attached files are my config files of php and apache! I looked through your configuration files and didn't notice any serious differences between them and my ones. I have PHP 4.2.1/Apache 2.0.36 on WinXP Pro. My register_globals was off. When I made it On your scipt worked properly. I don't know what the reason. What PHP you have? I attached my php.ini. Maybe you can find some important things. Another one question: does $PHP_SELF give proper value? It must not be set if register_globals=off. So if $PHP_SELF is set to some value, then global variables are registered. And the last question: why do you use global variables? It's much easier to use superglobal arrays $_POST, $_SERVER, etc. They guarantee that any values passed to your script won't be mixed. -- Best regards, Olexandr mailto:[EMAIL PROTECTED]--- End Message ---
php.ini.zip
Description: Zip compressed data
--- Begin Message ---Hello and thanks for your fast answer! I'ld like to know if there is any possibility to distinguish the selects if I've multiple multiple selects, that is, more than one on the same page? What I'm loooking for is the possibility to have an unknown number of multiple selects on the same page.... Is it possible? Anyone who can describe how to do this or provide a link to some tutorial? And also, where in the manual can I read about this? Sincerely, Victor On lördag, maj 25, 2002, at 08:59 , Miguel Cruz wrote: > Have a play with this little program - it should demonstrate all of the > things you'd want to do with getting data in and out of mult selects. If > it doesn't work, you may have an older version of PHP - in that case, > change "$_REQUEST" to "$HTTP_POST_VARS" and "$_SERVER['PHP_SELF']" to > "$PHP_SELF". > > --------------- > <? > > $choices = array(1 => 'dog', 2 => 'cat', 3 => 'mouse', 4 => 'frog'); > > if (is_array($_REQUEST['animals'])) > { > print '<p>You chose:</p><ul>'; > foreach ($_REQUEST['animals'] as $animal_id) > print "<li>{$choices[$animal_id]}</li>"; > print '</ul><hr>'; > } > > ?><form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> > <select multiple name="animals[]"><? > > foreach ($choices as $id => $name) > print '<option ' > . (in_array($id, $_REQUEST['animals']) ? 'selected ' : '') > . "value='$id'>$name</option>"; > > ?></select><input type="submit"></form> >--- End Message ---
--- Begin Message ---Just give each select its own name. Or name them all the same followed by an [] and you'll end up with a multi-dimensional array if things go right... <select name='one'> ... <select name='two'> ---John Holmes... > -----Original Message----- > From: Victor Spång Arthursson [mailto:[EMAIL PROTECTED]] > Sent: Sunday, May 26, 2002 5:49 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Need some advice concerning forms (multi select > pulldown) and arrays > > Hello and thanks for your fast answer! > > I'ld like to know if there is any possibility to distinguish the selects > if I've multiple multiple selects, that is, more than one on the same > page? What I'm loooking for is the possibility to have an unknown number > of multiple selects on the same page.... > > Is it possible? Anyone who can describe how to do this or provide a link > to some tutorial? And also, where in the manual can I read about this? > > Sincerely, > > Victor > > On lördag, maj 25, 2002, at 08:59 , Miguel Cruz wrote: > > > Have a play with this little program - it should demonstrate all of the > > things you'd want to do with getting data in and out of mult selects. If > > it doesn't work, you may have an older version of PHP - in that case, > > change "$_REQUEST" to "$HTTP_POST_VARS" and "$_SERVER['PHP_SELF']" to > > "$PHP_SELF". > > > > --------------- > > <? > > > > $choices = array(1 => 'dog', 2 => 'cat', 3 => 'mouse', 4 => 'frog'); > > > > if (is_array($_REQUEST['animals'])) > > { > > print '<p>You chose:</p><ul>'; > > foreach ($_REQUEST['animals'] as $animal_id) > > print "<li>{$choices[$animal_id]}</li>"; > > print '</ul><hr>'; > > } > > > > ?><form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> > > <select multiple name="animals[]"><? > > > > foreach ($choices as $id => $name) > > print '<option ' > > . (in_array($id, $_REQUEST['animals']) ? 'selected ' : '') > > . "value='$id'>$name</option>"; > > > > ?></select><input type="submit"></form> > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php--- End Message ---
--- Begin Message ---On Sunday, May 26, 2002, at 01:14 PM, John Holmes wrote: > Just give each select its own name. Can't do that, don't know from time to time how many there'll be.... And I've to have some case which iterates on the following page... > Or name them all the same followed > by an [] and you'll end up with a multi-dimensional array if things go > right... Sounds better - but I've a lot of items and I'ld like to know which of the arrays that go to which item... Can I just write …name=array[whateverid] and then in some way reveal the whateverid's? Sincerely Victor--- End Message ---
--- Begin Message ---Ok, I can't get this right... Have the following code: <? $choices = array(1 => 'dog', 2 => 'cat', 3 => 'mouse', 4 => 'frog'); if (is_array($_REQUEST['animals'])) { // get the number of selectcases echo "get the number of selectcases: " . count($animals) . "<br>"; // get the number of provided selects from select with name "2" echo "get the number of provided selects from select with name \"2\": " . count($animals[2]) . "<br>"; // test to print some data echo $animals[2][0]. "<br>"; echo $animals[2][1]. "<br>"; echo $animals[2][2]. "<br>"; echo $animals[2][3]. "<br>"; } ?> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <select multiple name="animals[2]"> <option value='1'>dog</option> <option value='2'>cat</option> <option value='3'>mouse</option> <option value='4'>frog</option> </select> <select multiple name="animals[4]"> <option value='1'>dog</option> <option value='2'>cat</option> <option value='3'>mouse</option> <option value='4'>frog</option> </select> <input type="submit"></form> Why does it not work? // get the number of selectcases echo "get the number of selectcases: " . count($animals) . "<br>"; This works great // get the number of provided selects from select with name "2" echo "get the number of provided selects from select with name \"2\": " . count($animals[2]) . "<br>"; But this doesn't... Thankful for any help, /Victor On Sunday, May 26, 2002, at 05:35 PM, John Holmes wrote: > You can supply an "whateverID" for the select if you want to. > > <select name="select[]"> > <option ... > </select> > > <select name="select[]"> > <option ... > </select> > > etc... > > That will give you an array $select[] on the processing page. If the > selects are multi-selects, you'll have a multidimensional array. The > first chosen element in the first select box can be referenced like this > > $select[0][0] > > You can get a count of how many select boxes there are by doing > > count($select); > > You can get a count of how many elements were selected within a select > you can do this: > > count($select[x]); > > Where x is the number of the select box you want to know about. > > Confusing, eh? > > ---John Holmes... > >> -----Original Message----- >> From: Victor Spång Arthursson [mailto:[EMAIL PROTECTED]] >> Sent: Sunday, May 26, 2002 7:44 AM >> To: [EMAIL PROTECTED] >> Subject: Re: [PHP] Need some advice concerning forms (multi select >> pulldown) and arrays >> >> >> On Sunday, May 26, 2002, at 01:14 PM, John Holmes wrote: >> >>> Just give each select its own name. >> >> Can't do that, don't know from time to time how many there'll be.... > And >> I've to have some case which iterates on the following page... >> >>> Or name them all the same followed >>> by an [] and you'll end up with a multi-dimensional array if things > go >>> right... >> >> Sounds better - but I've a lot of items and I'ld like to know which of >> the arrays that go to which item... Can I just write >> …name=array[whateverid] and then in some way reveal the whateverid's? >> >> Sincerely >> >> Victor > >--- End Message ---
--- Begin Message ---On Sun, 26 May 2002, Victor Spång Arthursson wrote: > <select multiple name="animals[2]"> change this to: <select multiple name="animals[2][]"> > <select multiple name="animals[4]"> and this to: <select multiple name="animals[4][]"> because you want animals[2] and animals[4] to be arrays, not scalar values. miguel--- End Message ---
--- Begin Message ---try: $url = preg_replace('/^(http:\/\/)[^\/]+(\/.*)$, '\\1$SERVER_NAME\\2', $SCRIPT_URI); Michael "Jtjohnston" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I want to detect the url my .php lies in. > > This is over kill and BS: > > $myurlvar = "http://".$SERVER_NAME.parse($SCRIPT_NAME); > > How do I get "http://foo.com/dir1/dir2/dir3/". > > There seems to be nothing in phpinfo() that will give me a full url to > play with. > > Flame me if you will, but I browsed TFM and found nothing inspirational. > > Looked at phpinfo() too and got discouraged. > > I need a full url. > > John > >--- End Message ---
--- Begin Message ---typo: $url = preg_replace('/^(http:\/\/)[^\/]+(\/.*)$/', '\\1$SERVER_NAME\\2', $SCRIPT_URI); Michael "Michael Virnstein" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > try: > > $url = preg_replace('/^(http:\/\/)[^\/]+(\/.*)$, '\\1$SERVER_NAME\\2', > $SCRIPT_URI); > > Michael > > "Jtjohnston" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > I want to detect the url my .php lies in. > > > > This is over kill and BS: > > > > $myurlvar = "http://".$SERVER_NAME.parse($SCRIPT_NAME); > > > > How do I get "http://foo.com/dir1/dir2/dir3/". > > > > There seems to be nothing in phpinfo() that will give me a full url to > > play with. > > > > Flame me if you will, but I browsed TFM and found nothing inspirational. > > > > Looked at phpinfo() too and got discouraged. > > > > I need a full url. > > > > John > > > > > >--- End Message ---
--- Begin Message ---but the scriptname itself will be included there. Try this, if you don't want the scriptname to be included.: $url = preg_replace('/^(http:\/\/)[^\/]+((\/[^\/])*\/)([^\/]+)$/', '\\1$SERVER_NAME\\2', $SCRIPT_URI); Haven't tested them, but should work. Michael "Michael Virnstein" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > typo: > > $url = preg_replace('/^(http:\/\/)[^\/]+(\/.*)$/', '\\1$SERVER_NAME\\2', > $SCRIPT_URI); > > Michael > > "Michael Virnstein" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > try: > > > > $url = preg_replace('/^(http:\/\/)[^\/]+(\/.*)$, '\\1$SERVER_NAME\\2', > > $SCRIPT_URI); > > > > Michael > > > > "Jtjohnston" <[EMAIL PROTECTED]> schrieb im Newsbeitrag > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > I want to detect the url my .php lies in. > > > > > > This is over kill and BS: > > > > > > $myurlvar = "http://".$SERVER_NAME.parse($SCRIPT_NAME); > > > > > > How do I get "http://foo.com/dir1/dir2/dir3/". > > > > > > There seems to be nothing in phpinfo() that will give me a full url to > > > play with. > > > > > > Flame me if you will, but I browsed TFM and found nothing inspirational. > > > > > > Looked at phpinfo() too and got discouraged. > > > > > > I need a full url. > > > > > > John > > > > > > > > > > > >--- End Message ---
--- Begin Message ---If you're getting this discouraged over creating a URL, then maybe you should give this stuff up. There's no variable that gives you the full URL of your script, deal with it. What is this parse() function you're using? What does it do? Why is this "over kill and BS"? Try this: $myurlvar = http:// . $SERVER_NAME . dirname($SCRIPT_NAME); ---John Holmes... > -----Original Message----- > From: jtjohnston [mailto:[EMAIL PROTECTED]] > Sent: Sunday, May 26, 2002 1:39 AM > To: [EMAIL PROTECTED] > Subject: [PHP] inspirational > > I want to detect the url my .php lies in. > > This is over kill and BS: > > $myurlvar = "http://".$SERVER_NAME.parse($SCRIPT_NAME); > > How do I get "http://foo.com/dir1/dir2/dir3/". > > There seems to be nothing in phpinfo() that will give me a full url to > play with. > > Flame me if you will, but I browsed TFM and found nothing inspirational. > > Looked at phpinfo() too and got discouraged. > > I need a full url. > > John > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php--- End Message ---
--- Begin Message ---A couple of simple ones here ... the usual references don't appear to give a straightforward answer on these: Can arrays be passed to functions just like a simple variable? Can arrays be passed as values in hidden form fields just like a simple variable? I've been playing around with these and getting inconsistent results. I've been trying things like serialize and urlencode, but still haven't worked out a straightforward 'rule' or policy. Can someone throw some light on this? TIA Michael--- End Message ---
--- Begin Message ---> Can arrays be passed to functions just like a simple variable? yes, no difference. You can pass every variable to a function, you can pass constants or your values directly. You have to use a variable if a function requires passing by reference or if you want to pass by refernce, because only variables can take the value back. > Can arrays be passed as values in hidden form fields just like a > simple variable? yes, but differently. either you serialize the array, send it urlencoded to the page and unserialze it there: //page1.php: <?php $array = array(1,2,3,4,5); $array = urlencode(serialize($array)); ?> <a href="page2.php?array=<?php echo $array; ?>">Page2</a> //or input field: <input type="hidden" name="array" value="<?php echo $array; ?>"> //page2.php <?php $array = unserialize($array); print_r($array); ?> or you can appen urls like this, no serialization or sth needed then both pages: numerical indexed arrays: <a href="page2.php?array[]=1&array[]=2&array[]=3&array[]=4&array[]=5">Page2</a> or <a href="page2.php?array[0]=1&array[1]=2&array[2]=3&array[3]=4&array[4]=5">Page 2</a> string indexed arrays: <a href="page2.php?array[test1]=1&array[test2]=2&array[test3]=3&array[test4]=4& array[test5]=5">Page2</a> or with forms: numerical indexed arrays: <input type="hidden" name="array[]" value="1"> <input type="hidden" name="array[]" value="2"> <input type="hidden" name="array[]" value="3"> <input type="hidden" name="array[]" value="4"> <input type="hidden" name="array[]" value="5"> or <input type="hidden" name="array[0]" value="1"> <input type="hidden" name="array[2]" value="2"> <input type="hidden" name="array[3]" value="3"> <input type="hidden" name="array[4]" value="4"> <input type="hidden" name="array[5]" value="5"> string indexed arrays: <input type="hidden" name="array[test1]" value="1"> <input type="hidden" name="array[test2]" value="2"> <input type="hidden" name="array[test3]" value="3"> <input type="hidden" name="array[test4]" value="4"> <input type="hidden" name="array[test5]" value="5"> Michael "Michael Hall" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > A couple of simple ones here ... the usual references don't appear to give > a straightforward answer on these: > > Can arrays be passed to functions just like a simple variable? > > Can arrays be passed as values in hidden form fields just like a > simple variable? > > I've been playing around with these and getting inconsistent results. > I've been trying things like serialize and urlencode, but still haven't > worked out a straightforward 'rule' or policy. > > Can someone throw some light on this? > > TIA > Michael >--- End Message ---
--- Begin Message ---> Can arrays be passed to functions just like a simple variable? Yes. > Can arrays be passed as values in hidden form fields just like a > simple variable? Yes, with a little work. > I've been playing around with these and getting inconsistent > results. I've been trying things like serialize and urlencode, > but still haven't worked out a straightforward 'rule' or policy. For example: $arr = array('color' => 'red', 'fruit' => 'apple'); $str_arr = urlencode(serialize($arr)); <input type="hidden" name="foo" value="<?php echo $str_arr ?>"> And in the action script, do: $arr = unserialize(stripslashes($_REQUEST['foo'])); Notes: a) stripslashes may be needed, in case magical quotes get in the way (magic_quotes_gpc). b) am using $_REQUEST, you may use $_GET or $_POST or whatever contains the form value. c) hidden, text, textarea ... doesn't matter. d) a way to test if what _should_ be an array is really an array is with print_r() and/or is_array(). print_r($arr); e) we don't need urldecode() because that'll happen automatically when going through the form. f) you could use implode() instead of serialize too. > Can someone throw some light on this? I hope so :) Regards, Philip Olson--- End Message ---
--- Begin Message ---Hi, can someone tell me is there a script for sending and receiving a mail via WAP ? Thanks, Rosen--- End Message ---
--- Begin Message ---This works for me (WinXPpro, IIS, PHP 4.1.2): <?php if (isset($HTTP_POST_VARS["MAX_FILE_SIZE"])) if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) { copy($HTTP_POST_FILES['userfile']['tmp_name'], "upload/".$HTTP_POST_FILES['userfile']['name']); move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], "upload/".$HTTP_POST_FILES['userfile']['name']); } else { echo "Possible file upload attack. Filename: " . $HTTP_POST_FILES['userfile']['name']; } ?> Hope it will help bye, evan "Dani" <[EMAIL PROTECTED]> ha scritto nel messaggio [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi, > > I want to upload image file into a folder in webserver using HTML form. > What function do I use fo this purpose? > > Thank you, > > Dani >--- End Message ---
--- Begin Message ---On Sat, May 25, 2002 at 05:41:24PM -0600, Kevin Stone wrote: > If so what would the unix command be to expand and create ZIP > archives? > How would I tie that into my PHP script using the system() function? system("unzip $filename"); or exec("unzip $filename"); or passthru("unzip $filename"); or `unzip $filename`; --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409--- End Message ---
--- Begin Message ---> With register_globals OFF in your php.ini file, all of the user input is > present in the _GET, _POST, _REQUEST, or _COOKIE array. With > register_globals ON, then the variables are registered as regular variables. > If you have a URL like page.php?id=1, then with them OFF, you have to use > $_GET["id"] to get the value of one, with them ON, you can just use $id. Just to be clear, $_GET['id'] will work fine with register_globals on or off. In otherwords, these php predefined variables will exist either way. Just like the older non-super ones, such as $HTTP_GET_VARS. Regards, Philip Olson--- End Message ---
--- Begin Message ---This is not really specific to PHP (although the information might be useful for all that form validation we all do), and for that I apologize in advance (does anyone know of a regex mailing list?), but maybe someone here can help with the following: I find no good regex for checking valid domain names. None that I have seen take into account the fact that, although dashes ("-") and dots (".") are allowed in a domain name, the domain name can neither begin with nor end with a dash or dot, and additionally, two dashes or two dots in a row are not allowed and a dash followed by a dot or a dot followed by a dash are not allowed. So, I've come up with two regex's for checking domain names. The first one checks that the name contains alphanumerics, the dash and the dot, and neither begins with or ends with a dash or dot: ^[a-z0-9]$|^[a-z0-9]+[a-z0-9.-]*[a-z0-9]+$ The second one checks that two dashes and two dots are not together and that a dash followed by a dot or a dot followed by a dash are not together: --|\.\.|-\.|\.- Putting it all together, the way I check for a valid domain name is with the following: if (eregi("^[a-z0-9]$|^[a-z0-9]+[a-z0-9.-]*[a-z0-9]+$", $domain_name) != true OR eregi("--|\.\.|-\.|\.-", $domain_name) == true { error; } So, my question (finally!) is this: Is there any way to combine both expressions (basically, one part that checks for false and one part that checks for true) into one regex that just returns true or false? I haven't been able to find any documentation that shows me how to do that, basically a "like this but not like this" syntax. BTW, anticipating someone mentioning the fact that the above regex's don't check for a domain name ending with a dot followed by three characters max (as in .com, .net, etc.), it's because that long-held truth is no longer true. We now have .info and .museum, and who know what the future will bring. About the only truth left is that domain names end in a dot followed by two characters minimum (there are the country code domains like .us, .de. etc. but there are no one character TLD's at present and I would expect perhaps not for a long long time, but you never know). Perhaps someone would expand on the regex above to include checking for a name ending with a dot followed by two characters minimum, I just haven't been into regex's long enough to know how). Of course, you could get really anal about all this and check for domain names that only end in the current ICANN root server TLD's (about 260 or so, I believe), but that wouldn't account for TLD's that operate within other root servers (there's always sumthin'). Anyways, Any help with the above is certainly appreciated! Jeff--- End Message ---
--- Begin Message ---I use this, but it's a preg rather than ereg pattern: '/([a-z0-9]+[a-z0-9\-]*\.)+[a-z0-9]+[a-z0-9\-]*[a-z0-9]+$/i' Two problems (which in practice are so slight that I've foregone my usual standards-analness to ignore them) 1) It will allow a domain name component (except the final one) to end with a dash (e.g., "test-.example.com"). 2) It will not allow a one-character final component. miguel On Sun, 26 May 2002, Jeff Field wrote: > This is not really specific to PHP (although the information might be useful > for all that form validation we all do), and for that I apologize in advance > (does anyone know of a regex mailing list?), but maybe someone here can help > with the following: > > I find no good regex for checking valid domain names. None that I have seen > take into account the fact that, although dashes ("-") and dots (".") are > allowed in a domain name, the domain name can neither begin with nor end > with a dash or dot, and additionally, two dashes or two dots in a row are > not allowed and a dash followed by a dot or a dot followed by a dash are not > allowed. > > So, I've come up with two regex's for checking domain names. The first one > checks that the name contains alphanumerics, the dash and the dot, and > neither begins with or ends with a dash or dot: > > ^[a-z0-9]$|^[a-z0-9]+[a-z0-9.-]*[a-z0-9]+$ > > The second one checks that two dashes and two dots are not together and that > a dash followed by a dot or a dot followed by a dash are not together: > > --|\.\.|-\.|\.- > > Putting it all together, the way I check for a valid domain name is with the > following: > > if (eregi("^[a-z0-9]$|^[a-z0-9]+[a-z0-9.-]*[a-z0-9]+$", $domain_name) != > true > OR eregi("--|\.\.|-\.|\.-", $domain_name) == true > { > error; > } > > So, my question (finally!) is this: > > Is there any way to combine both expressions (basically, one part that > checks for false and one part that checks for true) into one regex that just > returns true or false? I haven't been able to find any documentation that > shows me how to do that, basically a "like this but not like this" syntax. > > BTW, anticipating someone mentioning the fact that the above regex's don't > check for a domain name ending with a dot followed by three characters max > (as in .com, .net, etc.), it's because that long-held truth is no longer > true. We now have .info and .museum, and who know what the future will > bring. > > About the only truth left is that domain names end in a dot followed by two > characters minimum (there are the country code domains like .us, .de. etc. > but there are no one character TLD's at present and I would expect perhaps > not for a long long time, but you never know). Perhaps someone would expand > on the regex above to include checking for a name ending with a dot followed > by two characters minimum, I just haven't been into regex's long enough to > know how). > > Of course, you could get really anal about all this and check for domain > names that only end in the current ICANN root server TLD's (about 260 or so, > I believe), but that wouldn't account for TLD's that operate within other > root servers (there's always sumthin'). Anyways, > > Any help with the above is certainly appreciated! > > Jeff > > >--- End Message ---
--- Begin Message ---Dear folks, Has anyone ever been able to get a CGI to produce valid PHP output?? Whatever I do, my browser ALWAYS wants to open or save the non-parsed PHP text produced by the CGI file. And yes, I have set the proper ExecCGI and PHP entries in my vhosts.conf; and yes, I restarted the server. Basically, I open an existing php file (in a Perl CGI), and output its contents again to the Apache server. The CGI starts with sending this header: print "Content-type: application/x-httpd-php\n\n"; Then I output the text. But, no matter what I do, it will not parse the PHP code. I do not understand this. Regular PHP files in that dir work fine. There is, as far as I can see, no reason why this should not work. And the PHP file really needs to be generated from the CGI, as it needs to run as a specific user. Anyway, any help would be much appreciated, - Mark--- End Message ---
--- Begin Message ---The problem is that you are sending this output to the browser and not the server. You can do this with XML because IE and Netscape have XML parsers built-in. You should create a form that will catch the data from CGI then handle it on the server. There might be other work arounds as well...however, I have only played with the XML stuff... Thanks, Ray Hunter -----Original Message----- From: Mark [mailto:[EMAIL PROTECTED]] Sent: Sunday, May 26, 2002 12:07 PM To: [EMAIL PROTECTED] Subject: [PHP] Parsing PHP output Dear folks, Has anyone ever been able to get a CGI to produce valid PHP output?? Whatever I do, my browser ALWAYS wants to open or save the non-parsed PHP text produced by the CGI file. And yes, I have set the proper ExecCGI and PHP entries in my vhosts.conf; and yes, I restarted the server. Basically, I open an existing php file (in a Perl CGI), and output its contents again to the Apache server. The CGI starts with sending this header: print "Content-type: application/x-httpd-php\n\n"; Then I output the text. But, no matter what I do, it will not parse the PHP code. I do not understand this. Regular PHP files in that dir work fine. There is, as far as I can see, no reason why this should not work. And the PHP file really needs to be generated from the CGI, as it needs to run as a specific user. Anyway, any help would be much appreciated, - Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php--- End Message ---
--- Begin Message ---I tested ini_set('register_globals',0) and ini_set('register_globals','Off') for turning register_globals off. It doesn't work and it doesn't produce any notice, warning or error. Here's a quick example: <?php ini_set('register_globals',0); if(isset($test)) echo "<h2>$test</h2>"; ?> <form action="ini_set.php" method="get"> <input type="text" name="test" /> <input type="submit" /> </form> This prints out $test, what it shouldn't do with register_globals turned off. I tested this with PHP 4.1.2 and 4.2.1. Even if I start to doubt it is supposed to work according to the documentation. Can anyone tell me what I've done wrong? For some strange reason if I do echo ini_set('register_globals',0); it will print "10". For echo ini_set('register_globals','Off'); it will print "1Off". Jens PS: ini_set works fine with include_path and error_reporting--- End Message ---
--- Begin Message ---Can somone take a look at this? I found this on sourceforge, but cannot reach author. http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.php This month won't display properly. It's missing </tr><tr> somewhere. Every other month seems to work. Can someone help please? Here is the code: http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.php http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.phps http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/BaseCalendar.inc http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/BaseCalendar.inc.phps The problem should be in here, but I can't see it: // Plancing day i on calendar if ($shift==0 && $today_ts==$day_i_ts) { echo "<td bgcolor=".($this->calBGCellToday)."><strong><center>".$link_i."</center></strong></td>"; } else { echo "<td bgcolor=".($this->calBGCellColor)."><center>".$link_i."</center></td>\n"; if ($day_i==7 && $i<$daysInMonth) { echo "</tr><tr>\n"; } else if ($day_i==7 && $i==$daysInMonth) { echo "</tr>\n"; } else if ($i==$daysInMonth) { for ($h=$dayMonth_end; $h<7; $h++) { echo "<td> </td>\n"; } echo "</tr>\n"; } } //end else--- End Message ---
--- Begin Message ---Can somone take a look at this? I found this on sourceforge, but cannot reach author. http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.php This month won't display properly. It's missing </tr><tr> somewhere. Every other month seems to work. Can someone help please? Here is the code: http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.php http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.phps http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/BaseCalendar.inc http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/BaseCalendar.inc.phps The problem should be in here, but I can't see it: // Plancing day i on calendar if ($shift==0 && $today_ts==$day_i_ts) { echo "<td bgcolor=".($this->calBGCellToday)."><strong><center>".$link_i."</center></strong></td>"; } else { echo "<td bgcolor=".($this->calBGCellColor)."><center>".$link_i."</center></td>\n"; if ($day_i==7 && $i<$daysInMonth) { echo "</tr><tr>\n"; } else if ($day_i==7 && $i==$daysInMonth) { echo "</tr>\n"; } else if ($i==$daysInMonth) { for ($h=$dayMonth_end; $h<7; $h++) { echo "<td> </td>\n"; } echo "</tr>\n"; } } //end else--- End Message ---
--- Begin Message ---Can somone take a look at this? I found this on sourceforge, but cannot reach author. http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.php This month won't display properly. It's missing </tr><tr> somewhere. Every other month seems to work. Can someone help please? Here is the code: http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.php http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.phps http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/BaseCalendar.inc http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/BaseCalendar.inc.phps The problem should be in here, but I can't see it: // Plancing day i on calendar if ($shift==0 && $today_ts==$day_i_ts) { echo "<td bgcolor=".($this->calBGCellToday)."><strong><center>".$link_i."</center></strong></td>"; } else { echo "<td bgcolor=".($this->calBGCellColor)."><center>".$link_i."</center></td>\n"; if ($day_i==7 && $i<$daysInMonth) { echo "</tr><tr>\n"; } else if ($day_i==7 && $i==$daysInMonth) { echo "</tr>\n"; } else if ($i==$daysInMonth) { for ($h=$dayMonth_end; $h<7; $h++) { echo "<td> </td>\n"; } echo "</tr>\n"; } } //end else--- End Message ---
--- Begin Message ---Can somone take a look at this? I found this on sourceforge, but cannot reach author. http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.php This month won't display properly. It's missing </tr><tr> somewhere. Every other month seems to work. Can someone help please? Here is the code: http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.php http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/example.phps http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/BaseCalendar.inc http://www.collegesherbrooke.qc.ca/languesmodernes/calendar/BaseCalendar.inc.phps The problem should be in here, but I can't see it: // Plancing day i on calendar if ($shift==0 && $today_ts==$day_i_ts) { echo "<td bgcolor=".($this->calBGCellToday)."><strong><center>".$link_i."</center></strong></td>"; } else { echo "<td bgcolor=".($this->calBGCellColor)."><center>".$link_i."</center></td>\n"; if ($day_i==7 && $i<$daysInMonth) { echo "</tr><tr>\n"; } else if ($day_i==7 && $i==$daysInMonth) { echo "</tr>\n"; } else if ($i==$daysInMonth) { for ($h=$dayMonth_end; $h<7; $h++) { echo "<td> </td>\n"; } echo "</tr>\n"; } } //end else--- End Message ---
--- Begin Message ---Rite, when you see a web form, you know you can simulate the submit by filling in the values in the address field, just like a GET method, and it usually works the exact same. But how do you do it when one of the fields in the form is a file upload?!?!?! For the record, its a GIF file you've to upload. Is there any way to do this in PHP??--- End Message ---
--- Begin Message ---<?PHP $im = createfrombmp("image"); print "<FORM METHOD=\"post\" ACTION=\"actionpage.php\">"; print "<INPUT TYPE=\"hidden\" NAME=\"image\" VALUE=\"$im\">"; ?> you get the idea I think PHP does have other funtions for file uplading though. "Georgie Casey" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Rite, when you see a web form, you know you can simulate the submit by > filling in the values in the address field, just like a GET method, and it > usually works the exact same. But how do you do it when one of the fields in > the form is a file upload?!?!?! > > For the record, its a GIF file you've to upload. Is there any way to do this > in PHP?? > > > >--- End Message ---
--- Begin Message ---i'm getting an error message saying my BMP file i'm trying to convert isnt a valid WBMP file? is dere a difference between BMP and WBMP? I just opened my GIF file into PSP7 and and saved as a windows bmp. why isnt it working? "Peter" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > <?PHP > $im = createfrombmp("image"); > print "<FORM METHOD=\"post\" ACTION=\"actionpage.php\">"; > print "<INPUT TYPE=\"hidden\" NAME=\"image\" VALUE=\"$im\">"; > ?> > you get the idea > > I think PHP does have other funtions for file uplading though. > > "Georgie Casey" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Rite, when you see a web form, you know you can simulate the submit by > > filling in the values in the address field, just like a GET method, and it > > usually works the exact same. But how do you do it when one of the fields > in > > the form is a file upload?!?!?! > > > > For the record, its a GIF file you've to upload. Is there any way to do > this > > in PHP?? > > > > > > > > > >--- End Message ---