Re: [PHP] htaccess / php
Ed Lazor wrote: What do I put in .htaccess for Apache to process a named archive as a PHP file? I did it before and can't seem to find what I did. Requests to http://myhost.com/archive/page1.php would get processed by the file named archive and page1.php would just be a parameter that I could access from within the script by checking the url and subtracting http://myhost.com/archive/;. Location /archive ForceType application/x-httpd-php /Location -- H| I haven't lost my mind; it's backed up on tape somewhere. + Ashley M. Kirchner mailto:[EMAIL PROTECTED] . 303.442.6410 x130 IT Director / SysAdmin / WebSmith . 800.441.3873 x130 Photo Craft Laboratories, Inc.. 3550 Arapahoe Ave. #6 http://www.pcraft.com . . .. Boulder, CO 80303, U.S.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Generate automatic list of dates
Hi! $first_date = 2003-12-01 $end_date = 2004-01-15 while ( $first_date = $end_date) { $sql = INSERT INTO time_table (id, date, person_id) VALUES (35,$first_date,0); $result = mysql_query($sql, $conn); [next date] WHAT CODE TO HERE } eg. first insert row is 35, 2003-12-01,0 next should be 35,2003-12-02,0 etc ... and last 35,2004-01-15,0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] combo box
hi :) i am creating a webpage. i use a combo box to let user choose which folder they want. after they choose, it will be saved into the database. the next time they load this page, it will retrieve the data from database and appear at the combo box. i already done that. but now the problem isthe data that i retrieve from the database will same with the options in the combo box. so, it will become 2 same options. i am afraid this will confuse the user. so i want to fix it. if u dont understand what i mean, try look at the picture coding below: folder: husband friend family boss husband ___ this is the code: select size=1 name=groupMailbox1 option?php echo $row[groupMailbox1]; ?/option ?php //Open Directory you want to include //$base='/home/a/mail'; $handel = opendir($base); //Get contents of the directory while (false !== ($file = readdir($handel))) { if (is_dir($base . / . $file) ($file !== .) ($file !== ..)) { list($filename, $ext) = explode(., $file); list($main, $sub, $include) = explode(/, $PHP_SELF); echo option value=\$file\; //Echo the file name in a combo box if ($inc==$file) echo selected; echo$file/option\n; echo $file; } } ? /selectp/p ___ how to make it so that the data that we retrieve from database, if same with the options we have, we only need to make that option selected? thanks :) hweefarn __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generate automatic list of dates
- Original Message - From: Tommi Virtanen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 2:27 PM Subject: [PHP] Generate automatic list of dates Hi! $first_date = 2003-12-01 $end_date = 2004-01-15 while ( $first_date = $end_date) { $sql = INSERT INTO time_table (id, date, person_id) VALUES (35,$first_date,0); $result = mysql_query($sql, $conn); [next date] WHAT CODE TO HERE $str = explode(-, $first_date); $tst = mktime (0, 0, 0, $str[1], $str[2] +1, $str[0]); $first_date = strftime (%G-%m-%d, $tst); should do. } eg. first insert row is 35, 2003-12-01,0 next should be 35,2003-12-02,0 etc ... and last 35,2004-01-15,0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Generate automatic list of dates
- Original Message - From: Nitin [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Tommi Virtanen [EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 3:12 PM Subject: Re: [PHP] Generate automatic list of dates - Original Message - From: Tommi Virtanen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 2:27 PM Subject: [PHP] Generate automatic list of dates Hi! $first_date = 2003-12-01 $end_date = 2004-01-15 while ( $first_date = $end_date) { $sql = INSERT INTO time_table (id, date, person_id) VALUES (35,$first_date,0); $result = mysql_query($sql, $conn); [next date] WHAT CODE TO HERE $str = explode(-, $first_date); $tst = mktime (0, 0, 0, $str[1], $str[2] +1, $str[0]); $first_date = strftime (%G-%m-%d, $tst); use $first_date = strftime (%Y-%m-%d, $tst); instead... should do. } eg. first insert row is 35, 2003-12-01,0 next should be 35,2003-12-02,0 etc ... and last 35,2004-01-15,0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Generate automatic list of dates
Tommi Virtanen wrote: Hi! $first_date = 2003-12-01 $end_date = 2004-01-15 while ( $first_date = $end_date) { $sql = INSERT INTO time_table (id, date, person_id) VALUES (35,$first_date,0); $result = mysql_query($sql, $conn); [next date] WHAT CODE TO HERE 1) Convert current $first_date into timestamp, 2) add 1 day (in seconds), 3) convert it back to SQL-format and use it in next cycle-step. } -- Pavel a.k.a. Papi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] include-problem
On maandag 1 december 2003 15:23 Rasmus Lerdorf told the butterflies: On Mon, 1 Dec 2003, Wouter van Vliet wrote: ?php print !!!; ob_start(); include 'http://server.com/test/echo.php'; $XML = ob_get_clean(); // or use ob_get_contents(); and ob_end_clean() for PHP 4.3 print ???; print '[Between this you'll get your XYZ]'; print $XML; print '[Between this you'll get your XYZ]'; ? Or just use file_get_contents() which would be more efficient than using output buffering for this. -Rasmus yes, probably. But isn't file_get_contents(); only implemented from php4.3 .. might wanna try join('', file()); or $fd = fopen($FileName, 'r'); fread($fd, filesize($fd)); if you're running an older version. -me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Problem with $_POST[] and header();
Hi, I have an include file which I use to check all input. if there is a problem the user is redirected to the page they came from if(!mysql_query($query)){ $error = Could not complete query; header(Location: file.php?error=$error); exit; } However in file.php I have included $_POST[] variables sent from a previous page using the following method foreach ($_POST as $key = $value) { echo input type=\hidden\ name=\.$key.\ value=\.$value.\; } But if there is a problem with the input the $_POST[] values are not resent, is there a way to do this? Thanks for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] date() function doesn't seem to work right...
On maandag 1 december 2003 21:04 Curt Zirzow told the butterflies: * Thus wrote Scott Fletcher ([EMAIL PROTECTED]): When I do this script, I didn't get a : and numbers in second. --snip-- date(Y-m-d H:i:s); --snip-- works fine with phpversion() 4.2.2 Curt -- If eval() is the answer, you're almost certainly asking the wrong question. -- Rasmus Lerdorf, BDFL of PHP Yep, for PHP 4.3.4 it works juust fiine. What version are you using? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Error message trying to include a file
On maandag 1 december 2003 23:17 Curt Zirzow told the butterflies: * Thus wrote Matthias Wulkow ([EMAIL PROTECTED]): I have an array filled with urls of javascript files and then I include them one by one in a loop. for( $i = 0 ; $i sizeof($this-page-javascript) ; $i++ ){ include($this-page-javascript[$i]); //This line above is line 52 shown on error warning } what does print_r($this-page-javascript) yield? you'd be better off with a loop like: foreach($this-page-javascript as $file_to_include) { include($file_to_include); } Curt -- If eval() is the answer, you're almost certainly asking the wrong question. -- Rasmus Lerdorf, BDFL of PHP Probably include($this-page-javascript[$i]); Is the problem. There's this thing in PHP that you can't do this thing with referencing to an object property from within an other object. Or whatever to call that. Sounds silly and stupid, but it bullies me too. Try this: $Page = $this-page; foreach($Page-javascript as $File) include($File); or this (if you care about memory usage): $Page = $this-page; foreach(array_keys($Page-javascript) as $i) include($Page-javascript[$i]); Because php doesn't do reference thingies in a foreach loop, sadly. Wouter -note that you do not need { and } for oneline if/foreach/for/while/.. blocks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Picture Width and Height in $_FILES
On dinsdag 2 december 2003 3:40 Dimitri Marshall told the butterflies: Hi there, I've seen the code somewhere but can't remember what it is exactly. Basically I need to know what the PHP is to get the picture width and height. I tried: $pic = $_FILES[$objectNumber]; $width = $pic['width']; $height = $pic['height']; ... with no success. Any help is greatly appreciated. Thanks, Dimitri Marshall There's this getimagesize() function, it will tell you everything about an image that you need to know. Even who made it, if that's in the exif headers :P. Wouter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with $_POST[] and header();
On Tue, 2 Dec 2003 10:26:08 -, you wrote: if(!mysql_query($query)){ $error = Could not complete query; header(Location: file.php?error=$error); exit; } The Location: header requires an absolute URI. See RFC 2616, 14.30 However in file.php I have included $_POST[] variables sent from a previous page using the following method foreach ($_POST as $key = $value) { echo input type=\hidden\ name=\.$key.\ value=\.$value.\; } But if there is a problem with the input the $_POST[] values are not resent, is there a way to do this? Pass them as part of a GET, or store them in a session (you may need to include the session ID as part of the URI). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working as a PHP/database developer..
Hi! First of all, thanks for the input! What's the matter with re-using the code and charging the same rate for it? You're a business, and you're supposed to make money. I currently charge by the hour, but I'm trying whereever possible to move away from hourly rates into fixed price services. Why? Perhaps I stated my views a bit rashly. I'm not of the opinion that it is wrong to re-use code, merely that I was wondering how to specify the hourly rate if doing so. Seeing now (even though I couldn't say I have large enough control group ;-) ) that it is common to re-use and charge as normal, a) The client knows exactly what to expect in terms of price and result b) I don't spend half my days quoting every last detail of a job c) I have the opportunity to re-use code over and over, making a PROFIT, rather than braking even all the time I totally agree with (a) and (b), but what about (c)? Is it that hard to make a profit if one actually has to put some work into it? I.e. do you consider PHP/db development to be a large competition-driven field (within the larger field of software/script dev)? Copyright is the simple answer, but it needs to be a) observed by your clients b) enforced by you when not observed by clients Yes, I agree. But for (b), how can I enforce it since PHP code resides on servers. My scenario is this: I develop scripts for the (aforementioned web designers), cooperation ends and we go separate paths. Now how do I enforce my copyright when I have no insight into their other projects nor the web servers they work with? You can always compile your scripts, and supply them with compiled (encoded) products, rather than source scripts. This of course would depend on the copyright agreement you have with your clients. This is actually totally new to me. Compiling scripts, storing the (encoded) products on the server. What are the formats? Standards? Web servers / RDBM's that recognize these formats? There's no decent answer to that -- there's soo many factors to take into consideration, like the market, the economic environment, your skills, your productivity, your client's budget, etc etc. The only accurate answer is twice as much as half. Yeah, I know I had that answer coming. *laugh* Guess I'll have to continue sifting through the market in my area. Compiling with Zend encoder or similar, as stated above. Zend encoder. Okay! Though it partially answers my above question about encoding scripts, I would be grateful to get some more pointers on the technical nuts and bolts... (even though I probably can just start using the Zend encoder - always interested in learning more). You obviously aren't confident working with these people, so consider NOT working for them. No can do. The project is much to interesting and the social engineering implied by it is a hilarious experience. Alea iacta est! Thank you for the valuable input! VPeO -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 12 seconds!?!?
Comex wrote: I have a script that replicates a human on a message board, and its logs (logging in, going to inventory, etc.) occur every 12 (no more no less) seconds. Do you know why? Probably because the board that you are trying to spam ... err ... login to is configured to allow a delay before posts. VB has this option. -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com --- Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML, strings and foreign (swedish/danish) characters
I'm on the point of almost giving up trying to get XML and PHP to sing along, but I'll throw out a question here first. I'm having severe problems getting PHP and XML to work with XML-files that contains foreign characters. Doesnt matter if i type the foreign characters in by myself hardcoded in the PHP-script, or if I get them from external XML-files, or if I get them directly from the database. utf8_encode() helps a bit, in the way that it makes the script work at least, but instead of the string mngde PHP outputs mngde Is there any way to get XML to work together with PHP, or should I simply resign and try with ASP instead? Very thankful for any help that points in the right direction Sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: XML, strings and foreign (swedish/danish) characters
Hello, On 12/02/2003 09:05 AM, Victor spng arthursson wrote: I'm on the point of almost giving up trying to get XML and PHP to sing along, but I'll throw out a question here first. I'm having severe problems getting PHP and XML to work with XML-files that contains foreign characters. Doesnt matter if i type the foreign characters in by myself hardcoded in the PHP-script, or if I get them from external XML-files, or if I get them directly from the database. utf8_encode() helps a bit, in the way that it makes the script work at least, but instead of the string mngde PHP outputs mngde Is there any way to get XML to work together with PHP, or should I simply resign and try with ASP instead? You just need to use the proper input/output encodings. PHP function usually assume iso-8859-1 . I do not know if that is the encoding that your idiom uses. Anyway, you may want to try these XML parser and writer classes: http://www.phpclasses.org/xmlparser http://www.phpclasses.org/xmlwriter -- Regards, Manuel Lemos Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file uploads
Hi, I'm working on a class and when a user submits a form to add a new product, I'm calling the addProduct method and within that method I call another method of the class 3 times. Once for a thumbnail image, once for a preview image and once for the full image, is this considered the correct approach ??? function myMethod (){ myOtherFunc(full); myOtherFunc(preview); myOtherFunc(thumb); } Id that the best way to write it ?? It would appear to only have 1 method running at any one time, so making them work in succession would be the obvious answer: function myMethod (){ if(myOtherFunc(full)){ if(myOtherFunc(preview)){ if(myOtherFunc(thumb)){ echo all methods returned true!; } else { echo last method returned false!; } } else { echo 2nd method returned false!; } } else { echo 1st method returned false!; } } Is there not a better way of handling this function chain (for want of a better word) ??? Thanks, Jon jon bennett | [EMAIL PROTECTED] new media designer / developer _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/ On 1 Dec 2003, at 16:05, Jon Bennett wrote: Down't worry, it's sorted! Cheers, Jon jon bennett | [EMAIL PROTECTED] new media designer / developer _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/ On 1 Dec 2003, at 15:57, Jon Bennett wrote: I'm trying to return a value if the file uploads correctly, using return, but I don't seem to be getting anything back. I've added this to my storeImages method return = $aNewImage['new_name']; and when I call the method from my addProduct() method I use this: $sThumbnailFileName = $this-_storeImages($iProductId, $aArgs[Image], 'thumb'); I then assumed I'd be able to just reference the $sThumbnailFileName var so I can insert the filename into the db, but it always goes in blank, does $sThumbnailFileName not get returned $aNewImage['new_name'], or is it stuck in an array or something ?? Thanks, Jon jon bennett | [EMAIL PROTECTED] new media designer / developer _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/ On 1 Dec 2003, at 15:26, Jon Bennett wrote: well I'll be dammed, that was it! Geeze, you look at something for so long sometimes you can't see the wood for the trees I feel so stoopid now! Thanks, Jon jon bennett | [EMAIL PROTECTED] new media designer / developer _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/ On 1 Dec 2003, at 15:10, Pavel Jartsev wrote: Jon Bennett wrote: Just to clarify about using move_uploaded_file() ... function addProduct(){ // Move the uploaded file to the correct location move_uploaded_file($$_FILES[image][tmp_name], BASE_DIR./_img/_products/.$iProductId._.$fileName); } ... function storeBigImage($ID, $aImage){ // create filenames fopen($aImage['name'], 'r'); $aNewImage['real_name'] = $aImage['name']; $aNewImage['new_name'] = $ID . '_' . 'big' . '_' . $aNewImage['real_name']; $aNewImage['image_loc'] = BASE_DIR . '_lib/_products/' . $aNewImage['new_name']; ... Just noticed one thing... maybe it's just a typo, but directory, where You save uploaded image isn't the same in those examples. In move_uploaded_file() it contains _img/..., but in storeBigImage() there is _lib/ And therefore first case is working and second isn't. -- Pavel a.k.a. Papi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working as a PHP/database developer..
On Tuesday, December 2, 2003, at 09:45 PM, Video Populares et Optimates wrote: What's the matter with re-using the code and charging the same rate for it? You're a business, and you're supposed to make money. I currently charge by the hour, but I'm trying whereever possible to move away from hourly rates into fixed price services. Why? Perhaps I stated my views a bit rashly. I'm not of the opinion that it is wrong to re-use code, merely that I was wondering how to specify the hourly rate if doing so. Seeing now (even though I couldn't say I have large enough control group ;-) ) that it is common to re-use and charge as normal, I wouldn't say it's common practice, but it makes good business sense to refine your tools to the point where they can be reused over and over with a lot less new code for each resale. a) The client knows exactly what to expect in terms of price and result b) I don't spend half my days quoting every last detail of a job c) I have the opportunity to re-use code over and over, making a PROFIT, rather than braking even all the time I totally agree with (a) and (b), but what about (c)? Is it that hard to make a profit if one actually has to put some work into it? I.e. do you consider PHP/db development to be a large competition-driven field (within the larger field of software/script dev)? I don't understand the question. Copyright is the simple answer, but it needs to be a) observed by your clients b) enforced by you when not observed by clients Yes, I agree. But for (b), how can I enforce it since PHP code resides on servers. My scenario is this: I develop scripts for the (aforementioned web designers), cooperation ends and we go separate paths. Now how do I enforce my copyright when I have no insight into their other projects nor the web servers they work with? I can't answer that -- you need to talk to lawyers and seek legal advice. All I know is that copyright laws are there to protect. The catch is that enforcing this protection usually takes money. You can always compile your scripts, and supply them with compiled (encoded) products, rather than source scripts. This of course would depend on the copyright agreement you have with your clients. This is actually totally new to me. Compiling scripts, storing the (encoded) products on the server. What are the formats? Standards? Web servers / RDBM's that recognize these formats? [snip] Compiling with Zend encoder or similar, as stated above. Zend encoder. Okay! Though it partially answers my above question about encoding scripts, I would be grateful to get some more pointers on the technical nuts and bolts... (even though I probably can just start using the Zend encoder - always interested in learning more). Encoded scripts can run on virtually any server running PHP, using the optimiser (?). Of course, you could read about it all on Zend.com. Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] forms and mysql
Hi i am very new to PHP so need some help ! i have a form which allows the user to put in 2 team names and then displays them, at the moment it displays them side by side but i need to insert V (versus) in the middle--how can i do that. I am guessing it goes in the lines of the code below somewhere, This code originally displayed someones input for --first name,last name and address so i have adapted it. Is there anyway to have the 'address' field display a set value as in a V , at the moment i have removed that part but the table field is still there, i have just hidden the form input. $result = mysql_query(SELECT * FROM teams,$db); while ($myrow = mysql_fetch_array($result)) { printf(a href=\%s?id=%s\%s %s/a \n, $PHP_SELF, $myrow[id], $myrow[teama],$myrow[teamb]); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Upload issue - The 2MB barrier...
As the default setting for file upload is set to 2MB, we usually get a problem since we cant always access the php.ini on every server our scripts should be run from. After looking in the php.ini file on one of my webhosting partners I noticed an interesting (in my opinion) thing with the post settings which read : (And to make it clear, I could easilly change the php.ini file, but due to the other clients on this webserver I cant... Im not alone here ) post_max_size = 55M Since the other setting would easilly accept say 5 MB I wonder, would it be possible to upload an image as a POST? Or something like this? Maby this is a pointless idea to investigate further ? -- Kim Steinhaug --- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload issue - The 2MB barrier...
Hello Kim, Tuesday, December 2, 2003, 12:34:22 PM, you wrote: KS As the default setting for file upload is set to 2MB, we usually get KS a problem since we cant always access the php.ini on every server KS our scripts should be run from. Can you modify the httpd.conf for your site? If so you can over-ride the upload_max_filesize setting in that without messing up any other user on the server. -- Best regards, Richardmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: forms and mysql
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi i am very new to PHP so need some help ! i have a form which allows the user to put in 2 team names and then displays them, at the moment it displays them side by side but i need to insert V (versus) in the middle--how can i do that. I am guessing it goes in the lines of the code below somewhere, This code originally displayed someones input for --first name,last name and address so i have adapted it. Is there anyway to have the 'address' field display a set value as in a V , at the moment i have removed that part but the table field is still there, i have just hidden the form input. $result = mysql_query(SELECT * FROM teams,$db); while ($myrow = mysql_fetch_array($result)) { printf(a href=\%s?id=%s\%s %s/a \n, $PHP_SELF, $myrow[id], $myrow[teama],$myrow[teamb]); I'm sure that printf and friends must be most confusing to those who don't come from a C background :-) I think something like this might work, and be a bit more comprehensible to a neophyte. $result = mysql_query(SELECT * FROM teams,$db); while ($myrow = mysql_fetch_array($result)) { extract($myrow); // allows you to access fields as $id, $teama etc // printf(a href=\%s?id=%s\%s %s/a \n, $PHP_SELF, $myrow[id], // $myrow[teama],$myrow[teamb]); echo 'A HREF='.$_SERVER{'PHP_SELF'}.'?id='.$id.'' . \n; echo $teama V $teamb/A\n; } -- Quod subigo farinam A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload issue - The 2MB barrier...
Hmm 1. We can rule out the ini_set() 2. We can now rule out the .htaccess Tried the following : .htaccess php_value upload_max_filesize 5M testfile.php print 'upload_max_filesize = ' . ini_get('upload_max_filesize') . \n; The testfile succesfully states the new value, but it doesnt work. Obviously, the documentation on php.net already told me so, so the fact that I really tested this is kinda stupid... hehe. That leaves me with the httpd.conf settings which is supposed to work, also according to the PHP documentation. Just need to locate this file first... -- Kim Steinhaug --- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. --- Richard Davey [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello Kim, Tuesday, December 2, 2003, 12:34:22 PM, you wrote: KS As the default setting for file upload is set to 2MB, we usually get KS a problem since we cant always access the php.ini on every server KS our scripts should be run from. Can you modify the httpd.conf for your site? If so you can over-ride the upload_max_filesize setting in that without messing up any other user on the server. -- Best regards, Richardmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload issue - The 2MB barrier...
Kim Steinhaug wrote: That leaves me with the httpd.conf settings which is supposed to work, also according to the PHP documentation. Just need to locate this file first... $ locate httpd.conf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best way to split a string of numbers into segments.
Hi. Is there an easy, non expensive way to do the perl-equivalent of: $date=20031202; ($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/; I looked through the preg_* functions online, but couldn't see anything to help me. Am I stuck with substr() :P ? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: combo box
If I were you, I do this way. // in your HTML form. select name=flag option value=1 Husband/option ... /select // DB then insert 1, 2, 3, 4. //it will be one of them from flag variable. // when you retrieve it... if (flag == 1) echo Husband if ... and so on. :) Kang Chan Hweefarn Saputra wrote: hi :) i am creating a webpage. i use a combo box to let user choose which folder they want. after they choose, it will be saved into the database. the next time they load this page, it will retrieve the data from database and appear at the combo box. i already done that. but now the problem isthe data that i retrieve from the database will same with the options in the combo box. so, it will become 2 same options. i am afraid this will confuse the user. so i want to fix it. if u dont understand what i mean, try look at the picture coding below: folder: husband friend family boss husband ___ this is the code: select size=1 name=groupMailbox1 option?php echo $row[groupMailbox1]; ?/option ?php //Open Directory you want to include //$base='/home/a/mail'; $handel = opendir($base); //Get contents of the directory while (false !== ($file = readdir($handel))) { if (is_dir($base . / . $file) ($file !== .) ($file !== ..)) { list($filename, $ext) = explode(., $file); list($main, $sub, $include) = explode(/, $PHP_SELF); echo option value=\$file\; //Echo the file name in a combo box if ($inc==$file) echo selected; echo$file/option\n; echo $file; } } ? /selectp/p ___ how to make it so that the data that we retrieve from database, if same with the options we have, we only need to make that option selected? thanks :) hweefarn __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upload issue - The 2MB barrier...
I found the file, but since im on a Cpanel server I do have to do some checking with the admin so that I dont mess up for other users. I wouldnt want my experimenting resulting in an unstable server for other users, :) It looks like this is the only way to alter the settings. Thanks for replies. -- Kim Steinhaug --- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. --- Marek Kilimajer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Kim Steinhaug wrote: That leaves me with the httpd.conf settings which is supposed to work, also according to the PHP documentation. Just need to locate this file first... $ locate httpd.conf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to split a string of numbers into segments.
preg_match should do it... $mydate = 20031202; $date = array(); preg_match(/(\d{4})(\d{2})(\d{2})/, $mydate, $date); print_r($date); substr would be much quicker though On Tue, 2003-12-02 at 13:14, Tom wrote: Hi. Is there an easy, non expensive way to do the perl-equivalent of: $date=20031202; ($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/; I looked through the preg_* functions online, but couldn't see anything to help me. Am I stuck with substr() :P ? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Community Site - Volunteers Needed
The French php community has its site already : http://www.communautephp.com. Myabe it can give you some ideas... Chris Shiflett wrote: PHP has one of the largest developer communities in the world, yet we have no community gathering place like those you can find for other languages (Perl has http://use.perl.org/, for example). Want to help change this? Read on. Don't care? Click delete. :-) I am coordinating the development of a Web site that is built by and for the PHP community. Its features will include such things as: 1. Personal blogs for all registered users 2. Frequent community news and user comments (Slashdot style) 3. Weekly summaries of key mailing lists (such as php-general) 4. Weekly summaries of other news from related communities 5. News from various user groups (such as NYPHP) 6. Links, FAQs, articles, tutorials, and other helpful documentation More importantly, the features will be driven by the needs of the community and not any one person. This list is just an example of the most common features found on other community sites. Will this site seek to eliminate other PHP sites that offer one or more of these features already? Absolutely not. My hope is to help bring the community together, both the people in the community as well as all related Web sites. I have spoken with O'Reilly, and they have agreed to support us in this endeavor with servers, bandwith, administration, and anything else we need. All we have to do is provide the people to develop and maintain the site and its content. You don't have to be an expert to help out. I need people to fill the following roles (multiple people can fill the same role and a single person can fill multiple roles): 1. Site management and global vision 2. Coding standards creation and software architecture 3. Security audits and general guidance 4. Weekly summary of php-general 5. Weekly summary of php-internals 6. Weekly summary of general community news 7. News item selection and posting (users can submit suggested news) 8. Database design 9. Software development (PHP, Perl, etc.) 10. PHP user group representatives (updated news from your group) 11. Content writers (FAQs, articles, tutorials, etc.) 12. Graphic designers, user interface specialists, etc. 13. Translators There are likely many other roles to be filled. If you think you can help out a lot, please consider the first role, site management and global vision. If you want to help but don't feel like you fit into any specific role, don't worry about it (any help is very much appreciated). There will be mailing lists, CVS, and other tools available to assist in the creation of this site. More information about these things will be given to those who are interested in being involved. Please send me an email at [EMAIL PROTECTED] if you are willing to help. Mention where you are interested in helping and any information about yourself that you think is important. This information is not intended to determine whether anyone is worthy or any silliness like that, but it is rather to help organize the contributors so that everyone is doing something they enjoy. Thanks for your attention. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to split a string of numbers into segments.
On Tue, 02 Dec 2003 13:14:20 +, you wrote: Is there an easy, non expensive way to do the perl-equivalent of: $date=20031202; ($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/; I looked through the preg_* functions online, but couldn't see anything to help me. Am I stuck with substr() :P ? list() springs to mind list ($a, $b, $c) = preg_split (/* mumble mumble */); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] reload farmes
Hi there I have some problems with PHP. I have a website with different frames where different actions take place. One frame needs a button (here: Delete) which: 1. reloads another frame 2. reloads itself The code looks like: if (isset($_POST['action'])) { if ($_POST['action'] == Delete) { $id = $_POST['absolute']; $activity = mysql_query(SELECT id FROM activity WHERE station = '$station'); $activity_fetch = mysql_fetch_array($activity); $delete_activity = mysql_query(DELETE FROM activity where id = '$id'); $update_stations = mysql_query(UPDATE stations set status = 1, timestatus = 0 where station = '$station'); header(Location: http://127.0.0.1/empty.php;); } } With HTML it is body onload=. But this doesn`t work here because I have sent the header already. Can anyone help me? TIA Christian -- NextNet IT Services Christian Jancso phone +41.1.210.33.44 facsimile +41.1.210.33.13 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to split a string of numbers into segments.
I agree that preg_match generates an array, but I cannot assign to it directly, and in your example I have 4 elements in the array, not three. Array ( [0] = 20031202 [1] = 2003 [2] = 12 [3] = 02 ) I suppose something like preg_match(/(\d{4})(\d{2})(\d{2})/, $mydate, list($y,$m$d)); Is vaguely what I am gunning for. And substr()... $date = 20031202; $year = substr($date,0,4); $month = substr($date,3,2); $day = substr($date,5,2); That seems like a lot of lines of code, and I am believe that substr() is expensive. Maybe I have been doing too much perl, as it seems such a neat solution to me :P preg_match should do it... $mydate = 20031202; $date = array(); preg_match(/(\d{4})(\d{2})(\d{2})/, $mydate, $date); print_r($date); substr would be much quicker though On Tue, 2003-12-02 at 13:14, Tom wrote: Hi. Is there an easy, non expensive way to do the perl-equivalent of: $date=20031202; ($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/; I looked through the preg_* functions online, but couldn't see anything to help me. Am I stuck with substr() :P ? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to split a string of numbers into segments.
David Otton wrote: On Tue, 02 Dec 2003 13:14:20 +, you wrote: Is there an easy, non expensive way to do the perl-equivalent of: $date=20031202; ($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/; I looked through the preg_* functions online, but couldn't see anything to help me. Am I stuck with substr() :P ? list() springs to mind list ($a, $b, $c) = preg_split (/* mumble mumble */); Hi David. Yes, list() was, initially, my starting point. But preg_split() will not allow me split with the full /(\d{4})(\d{2})(\d{2})/ syntax (and assign the temp vars to thos in list(). Unless I missed something? $date=20031202; list ($a, $b, $c) = preg_split (/(\d{4})(\d{2})(\d{2})/); parse error, unexpected '/', expecting ')' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reload farmes
you cannot change the page after you have started sending it.. this is a limitation of HTTP not PHP. You will probably need to send some javascript along with your php to do the frame reloading, or find a neater way to do it On Tue, 2003-12-02 at 14:12, Christian Jancso wrote: Hi there I have some problems with PHP. I have a website with different frames where different actions take place. One frame needs a button (here: Delete) which: 1. reloads another frame 2. reloads itself The code looks like: if (isset($_POST['action'])) { if ($_POST['action'] == Delete) { $id = $_POST['absolute']; $activity = mysql_query(SELECT id FROM activity WHERE station = '$station'); $activity_fetch = mysql_fetch_array($activity); $delete_activity = mysql_query(DELETE FROM activity where id = '$id'); $update_stations = mysql_query(UPDATE stations set status = 1, timestatus = 0 where station = '$station'); header(Location: http://127.0.0.1/empty.php;); } } With HTML it is body onload=. But this doesn`t work here because I have sent the header already. Can anyone help me? TIA Christian -- NextNet IT Services Christian Jancso phone +41.1.210.33.44 facsimile +41.1.210.33.13 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to split a string of numbers into segments.
list ($a, $b, $c) = preg_split (/(\d{4})(\d{2})(\d{2})/); note the 's list ($a, $b, $c) = preg_split (/(\d{4})(\d{2})(\d{2})/); parse error, unexpected '/', expecting ')' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to split a string of numbers into segments.
list(, $year, $month, $day) = Tom wrote: I agree that preg_match generates an array, but I cannot assign to it directly, and in your example I have 4 elements in the array, not three. Array ( [0] = 20031202 [1] = 2003 [2] = 12 [3] = 02 ) I suppose something like preg_match(/(\d{4})(\d{2})(\d{2})/, $mydate, list($y,$m$d)); Is vaguely what I am gunning for. And substr()... $date = 20031202; $year = substr($date,0,4); $month = substr($date,3,2); $day = substr($date,5,2); That seems like a lot of lines of code, and I am believe that substr() is expensive. Maybe I have been doing too much perl, as it seems such a neat solution to me :P preg_match should do it... $mydate = 20031202; $date = array(); preg_match(/(\d{4})(\d{2})(\d{2})/, $mydate, $date); print_r($date); substr would be much quicker though On Tue, 2003-12-02 at 13:14, Tom wrote: Hi. Is there an easy, non expensive way to do the perl-equivalent of: $date=20031202; ($year, $month, $day) = ($date =~ /(\d{4})(\d{2})(\d{2})/; I looked through the preg_* functions online, but couldn't see anything to help me. Am I stuck with substr() :P ? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] (More Information) was Problems with ldap_modify() and very large entries
Here's a followup to my problem with ldap_mod_replace and ldap_modify. Attached is a simple program demonstrating the problem. Basically, if you try to fill an attribute in ldap that is something around 17000 characters or above, ldap_mod_replace hangs. I've determined it is definately a PHP problem, since ldap_modify from the commandline works consistently and fine with very high amounts of data. Thus, in the following simple code: $conn = ldap_connect(ldap://ldap.server.net;); ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_start_tls($conn); ldap_bind($conn, 'uid=root,ou=users,dc=server,dc=net', 'password'); $dn = mnTB=CB1,mnTS=abra,mnT=index,dc=peterjh,dc=in,dc=us,dc=server,dc=net; $array = array(); $output = ; for ($i = 0; $i 170; $i++) { # 26 * 4 = 104 - 4 = 100 # thus append a hundred characters each iteration $string = efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk $output .= $string; } print strlen($output) .\n; $array['mnappparam'][0] = $output; ldap_mod_replace($conn, $dn, $array); Setting the top of $i to 170 or above hangs (consistently) ldap_mod_replace. Technically, 161-180 (thus, 17000-18000 characters) hangs inconsistently, while 160 and belows never hangs (16000 characters) and 181+ (181000 chars) hangs everytime. Any help on this would be highly appreciated, Peter John Hartman -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] printer_end_page() not ending page
Hey guys, I'm writing a small script that will print pick lists for our online orders using the printer functions provided with the stock extension. The problem is I can't get it to span across multiple pages. I've tried checking the Y position and using end_page and start_page accordingly but for some reason it's locking up. Here's my code, I'm only posting the bit that's making it lock up. If I take this bit out it prints flawlessly but it only gives me one page of data. I commented it out after the fact so if anything isn't clear just ask me to clarify. if ($y == 6210){ // I stuffed $y in to see where the page ended, the last line was 6210 // $y increments 110 after every line I draw_text to with a little $y = $y + 110; printer_delete_font($itemFont); // I've tried it with and without deleting the font but I get the same results printer_end_page($handle); // according to the doc this shold end the page $itemFont = printer_create_font(Arial,72,48,400,false,false,false,0); // recreate the font printer_select_font($handle, $itemFont); // .. printer_start_page($handle); // this _should_ start a new page, below I have $y starting at 110 just for the margin $y = 110; } What am I doing wrong here? I've searched through tons of google's to find an example of someone doing this but all I can find are endless amounts of manual entries on the same functions. Little help? -Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] (More Information) was Problems with ldap_modify() and very large entries
Just to note: the problem holds true for: ldap_mod_add, ldap_modify, and ldap_mod_replace. Also, adding ldap_set_option($conn, LDAP_OPT_SIZELIMIT, 20) doesn't resolve the problem (or setting it to 0). Peter On Tue, 2 Dec 2003, Peter J Hartman wrote: Here's a followup to my problem with ldap_mod_replace and ldap_modify. Attached is a simple program demonstrating the problem. Basically, if you try to fill an attribute in ldap that is something around 17000 characters or above, ldap_mod_replace hangs. I've determined it is definately a PHP problem, since ldap_modify from the commandline works consistently and fine with very high amounts of data. Thus, in the following simple code: $conn = ldap_connect(ldap://ldap.server.net;); ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_start_tls($conn); ldap_bind($conn, 'uid=root,ou=users,dc=server,dc=net', 'password'); $dn = mnTB=CB1,mnTS=abra,mnT=index,dc=peterjh,dc=in,dc=us,dc=server,dc=net; $array = array(); $output = ; for ($i = 0; $i 170; $i++) { # 26 * 4 = 104 - 4 = 100 # thus append a hundred characters each iteration $string = efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk $output .= $string; } print strlen($output) .\n; $array['mnappparam'][0] = $output; ldap_mod_replace($conn, $dn, $array); Setting the top of $i to 170 or above hangs (consistently) ldap_mod_replace. Technically, 161-180 (thus, 17000-18000 characters) hangs inconsistently, while 160 and belows never hangs (16000 characters) and 181+ (181000 chars) hangs everytime. Any help on this would be highly appreciated, Peter John Hartman -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms and mysql
Hi, Tuesday, December 2, 2003, 9:54:33 PM, you wrote: B Hi i am very new to PHP so need some help ! B i have a form which allows the user to put in 2 team names and then displays B them, at the moment it displays them side by side but i need to insert V B (versus) in the middle--how can i do that. B I am guessing it goes in the lines of the code below somewhere, This code B originally displayed someones input for --first name,last name and address B so i have adapted it. Is there anyway to have the 'address' field display a B set value as in a V , at the moment i have removed that part but the table B field is still there, i have just hidden the form input. B $result = mysql_query(SELECT * FROM teams,$db); B while ($myrow = mysql_fetch_array($result)) { B printf(a href=\%s?id=%s\%s %s/a \n, $PHP_SELF, $myrow[id], B $myrow[teama],$myrow[teamb]); Just stick a V between as in ..%s V %s ... printf will ignore anything without a % before it and just copy it to the output -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Finding array in MySQL (I'm not asking the right question)
PHP Gurus, What I'm trying to do must be both common and simple, but I'm not asking the question right because I can't find the answers in Google or the online PHP manual using the search words like array, find, PHP, MySQL, etc... I have an array, and I want to select the fields in a table that match the contents of the array. The array consists of a set of user IDs. I want to find their emails from the table in a MySQL database which stores all their contact information. Sounds simple, right? Well, SELECT email FROM table WHERE id = . $array . ); isn't cutting it. I'm a total beginner, but I can understand why this doesn't work without being able to fix it. The data inside the array needs to be extracted into the set of ids it contains so that MySQL can read it. So I could run a while() loop and query the database for each id in the array, but that's obviously totally inefficient. There must be a command which handles this kind of thing. It's not explode(), it's not in_array()... I know what I'm after, but I just can't come up with the search term or phrasing which will allow a search engine to help me find it. Can someone please point me in the right direction? -- Cheers! Dave G [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding array in MySQL (I'm not asking the right question)
You can do something like $str = '.implode(', ', $arr).'; $query = SELECT * FROM table WHERE id IN ($str); Hope this helps, -- Cordialement, --- Sophie Mattoug Développement web dynamique [EMAIL PROTECTED] --- Dave G wrote: PHP Gurus, What I'm trying to do must be both common and simple, but I'm not asking the question right because I can't find the answers in Google or the online PHP manual using the search words like array, find, PHP, MySQL, etc... I have an array, and I want to select the fields in a table that match the contents of the array. The array consists of a set of user IDs. I want to find their emails from the table in a MySQL database which stores all their contact information. Sounds simple, right? Well, SELECT email FROM table WHERE id = . $array . ); isn't cutting it. I'm a total beginner, but I can understand why this doesn't work without being able to fix it. The data inside the array needs to be extracted into the set of ids it contains so that MySQL can read it. So I could run a while() loop and query the database for each id in the array, but that's obviously totally inefficient. There must be a command which handles this kind of thing. It's not explode(), it's not in_array()... I know what I'm after, but I just can't come up with the search term or phrasing which will allow a search engine to help me find it. Can someone please point me in the right direction? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML, strings and foreign (swedish/danish) characters
Victor Spng Arthursson wrote: I'm on the point of almost giving up trying to get XML and PHP to sing along, but I'll throw out a question here first. I'm having severe problems getting PHP and XML to work with XML-files that contains foreign characters. Doesnt matter if i type the foreign characters in by myself hardcoded in the PHP-script, or if I get them from external XML-files, or if I get them directly from the database. utf8_encode() helps a bit, in the way that it makes the script work at least, but instead of the string mngde PHP outputs mngde After processing the xml, use utf8_decode to get back to iso-8859-1 Is there any way to get XML to work together with PHP, or should I simply resign and try with ASP instead? Very thankful for any help that points in the right direction Sincerely Victor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Finding array in MySQL (I'm not asking the right question)
[snip] Well, SELECT email FROM table WHERE id = . $array . ); [/snip] $arrayUser[1] = 'bob'; $arrayUser[2] = 'cindy'; $arrayUser[1] = 'mark'; $countUser = count($arrayUser); for($i = 0; $i $countUser; $i++){ $sql = SELECT email FROM table WHERE id = ' . $arrayUser[$i] . ' ; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding array in MySQL (I'm not asking the right question)
SELECT email FROM table WHERE id IN (' . implode(',',$array) . '); And don't forget to check if $array really contains only numeric values. Dave G wrote: PHP Gurus, What I'm trying to do must be both common and simple, but I'm not asking the question right because I can't find the answers in Google or the online PHP manual using the search words like array, find, PHP, MySQL, etc... I have an array, and I want to select the fields in a table that match the contents of the array. The array consists of a set of user IDs. I want to find their emails from the table in a MySQL database which stores all their contact information. Sounds simple, right? Well, SELECT email FROM table WHERE id = . $array . ); isn't cutting it. I'm a total beginner, but I can understand why this doesn't work without being able to fix it. The data inside the array needs to be extracted into the set of ids it contains so that MySQL can read it. So I could run a while() loop and query the database for each id in the array, but that's obviously totally inefficient. There must be a command which handles this kind of thing. It's not explode(), it's not in_array()... I know what I'm after, but I just can't come up with the search term or phrasing which will allow a search engine to help me find it. Can someone please point me in the right direction? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding array in MySQL (I'm not asking the right question)
$arrayUser[1] = 'bob'; $arrayUser[2] = 'cindy'; $arrayUser[1] = 'mark'; $countUser = count($arrayUser); for($i = 0; $i $countUser; $i++){ $sql = SELECT email FROM table WHERE id = ' . $arrayUser[$i] .' ; } Is this method faster than just using IN and implode()? ie, WHERE id IN ( ' . implode() . ' ) Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best way to split a string of numbers into segments.
From the manual preg_split Returns an array containing substrings of subject split along boundaries matched by pattern. since you dont have any borders, this is unlikely to help you the only was i can see to do it is a quite long way $mydate = 20031202; $date = array(); preg_match(/(\d{4})(\d{2})(\d{2})/, $mydate, $date); list($x, $y, $d, $m) = $date; echo $d. / .$m. / .$y .\n; Mike On Tue, 2003-12-02 at 15:15, Tom wrote: I have noted the 's. Could you send me a complete piece of code, please? I cannot for the life of me get it to work, at all. Mike wrote: list ($a, $b, $c) = preg_split (/(\d{4})(\d{2})(\d{2})/); note the 's list ($a, $b, $c) = preg_split (/(\d{4})(\d{2})(\d{2})/); parse error, unexpected '/', expecting ')' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Finding array in MySQL (I'm not asking the right question)
[snip] $arrayUser[1] = 'bob'; $arrayUser[2] = 'cindy'; $arrayUser[1] = 'mark'; $countUser = count($arrayUser); for($i = 0; $i $countUser; $i++){ $sql = SELECT email FROM table WHERE id = ' . $arrayUser[$i] .' ; } Is this method faster than just using IN and implode()? ie, WHERE id IN ( ' . implode() . ' ) [/snip] No, because it requires the query be run more than once, but you may not get the desired results. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Finding array in MySQL (I'm not asking the right question)
Is this method faster than just using IN and implode()? Thanks to all who replied. I believe I have found what I'm looking for in using the implode() command. My assumption is that it was faster and more efficient to try and do as much processing on the PHP side and make as few queries to the database as possible. Is that a correct assumption, or am I wrong there? -- Cheers! Dave G [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Finding array in MySQL (I'm not asking the right question)
Dave G wrote: Is this method faster than just using IN and implode()? Thanks to all who replied. I believe I have found what I'm looking for in using the implode() command. My assumption is that it was faster and more efficient to try and do as much processing on the PHP side and make as few queries to the database as possible. Is that a correct assumption, or am I wrong there? Totally wrong ! It's always better to have maximum work done by MySQL Hope this helps, -- Cordialement, --- Sophie Mattoug Développement web dynamique [EMAIL PROTECTED] --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dealing with large classes over several files
This may well have come up before as it is an obvious problem/question. Coming from a C++ background, I define a class in a header file and define the functions for that class in a seperate source file. Now the question: is this possible in PHP4? I have tried the obvious: // myclass.inc.php class foo { // constructor and destructor function f () {} } // myclass.php function foo::f () { // define here } This gives me an error: unexpected T_PAAMAYIM_NEKUDOTAYIM Is this possible in PHP4, and if not, why not? It's an obvious problem, namely for code management. -Callum Urquhart www.pastecode.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Dealing with large classes over several files
This URL might be of some assistance to you: http://www.php.net/manual/en/ref.classobj.php It is a page on how to write classes and its associated member functions in PHP. There are a couple of other pages in the documentation which may be of assistance to you as well. HTH! --Sam -Original Message- From: Callum Urquhart [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 10:57 AM To: [EMAIL PROTECTED] Subject: [PHP] Dealing with large classes over several files This may well have come up before as it is an obvious problem/question. Coming from a C++ background, I define a class in a header file and define the functions for that class in a seperate source file. Now the question: is this possible in PHP4? I have tried the obvious: // myclass.inc.php class foo { // constructor and destructor function f () {} } // myclass.php function foo::f () { // define here } This gives me an error: unexpected T_PAAMAYIM_NEKUDOTAYIM Is this possible in PHP4, and if not, why not? It's an obvious problem, namely for code management. -Callum Urquhart www.pastecode.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Quick ereg_replace question
Hi, I need a regular expression which will eliminate all characters except numbers, period, and +, -, *, or / I am currently using: $new_value = ereg_replace('[^0-9\.-/+*]', , $value); However, this seems to eliminate - as well. Any help would be appreciated. Also, any good references for regular expressions? Thanks, Grant -- Grant Rutherford Iders Incorporated 100-137 Innovation Drive Winnipeg, MB, Canada R3T 6B6 http://www.iders.ca tel: 204-779-5400 ext 36 fax: 204-779-5444 Iders Incorporated: Confidential Note: This message is intended solely for the use of the designated recipient(s) and their appointed delegates, and may contain confidential information. Any unauthorized disclosure, copying or distribution of its contents is strictly prohibited. If you have received this message in error, please destroy it and advise the sender immediately by phone, Email or facsimile. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick ereg_replace question
I need a regular expression which will eliminate all characters except numbers, period, and +, -, *, or / I am currently using: $new_value = ereg_replace('[^0-9\.-/+*]', , $value); However, this seems to eliminate - as well. Any help would be appreciated. Try listing the - as the first character (or last) so it's not seen as showing a range. Also, any good references for regular expressions? O'Reilly's Mastering Regular Expressions, by Jeffrey Friedl. HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with $_POST[] and header();
it works fine as it is though? David Otton [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Tue, 2 Dec 2003 10:26:08 -, you wrote: if(!mysql_query($query)){ $error = Could not complete query; header(Location: file.php?error=$error); exit; } The Location: header requires an absolute URI. See RFC 2616, 14.30 However in file.php I have included $_POST[] variables sent from a previous page using the following method foreach ($_POST as $key = $value) { echo input type=\hidden\ name=\.$key.\ value=\.$value.\; } But if there is a problem with the input the $_POST[] values are not resent, is there a way to do this? Pass them as part of a GET, or store them in a session (you may need to include the session ID as part of the URI). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working as a PHP/database developer..
A few suggestions here, from my experience. I offer a variety of computer services freelance, and have been focusing on building my web development side of things. Customers love flat rates, but you WILL eat the time WHEN, not if, you go over. I offer flat rates for mostly HTML web design services. The client gets x number of pages and y number hours photography and we meet in the beginning and in the end. The client approves the site and I'm done. Any changes, unless I personally feel I made a stupid mistake, are billed according to my update policy. For PHP pages, I don't offer flat rates. I can give an estimate of the time it will take, but no more than that. My absolute minimum hourly rate is $35/hour and I'm located in Southwestern Washington State, USA. When I do work, it's a premium service. I don't claim to be the world's best PHP coder, but all my pages are reasonably written, execute quickly, and are quite secure. My big thing is that I make everything work, and work smoothly. I have a knack for building features that make everything easy to use, as simple as possible, yet extremely powerful. I write online catalogs that the owners can update and upload pictures and everything. I create online scheduling systems that are simple and straightforward. All this is perfectly integrated and easy to use. So as far as code issues go, well, most of the code isn't reusable without modification. I don't usually write a lot of comments, so that makes it doubly hard to see what's going on. The part that really makes me feel better about misuse of my code is that my clients like and trust me. They wouldn't switch to another person or company, and they lack the skills to work on PHP themselves. For simplicity's sake, I just leave source code on their sites. The only exception is a new area I'm working on: writing code that is licensed. I'm developing a church/club/organization database with PHP MySQL. I'll license it to people for their use only and include limitations on how many people can be in the database through PHP. This code I will compile so it can't easily be changed or modified for reuse. I also have a few other projects like this in the works. I'm still learning about the best ways to do all this, but I think you might find what I've learned so far helpful. Galen P. Zink Computer Consulting Web Design (360) 609-2617 http://zinkconsulting.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] header function, I'm stumped
All, dealing with header(location:...) again. and trying to understand what's happening. I've got the following code: writeMessage($id); header(Location:http://www.mysite.com/cp/ad/ad_details.php?id=;. $id); writeMessage() is a debugging function that writes the value of the variable to a debug log. When the code is run $id does have a valid value like 8 or 12. When I run the code, it does not redirect to the specified location, it continues executing the code. So I add the exit; and it does work: writeMessage($id); header(Location:http://www.mysite.com/cp/ad/ad_details.php?id=;. $id); exit; What's weird is the same code without the exit works on a different server (and indeed the same code with different location works on this server) I thought perhaps it was due to type problem, but code doesn't work if $id is a string or integer. The flow for the code: start the edit page when edit page is submitted, check the data, if data is good, update the database redirect to details page if data is bad, return to the edit page Then I used LiveHTTPHeaders in Mozilla and it give me some interesting information, though I'm not quite sure how to interpret. Can someone provide some depth to the mechanisms within the header(location)? Thanks in advance, Chris Hubbard [EMAIL PROTECTED] www.wildcharacters.com 425 481 2020 php based web application development [[ check out phalidate, a data validation class ]] Y! [EMAIL PROTECTED] MSN [EMAIL PROTECTED] AIM ganeshacph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] header function, I'm stumped
--- Chris Hubbard [EMAIL PROTECTED] wrote: header(Location:http://www.mysite.com/cp/ad/ad_details.php?id=;. $id); There should be a space after the first colon there. Then I used LiveHTTPHeaders in Mozilla and it give me some interesting information, though I'm not quite sure how to interpret. Awesome. Paste that here (you can omit the bulk of the HTML, so that there's not too much stuff to sift through), and we can help you interpret it. What would be best is to try and trim it down to only what is different between when it works and when it doesn't. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Parse WebCT quiz
John, I think your best option is to convert their format to XML and then use the XML to drive your quiz system. Should be pretty straightforward to convert to XML, cause you don't have to worry about exploding stuff. You just have to match patterns and use str_replace. Chris -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Sunday, November 23, 2003 10:26 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Parse WebCT quiz I have done this (below) already. I suppose. I will have to explode by \n. One of my problems is that with :QUESTION:{H|T}, the question is on the next line. Exploding by \n puts my question text into the next line_field[]. Note: Multiple lines of text are permitted. Getting that variabnle confuses me, for example. https://online.csus.edu/web-ct/help/en/designer/quiz/quiz_transfer.html#form ats Tested: http://ccl.flsh.usherbrooke.ca/~johj2201/webct_import.php $fileContents=fread($fh, filesize($_FILES['userfile']['tmp_name'])); fclose($fh); $lines=explode(\n,$fileContents); foreach($lines as $line) { echo $line.hr; } -quiz.txt-- :TYPE:S :TITLE:Sample Exercise JQuiz 2 (2) :CAT:Sample Exercise 2 :QUESTION:H I have come here ua lot/u. :ANSWERS:1 :CASE:0 :ANSWER1:How often have you come here?:100:0:0 :ANSWER2:How often have I come here?:100:0:0 :TYPE:MC:1:0:C :TITLE:Sample JBC Exercise 1 (1) :CAT:Sample Exercise 1 :QUESTION:H Which if the following sentences is incorrect? :ANSWER1:0:H That's not a very funny joke. :REASON1:H :ANSWER2:0:H The book I'm reading is quite long. :REASON2:H :ANSWER3:0:H He's much taller than me. :REASON3:H :ANSWER4:100:H Anna is more younger than Halley. :REASON4:H The corrct response is: Anna is younger than Halley. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Working as a PHP/database developer..
Video, et al -- I've been an independent SysAdmin for about seven years, but have only been doing independent programming for a couple, so others will certainly have more coding guidance and experience than I. All I can definitely say is that I'm still working on the knack of properly estimating my time! :-/ What I can say, though, is that if for any reason you're not comfortable with the folks with/for whom you will work then it's probably better to not or at least best to get it in writing and get as much as you can up front. Take the extra time to work out a contract that covers the sorts of services you'll provide (I would say that it shouldn't bother to include specifics of a particular bid; submit that separately as a quote or estimate instead), how and when payments are due (by check or other and terms like net 15, net 30, upon recepit) and what happens if they aren't (grace period, late fees, interest, ...), perhaps what happens if you can't complete your end, and who owns the finished product (unless that's declared to be specified in each quote). Unfortunately, it's generally true that if you can trust your partners (or clients) then you don't need a contract and if you can't then even the best one won't help you, so that gets you back to the get it up front part. For small jobs I require the full payment up front; for large jobs I do half up front and half upon completion. For hourly estimate jobs (or long-term hourly jobs like a 4-month one I did late this summer) I submit semiweekly invoices as well as, if desired, time sheets outlining what I did when and sometimes require a starter payment up front. All of my invoices have been net 15 but I'm trying to move to upon receipt :-) and have done so for any sys admin calls that I make. So that brings us to your licensing questions. Some of them may be alleviated by their not being able to do anything with the PHP code because they are not coders; they'd have to call you to make any changes for another site anyway. But otherwise it should be covered in your quote (which will clearly outline everything you're to do -- which is, by the way, just like a contract, for the benefit of both both at the beginning and the end), and you can reasonably argue that code written to be suitable for reuse takes more time and costs more. And, finally, down to pricing... I estimate my time based on the plan that I'd write everything from scratch, since some if it will be and other parts of it might still require some modification. That then gives me a number that I can perhaps adjust to come up with a quote. If you're working on a straight hourly basis, then you might be able to either bill for some or all of the hours it WOULD take you to write the module you'll pull out of your toolbox or bill a higher rate for implementing these library modules of yours. I tend to lean toward the former, and it's been OK so far (but, admittedly, I don't have much of a library!). Another thing that helps is to figure out your client's budget and how they'll like to spend it -- not so much for the purposes of sucking it dry :-) but to see things from their point of view. An example from the SA world is a client that wanted a hundred machines updated and expected to pay someone about $5k to someone who could do one per hour, or about $50/hr. The guy who got the job confirmed that they were happy with paying $50 per *machine* and quoted the job -- and then invested about 20 hours of his own time in building and testing a distribution server which he then used to rebuild the 100 machines in another 20 hours. He did the work in less time (and vastly less from the client's perspective) and everyone was happy even though he got paid a higher rate :-) Just what sort of job opportunity is this? Will you be an hourly employee who does whatever he is told, or a completely independent contractor implementing something to a set of general specs, or something in between? That goes a long way, too, toward your determination of who should own and control what. What's a proper pay? Those spending nearly always think it's lower than those receiving :-) As a general rule, if this isn't either a permanent job or a long-term contract (in which case you shouldn't be worrying about code ownership, IMHO), you need to bill for about half of the year to make your desired annual target because the other half will be spent on training, practicing, and hunting. Whether you apply that on a code licensing basis or an hourly work rate basis, make sure that you'll make enough to be around later! HTH HAND best of luck! :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
[PHP] sendmail vs smpt
Hi all. I'm curious as to the performance difference between scripts that use sendmail vs. smtp for their mailing abilities. I use the following class for delivering emails, http://phpmailer.sourceforge.net http://phpmailer.sourceforge.net/ , and since I don't have sendmail running on my local machine I'm using the smtp server of the university where I work to deliver my messages. However, it seems to be a bit sluggish. I'm going to run a test of switching the mail handler from smtp to sendmail once the application is in its permanent home in a few weeks, but for now does anyone have any opinions on this, and is there any advantage to using one over the other? Thanks in advance, Pablo
Re: [PHP] sendmail vs smpt
Pablo -- ...and then Pablo Gosse said... % % Hi all. I'm curious as to the performance difference between scripts % that use sendmail vs. smtp for their mailing abilities. Using sendmail will almost always be very very much faster because - you're talking to the local machine - you're offloading the mail process to something else and so if you can do so -- even if your machine is only set up with a dumb mailer that only knows how to talk to your U's smarthost -- I would recommend that you run, not walk, to do so :-) HTH HAND :-D -- David T-G * There is too much animal courage in (play) [EMAIL PROTECTED] * society and not sufficient moral courage. (work) [EMAIL PROTECTED] -- Mary Baker Eddy, Science and Health http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg! pgp0.pgp Description: PGP signature
[PHP] Re: sendmail vs smpt
Hello, On 12/02/2003 07:50 PM, Pablo Gosse wrote: Hi all. I'm curious as to the performance difference between scripts that use sendmail vs. smtp for their mailing abilities. I use the following class for delivering emails, http://phpmailer.sourceforge.net http://phpmailer.sourceforge.net/ , and since I don't have sendmail running on my local machine I'm using the smtp server of the university where I work to deliver my messages. However, it seems to be a bit sluggish. I'm going to run a test of switching the mail handler from smtp to sendmail once the application is in its permanent home in a few weeks, but for now does anyone have any opinions on this, and is there any advantage to using one over the other? Forget SMTP. There is a myth that SMTP is faster than queuing message via sendmail but that is just a reflex that some people do not understand how it works. What you need to understand is that sending messages usually consists on two things: queueing and deliverying. Usually you do not deliver messages directly to the end recipient. You just pass them to a MTA (Mail Transfer Agent) that will take care of the delivery. When you you pass the message to sendmail program, depending on it may be configured, it may either try to deliver the message immediately and return when it is done, or just leave the message on the local queue for later delivery. When you relay the message to a SMTP server, usually it just queues the message there for later delivery. Obviously, if you use sendmail and it tries to deliver the message immediately, it will take eventually a little more time, but the message is already delivered. If the message is queued for later delivery, your PHP script does not have to wait so much but the message may take much longer to be deliver. Even if you just want to queue the messages for later delivery to free your PHP scripts, sendmail can do it much faster because you will be using local interprogram communication to injec the message in the local queue. If you do it via SMTP server, you need to establish a TCP connection which is much slower even when the SMTP server is in the same machine. If you just want to free your PHP scripts and leave messages in the queue, what you may need to do is to pass sendmail the appropriate switches to tell it to do it so. For that, you can check sendmail documentation to see the available modes, or you may want to try this e-mail message composing and sending class that has sub-classes specialized in delivering via mail() function, sendmail, qmail and SMTP. The sendmail subclass provides options that translate to the appropriate sendmail switches. For faster queueing, set the delivery_mode variable of the sendmail_message_class to SENDMAIL_DELIVERY_DEFERRED . If you can have a qmail MTA in your machine, use qmail because it is by far the most efficient. http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] replace %rand[x]-[y]% macro in string with random string
Hello PHP-list, I'm building a script, that provides a honeypot of invalid email addresses for spambots.. for this I want to provide a macro for the templates that looks like %rand[x]-[y]%, where [x] and [y] are integers, that specify the length of the random script. My first thoughts were about the best parsing of the %rand..%-part, but now I came to a point, where I could also need suggestions on the random string generation.. It considers very basic word generations and the only meaningful word I discovered was 'Java'.. *g For generation of a random string with length 1.000.000 it takes about 13 seconds on my xp 1600+.. that's quite a lot, imho, so suggestions are very welcome.. the script goes here, ready to copy'n'paste: -- list($low, $high) = explode( , microtime()); $this-timerstart = $high + $low; function parserandstr($toparse){ $debug = 0; $new = ''; $ch = array( 'punct' = array('.', '.', '.', '..', '!', '!!', '?!'), 'sep' = array(', ', ' - '), 'vocal' = array('a', 'e', 'i', 'o', 'u'), 'cons_low' = array('x', 'y', 'z'), 'cons_norm' = array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w') ); while ( ($pos = strpos($toparse, '%rand')) !== FALSE){ if ($debug) echo 'brbr$pos: ' . $pos; $new .= substr($toparse, 0, $pos); if ($debug) echo 'br$new: ' . $new . ''; $toparse = substr($toparse, $pos + 5); if ($debug) echo 'br$toparse: ' . $toparse . ''; $posclose = strpos($toparse, '%', 1); if ($debug) echo 'br$posclose: ' . $posclose . ''; if ($posclose){ $rlength = substr($toparse, 0, $posclose); if ($debug) echo 'br$rlength: ' . $rlength . ''; $possep = strpos($rlength, '-'); $minrlen = substr($rlength, 0, $possep); $maxrlen = substr($rlength, $possep + 1); if ($debug) echo 'br$minrlen: ' . $minrlen . ''; if ($debug) echo 'br$maxrlen: ' . $maxrlen . ''; $rlen = rand($minrlen, $maxrlen); // generate random string $randstr = ''; $inword = 0; $insentence = 0; $lastchar = ''; for($j = 0; $j $rlen; $j++){ if ($inword 3 rand(0, 5) == 1) { // punctuation chars if (rand(0,5) 0) $char = ' '; else { $char = $ch['punct'][rand(0, count($ch['punct'])-1)] . ' '; $j += strlen($char)-1; $insentence = 0; } $inword = 0; } else { if (!$lastwasvocal rand(0, 10) 6) { // vocals $char = $ch['vocal'][rand(0, count($ch['vocal'])-1)]; $lastwasvocal = true; } else { do { if (rand(0, 30) 0) // normal priority consonants $char = $ch['cons_norm'][rand(0, count($ch['cons_norm'])-1)]; else $char = $ch['cons_low'][rand(0, count($ch['cons_low'])-1)]; } while ($char == $lastchar); $lastwasvocal = false; } $inword++; $insentence++; } if ($insentence == 1 || ($inword == 1 rand(0, 30) 10)) $randstr .= strtoupper($char); else $randstr .= $char; $lastchar = $char; } $new .= $randstr; if ($debug) echo 'br$new: ' . $new; $toparse = substr($toparse, $posclose + 1); if ($debug) echo 'br$toparse: ' . $toparse . ''; } else $new .= '%rand'; } return $new . $toparse; } function pre_dump($var, $desc=''){ echo 'pre::'.$desc.'::br'; var_dump($var); echo '/pre'; } #$s = parserandstr('random string comes here: ' . '%rand10-1000%. this is a fake %rand and should not be killed..'); $s = parserandstr('%rand20-20%'); echo 'brbr' . $s; echo 'brbr' . strlen($s); list($low, $high) = explode( , microtime()); $t= $high + $low; printf(brloaded in: %.4fs, $t - $this-timerstart); -- shinE! http://www.thequod.de ICQ#152282665 PGP 8.0 key: http://thequod.de/danielhahler.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace %rand[x]-[y]% macro in string with random string
Hello Daniel, Tuesday, December 2, 2003, 10:46:33 PM, you wrote: dh For generation of a random string with length 1.000.000 it takes about dh 13 seconds on my xp 1600+.. that's quite a lot, imho, so suggestions dh are very welcome.. Just so we're clear on this - you're creating a string (an email address) of a million characters? I don't know my mail RFC's that well, but I'm sure this is well beyond what it considers standard. Does the string HAVE to make sense? I mean does a spambot really care less, or can even detect, what the email address contains? Surely just creating a truly random string would suffice (and indeed remove the need for the rather elaborate function you posted). I fully accept I might be missing the whole point here :) -- Best regards, Richardmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: replace %rand[x]-[y]% macro in string with random string
result on my laptop for default script settings (P4 2.66, 512mb ram) 20 loaded in: 1.3158s please tell me what you think of this? if you like it i can email it to you (as a php file) --begin php code--- ?php class honeyPot { //define word lengths var $umin; var $umax; var $dmin; var $dmax; //define address count var $addresses; var $userfordomain; var $emails; var $countrys; function honeyPot($usermin = 3, $usermax = 15, $addresses = 10, $userfordomain = false, $domainmin = 3, $domainmax = 15){ $this-umin = $usermin; $this-umax = $usermax; $this-addresses = $addresses; $this-userfordomain = $userfordomain; $this-dmin = $domainmin; $this-dmax = $domainmax; $this-countrys = array(,au,cz,andsoforth); $this-types = array(com,co,org,gov,mil,id,tv,cc,andsoforth); } function createAddressArray(){ $i=0; $addressarray = array(); while($i$this-addresses){ $addressarray[] = $this-makeAddress(); $i++; } return $addressarray; } function displayAddresses(){ $i=0; $addressstring = ; while($i$this-addresses){ $addressstring .= $this-makeAddress() . br; $i++; } echo $addressstring; return $addressstring; } function makeAddress(){ $user = $this-createRandString(); if($this-userfordomain == false){ $domain = $this-createRandString(domain); }else{ $domain = $user; } $address = $user . @ . $domain . . . $this-createType(); $country = $this-createCountry(); if($country != ){ $address .= . . $country; } return $address; } function createRandString($type = user){ srand((double) microtime() * 948625); if($type==user){ $length = rand($this-umin, $this-umax); }else{ $length = rand($this-dmin, $this-dmax); } $string = ; $numbersmin = 48; $numbersmax = 57; $lowercaselettersmin = 97; $lowercaselettersmax = 122; $whichset = 0; while($length = 0){ $set = rand(0,100); if($set 5){ $string .= _; }elseif($set 32){ $string .= chr(rand($numbersmin, $numbersmax)); }else{ $string .= chr(rand($lowercaselettersmin, $lowercaselettersmax)); } $length--; } return $string; } function createType(){ srand ((double) microtime() * 845676); $tid = rand(0, count($this-types)-1); return $this-types[$tid]; } function createCountry(){ srand ((double) microtime() * 375797); $cid = rand(0, count($this-countrys)-1); return $this-countrys[$cid]; } } $test = new honeyPot(); print_r($test-createAddressArray()); echo brbr\n\n; $test-displayAddresses() ? end php code-- -- Luke Daniel Hahler [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello PHP-list, I'm building a script, that provides a honeypot of invalid email addresses for spambots.. for this I want to provide a macro for the templates that looks like %rand[x]-[y]%, where [x] and [y] are integers, that specify the length of the random script. My first thoughts were about the best parsing of the %rand..%-part, but now I came to a point, where I could also need suggestions on the random string generation.. It considers very basic word generations and the only meaningful word I discovered was 'Java'.. *g For generation of a random string with length 1.000.000 it takes about 13 seconds on my xp 1600+.. that's quite a lot, imho, so suggestions are very welcome.. the script goes here, ready to copy'n'paste: -- list($low, $high) = explode( , microtime()); $this-timerstart = $high + $low; function parserandstr($toparse){ $debug = 0; $new = ''; $ch = array( 'punct' = array('.', '.', '.', '..', '!', '!!', '?!'), 'sep' = array(', ', ' - '), 'vocal' = array('a', 'e', 'i', 'o', 'u'), 'cons_low' = array('x', 'y', 'z'), 'cons_norm' = array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w') ); while ( ($pos = strpos($toparse, '%rand')) !== FALSE){ if ($debug) echo 'brbr$pos: ' . $pos; $new .= substr($toparse, 0, $pos); if ($debug) echo 'br$new: ' . $new . ''; $toparse = substr($toparse, $pos + 5); if ($debug) echo 'br$toparse: ' . $toparse . ''; $posclose = strpos($toparse, '%', 1); if ($debug) echo 'br$posclose: ' . $posclose . ''; if ($posclose){ $rlength = substr($toparse, 0, $posclose); if ($debug) echo 'br$rlength: ' . $rlength . ''; $possep = strpos($rlength, '-'); $minrlen = substr($rlength, 0, $possep); $maxrlen = substr($rlength, $possep + 1); if ($debug) echo 'br$minrlen: ' . $minrlen . ''; if ($debug) echo 'br$maxrlen: ' . $maxrlen . ''; $rlen = rand($minrlen, $maxrlen); // generate random string $randstr = ''; $inword = 0; $insentence = 0; $lastchar = ''; for($j = 0; $j $rlen; $j++){ if ($inword 3 rand(0, 5) == 1) { // punctuation chars if (rand(0,5) 0) $char = ' '; else { $char =
Re: [PHP] replace %rand[x]-[y]% macro in string with random string
On Tue, 2003-12-02 at 18:33, Richard Davey wrote: Hello Daniel, Tuesday, December 2, 2003, 10:46:33 PM, you wrote: dh For generation of a random string with length 1.000.000 it takes about dh 13 seconds on my xp 1600+.. that's quite a lot, imho, so suggestions dh are very welcome.. I missed the original post, and I'm too lazy to go looking, but the following code runs in approx. 2.75 seconds on my Athlon 2400 running linux: $chars = '0123456789' .'abcdefghijklmnopqrstuvwxyz' .'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charArray = array(); for( $i = 0; $i 100; $i++ ) { $charArray[] = $chars[rand( 0, 61 )]; } It's runs much faster than using a .= style of string creation. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: replace %rand[x]-[y]% macro in string with random string
i forgot to mention, that being a class, you should be able to set any of the variable you want (either on class creation: new honeyPot($value1, $value2, etc); or with the class variables, $spambot = new honeyPot; $spambot-addresses = 50; //amount to create) Luke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace %rand[x]-[y]% macro in string with random string
on Tue, 2 Dec 2003 23:33:47 + Richard Davey wrote: RD Just so we're clear on this - you're creating a string (an email RD address) of a million characters? I don't know my mail RFC's that well, but RD I'm sure this is well beyond what it considers standard. We're not clear.. ;) the function I've posted is designed for templates, that handle the output my script generates.. it's useful to have non-email text portions in between or a short random string for the mailto-links description.. RD Does the string HAVE to make sense? I found it better to follow some rules.. At first that were spaces in between and it got bigger.. if I'd write a spambot I would check if the page I'm lurking on is a oneliner or does only contain non-email words with 20 characters, and so on.. -- shinE! http://www.thequod.de ICQ#152282665 PGP 8.0 key: http://thequod.de/danielhahler.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: replace %rand[x]-[y]% macro in string with random string
on Wed, 3 Dec 2003 10:54:10 +1100 Luke wrote: L result on my laptop for default script settings L (P4 2.66, 512mb ram) L 20 L loaded in: 1.3158s thanks for the test.. L please tell me what you think of this? if you like it i can email it to you L (as a php file) Looks good, I have already something similar as generate invalid addresses in my project, which only needs translation of the config section and some logging statistics, which are done in MySQL. At first, I only wanted to do a floodprotection for the notifybyemail feature, but now I'm with the whole config part into db.. :o) Anyone who'd like to betatest this, is very welcomed to drop me an email. A release post will also go here.. -- shinE! http://www.thequod.de ICQ#152282665 PGP 8.0 key: http://thequod.de/danielhahler.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace %rand[x]-[y]% macro in string with random string
on 02 Dec 2003 18:56:28 -0500 Robert Cummings wrote: RC I missed the original post, and I'm too lazy to go looking, but the RC following code runs in approx. 2.75 seconds on my Athlon 2400 running RC linux: it is 4.3 seconds on xp 1600+.. RC $chars = '0123456789' RC .'abcdefghijklmnopqrstuvwxyz' RC .'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; RC $charArray = array(); RC for( $i = 0; $i 100; $i++ ) RC { RC $charArray[] = $chars[rand( 0, 61 )]; RC } RC It's runs much faster than using a .= style of string creation. ..and replacing $charArray[] = with $s .= crawls this down to 3.5 seconds - so this is faster here.. winxp, php 4.3.4, Apache 1.xx -- shinE! http://www.thequod.de ICQ#152282665 PGP 8.0 key: http://thequod.de/danielhahler.asc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: replace %rand[x]-[y]% macro in string with random string
final note, for anyone who finds this interesting in the class, if you update the following 2 variables, this is the proper list $this-countrys = array(,.ac,.ad,.ae,.af,.ag,.ai,.al,.am,.an,.ao,.aq, .ar,.as,.at,.au,.aw,.az,.ba,.bb,.bd,.be,.bf,.bg,.bh ,.bi,.bj,.bm,.bn,.bo,.br,.bs,.bt,.bv,.bw,.by,.bz,.c a,.cc,.cd,.cf,.cg,.ch,.ci,.ck,.cl,.cm,.cn,.co,.cr, .cu,.cv,.cx,.cy,.cz,.de,.dj,.dk,.dm,.do,.dz,.ec,.ee ,.eg,.eh,.er,.es,.et,.fi,.fj,.fk,.fm,.fo,.fr,.ga,.g d,.ge,.gf,.gg,.gh,.gi,.gl,.gm,.gn,.gp,.gq,.gr,.gs, .gt,.gu,.gw,.gy,.hk,.hm,.hn,.hr,.ht,.hu,.id,.ie,.il ,.im,.in,.io,.iq,.ir,.is,.it,.je,.jm,.jo,.jp,.ke,.k g,.kh,.ki,.km,.kn,.kp,.kr,.kw,.ky,.kz,.la,.lb,.lc, .li,.lk,.lr,.ls,.lt,.lu,.lv,.ly,.ma,.mc,.md,.mg,.mh ,.mk,.ml,.mm,.mn,.mo,.mp,.mq,.mr,.ms,.mt,.mu,.mv,.m w,.mx,.my,.mz,.na,.nc,.ne,.nf,.ng,.ni,.nl,.no,.np, .nr,.nu,.nz,.om,.pa,.pe,.pf,.pg,.ph,.pk,.pl,.pm,.pn ,.pr,.ps,.pt,.pw,.py,.qa,.re,.ro,.ru,.rw,.sa,.sb,.s c,.sd,.se,.sg,.sh,.si,.sj,.sk,.sl,.sm,.sn,.so,.sr, .st,.sv,.sy,.sz,.tc,.td,.tf,.tg,.th,.tj,.tk,.tm,.tn ,.to,.tp,.tr,.tt,.tv,.tw,.tz,.ua,.ug,.uk,.um,.us,.u y,.uz,.va,.vc,.ve,.vg,.vi,.vn,.vu,.wf,.ws,.ye,.yt, .yu,.za,.zm,.zw); $this-types = array(com,org,gov,mil,net); luke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Finding array in MySQL (I'm not asking the right question)
Totally wrong ! It's always better to have maximum work done by MySQL So does that mean that this: $countUser = count($arrayUser); for($i = 0; $i $countUser; $i++){ $sql = SELECT email FROM table WHERE id = ' . $arrayUser[$i] . ' ; } ... is faster than this: SELECT email FROM table WHERE id IN (' . implode(',',$array) . '); ... ? -- Cheers! Dave G [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Simple table sorting
Hi! I have simple table like: namedepartment [data: first name] [data: dep. no] [data: second name] [data: dep. no] Now I have only sorting which sorts using ORDER BY name. How I make header name / department active link, which I can change sorting order Department and then back to Name? regards, gustavus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple table sorting
On Tue, 2003-12-02 at 21:30, Tommi Virtanen wrote: Hi! I have simple table like: name department [data: first name][data: dep. no] [data: second name] [data: dep. no] Now I have only sorting which sorts using ORDER BY name. How I make header name / department active link, which I can change sorting order Department and then back to Name? If you mean so that the user can click the department column heading and have the data sorted by department, then you can create a link to the current page with url parameters orderBy and disposition. For instance: myPage.php?orderBy=departmentdisposition=ascending Then in your page you can check the values of these and modify the ORDER BY clause of your query. The following example exemplifies what I'm saying: $qString = SELECT . name, . department .FROM . foo_table .ORDER BY ; if( isset( $_GET['orderBy'] ) $_GET['orderBy'] == 'department' ) { $qString .= 'department '; } else { $qString .= 'name '; } if( isset( $_GET['disposition'] ) $_GET['disposition'] == 'desc' ) { $qString .= 'DESC '; } else { $qString .= 'ASC '; } mysql_query( $qString ); HTH, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] news service
Hi i had your php news account setup on my outlook express buti lost it what do i put as the address Mark
[PHP] Re: news service
news.php.net and subscribe to the group php.general make sure you have all your email addresses and stuff setup in the account because it may ask you to send a confirmation no user/pass required -- Luke Bigmark [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi i had your php news account setup on my outlook express buti lost it what do i put as the address Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unicode translation
Guys, A problem arised on my application when a user enters a Unicode format code on the site. Well, we really catch every information and i really need to get some explanation about it. ex: C = U+0108: Latin Capital Letter C With Circumflex Now this unicode character does not have any keystroke on my computer, i only have Character Map (Windows) to generate this. On my php form i can type this clearly, but once preview it changes the character to Í or something similar (I guess). But when i used a Unicode character that has a keystroke value ë for example once preview it generates the correct character. Any bright ideas on this? -- - Louie Miranda http://www.axishift.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Conditional anchor href value
I'm working on a page which displays details for a given record, and allows the user to flip back and forth through a large set of records, much like a set of index cards. Previous and Next buttons reload the card with the new record id. It is important that the URLs for the cards be very simple and static (easily bookmarked), along the lines of: card.php?id=123. The complexity comes because there are a number of ways in which one would want to flip back and forth: by date, by creator, etc. We have a select menu on the card which provides these options. If the prev/next buttons and select menu are part of a form, one can check the menu upon the reload of the page and find the correct new id, but the page in this case will not have a useful, clean URL. Most likely it will reference the referring card. We don¹t want that. What we need is a way of saying if the menu says date, use this id, etc. It seemed to me that we might be looking at problem requiring a client-side solution, but my javascript experiments have been frustrating, and seem to be veering into browser-conditional waters - one of the great arguments for server-side scripting. Still the js approach has been closest to what we need: the php script puts all the possible links from that card into the page, and then the js function uses the correct one. Does anyone have any advice? Thanks -eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Conditional anchor href value
you might be able to put the id of the next/prev card as the value of the option and then use javascript to generate the url. the only reliance then would be that the browser as JS enabled, as the above should be possible with the most basic of JS HTH Martin -Original Message- From: Eric Blanpied [mailto:[EMAIL PROTECTED] Sent: Wednesday, 3 December 2003 2:05 PM To: php-general Subject: [PHP] Conditional anchor href value I'm working on a page which displays details for a given record, and allows the user to flip back and forth through a large set of records, much like a set of index cards. Previous and Next buttons reload the card with the new record id. It is important that the URLs for the cards be very simple and static (easily bookmarked), along the lines of: card.php?id=123. The complexity comes because there are a number of ways in which one would want to flip back and forth: by date, by creator, etc. We have a select menu on the card which provides these options. If the prev/next buttons and select menu are part of a form, one can check the menu upon the reload of the page and find the correct new id, but the page in this case will not have a useful, clean URL. Most likely it will reference the referring card. We don¹t want that. What we need is a way of saying if the menu says date, use this id, etc. It seemed to me that we might be looking at problem requiring a client-side solution, but my javascript experiments have been frustrating, and seem to be veering into browser-conditional waters - one of the great arguments for server-side scripting. Still the js approach has been closest to what we need: the php script puts all the possible links from that card into the page, and then the js function uses the correct one. Does anyone have any advice? Thanks -eric -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Information from NOD32 1.568 (20031202) __ This message was checked by NOD32 for Exchange e-mail monitor. http://www.nod32.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] in a Variable
Hi there, I'm sure this is an easy fix, but how do you either prevent users from being able to input in a field or make it so that it doesn't affect the code? Thanks in advance, Dimitri Marshall -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditional anchor href value
--- Eric Blanpied [EMAIL PROTECTED] wrote: Still the js approach has been closest to what we need: the php script puts all the possible links from that card into the page, and then the js function uses the correct one. Does anyone have any advice? Let PHP choose the correct one? Maybe something like this will work: a href=foo.php?bar=? echo $bar; ?Click here/a Then, you can let PHP choose what the appropriate value of bar should be. Show us some code, and I'm sure we can give you more specific examples. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] in a Variable
--- Dimitri Marshall [EMAIL PROTECTED] wrote: how do you either prevent users from being able to input in a field or make it so that it doesn't affect the code? Can you give an example of affecting the code? You can store spaces in variables just fine. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] in a Variable
Sorry, what I mean is... I have a field in a form where users input text. If the user inputs something like: Hi there, this is a quote and you should know it. Then only... Hi there, get's inserted because of the double quotes. Is that more clear? Dimitri Marshall Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] --- Dimitri Marshall [EMAIL PROTECTED] wrote: how do you either prevent users from being able to input in a field or make it so that it doesn't affect the code? Can you give an example of affecting the code? You can store spaces in variables just fine. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] in a Variable
Hello Dimitri, Wednesday, December 3, 2003, 3:28:19 AM, you wrote: DM I'm sure this is an easy fix, but how do you either prevent users from being DM able to input in a field or make it so that it doesn't affect the code? Assuming you mean the double quote marks, and not a blank space, use the function htmlspecialchars() to convert the double quotes into PHP and SQL friendly HTML entities. -- Best regards, Richardmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] in a Variable
Try using htmlentities() to convert the characters to the html entities that can be stored and displayed. http://www.php.net/htmlentities Jason Dimitri Marshall wrote: Sorry, what I mean is... I have a field in a form where users input text. If the user inputs something like: Hi there, this is a quote and you should know it. Then only... Hi there, get's inserted because of the double quotes. Is that more clear? Dimitri Marshall Chris Shiflett [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] --- Dimitri Marshall [EMAIL PROTECTED] wrote: how do you either prevent users from being able to input in a field or make it so that it doesn't affect the code? Can you give an example of affecting the code? You can store spaces in variables just fine. Chris = Chris Shiflett - http://shiflett.org/ PHP Security Handbook Coming mid-2004 HTTP Developer's Handbook http://httphandbook.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Unicode translation
Yeah, i had a similar problem, i dont know if its the same, but i found that adding meta http-equiv=content-type content=text/html; charset=UTF-8 in the head of the html output fixed it Luke - Original Message - From: Louie Miranda [EMAIL PROTECTED] Newsgroups: php.general To: [EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 2:09 PM Subject: Unicode translation Guys, A problem arised on my application when a user enters a Unicode format code on the site. Well, we really catch every information and i really need to get some explanation about it. ex: C = U+0108: Latin Capital Letter C With Circumflex Now this unicode character does not have any keystroke on my computer, i only have Character Map (Windows) to generate this. On my php form i can type this clearly, but once preview it changes the character to Í or something similar (I guess). But when i used a Unicode character that has a keystroke value ë for example once preview it generates the correct character. Any bright ideas on this? -- - Louie Miranda http://www.axishift.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Unicode translation
Luke wrote: Yeah, i had a similar problem, i dont know if its the same, but i found that adding meta http-equiv=content-type content=text/html; charset=UTF-8 in the head of the html output fixed it Even better, use header('Content-Type: text/html; charset=UTF-8') at the beginning of your PHP page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: reload farmes
i use echo SCRIPT language=\JavaScript\\n; echo javascript:top.location.href='{$placetogo}';\n; echo /SCRIPT; and if you want to refresh a specific frame, replace top in the script for the frame name -- Luke Christian Jancso [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi there I have some problems with PHP. I have a website with different frames where different actions take place. One frame needs a button (here: Delete) which: 1. reloads another frame 2. reloads itself The code looks like: if (isset($_POST['action'])) { if ($_POST['action'] == Delete) { $id = $_POST['absolute']; $activity = mysql_query(SELECT id FROM activity WHERE station = '$station'); $activity_fetch = mysql_fetch_array($activity); $delete_activity = mysql_query(DELETE FROM activity where id = '$id'); $update_stations = mysql_query(UPDATE stations set status = 1, timestatus = 0 where station = '$station'); header(Location: http://127.0.0.1/empty.php;); } } With HTML it is body onload=. But this doesn`t work here because I have sent the header already. Can anyone help me? TIA Christian -- NextNet IT Services Christian Jancso phone +41.1.210.33.44 facsimile +41.1.210.33.13 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Unicode translation
Does all unicode characters have an equivalent key-stroke? and in even different fonts? -- - Louie Miranda http://www.axishift.com - Original Message - From: Leif K-Brooks [EMAIL PROTECTED] To: Luke [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 11:52 AM Subject: Re: [PHP] Re: Unicode translation Luke wrote: Yeah, i had a similar problem, i dont know if its the same, but i found that adding meta http-equiv=content-type content=text/html; charset=UTF-8 in the head of the html output fixed it Even better, use header('Content-Type: text/html; charset=UTF-8') at the beginning of your PHP page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Virtual Directory Support
I have a new installation of PHP 4.1.2 and it appears I cannot run php scripts outside of apache root directory. I look at phpinfo() and I saw Virtual Directory Support is set to disabled. I'm suspecting this could me the problem, but I have not been able to find anything on google or the lists explaining how to enable this. Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Generate automatic list of dates
that should do it :) ? $first_date = 2003-12-01; $end_date = 2004-01-15; $ufirst = strtotime($first_date); $uend = strtotime($end_date); echo ufirst: . $ufirst; echo bruend: . $uend; while($ufirst = $uend){ //do other stuff here, insert into database etc $ufirst = strtotime(+1 day, $ufirst); $formatted = date(d/m/Y, $ufirst); echo brufirst: . $ufirst . : . $formatted; } ? --- Luke Tommi Virtanen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi! $first_date = 2003-12-01 $end_date = 2004-01-15 while ( $first_date = $end_date) { $sql = INSERT INTO time_table (id, date, person_id) VALUES (35,$first_date,0); $result = mysql_query($sql, $conn); [next date] WHAT CODE TO HERE } eg. first insert row is 35, 2003-12-01,0 next should be 35,2003-12-02,0 etc ... and last 35,2004-01-15,0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Unicode translation
no, but on windows, you should be able to access most of them (depending on the font) by using ALT+(number pad code) eg ALT+(num pad)0169 gives you - © Luke -- Luke Louie Miranda [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Does all unicode characters have an equivalent key-stroke? and in even different fonts? -- - Louie Miranda http://www.axishift.com - Original Message - From: Leif K-Brooks [EMAIL PROTECTED] To: Luke [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, December 03, 2003 11:52 AM Subject: Re: [PHP] Re: Unicode translation Luke wrote: Yeah, i had a similar problem, i dont know if its the same, but i found that adding meta http-equiv=content-type content=text/html; charset=UTF-8 in the head of the html output fixed it Even better, use header('Content-Type: text/html; charset=UTF-8') at the beginning of your PHP page. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Unicode translation
Yes, i just learned that windows uses a decimal code and there is a hex value too. Well, since some unicode characters dont have a decimal value, its really getting harder to solve this kind of problems. :( -- - Louie Miranda http://www.axishift.com - Original Message - Luke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] no, but on windows, you should be able to access most of them (depending on the font) by using ALT+(number pad code) eg ALT+(num pad)0169 gives you - © Luke -- Luke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] refresh data
At the moment this code accepts changes and deletes from the Db but when the submit button is pressed it echos- 'Record updated/edited' and i have to go back and refresh to view the updated list, how can i just have it refresh. When you open the file it shows the list but when editing it disappears. html ?php $db = mysql_connect(localhost, root); mysql_select_db(mydb,$db); if ($submit) { // here if no ID then adding else we're editing if ($id) { $sql = UPDATE employees SET first='$first',last='$last' WHERE id=$id; } else { $sql = INSERT INTO employees (first,last) VALUES ('$first','$last'); } // run SQL against the DB $result = mysql_query($sql); echo Record updated/edited!p; } elseif ($delete) { // delete a record $sql = DELETE FROM employees WHERE id=$id; $result = mysql_query($sql); echo $sql Record deleted!p; } else { // this part happens if we don't press submit if (!$id) { // print the list if there is not editing $result = mysql_query(SELECT * FROM employees,$db); while ($myrow = mysql_fetch_array($result)) { printf(ahref=\%s?id=%s\%s- V - %s../a\n, $PHP_SELF, $myrow[id], $myrow[first],$myrow[last]); printf(a href=\%s?id=%sdelete=yes\(DELETE)/abr, $PHP_SELF, $myrow[id]); } } ? P br P form method=post action=?php echo $PHP_self? ?php if ($id) { ? input type=hidden name=id value=?php echo $id ? ?php } ? Team A:input type=Text name=first value=?php echo $first? brbr Team B:input type=Text name=last value=?php echo $last ?brbr input type=Submit name=submit value=Enter Team Names /form ?php } ? /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] refresh data
Hello BigMark, Wednesday, December 3, 2003, 6:04:03 AM, you wrote: B At the moment this code accepts changes and deletes from the Db but when the B submit button is pressed it echos- 'Record updated/edited' and i B have to go back and refresh to view the updated list, how can i just have it B refresh. When you open the file it shows the list but when editing it B disappears. The problem is that you're only printing the list if there has been no editing of the database, when in actual fact you want to print the list regardless. Why not just remove this part? // this part happens if we don't press submit if (!$id) { -- Best regards, Richardmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Unicode translation
I'm not quite following this and I'm not sure what exactly you're having a problem with, but I'll try to explain some stuff that it looks like will help. Unicode(UTF-8) is a variable multi-byte format. Each character is represented by 1 to 4 bytes, UTF-8 character number 0x108(264) happens to require 2 bytes. So, if anything is trying to read UTF-8 characters with the rules for a single byte character set you will see the C Circumflex as two separate characters. UTF-8 should display fine on web page if you set the charset (like the previous emails incstructed you too) and the users OS supports UTF-8 (Windows 2000 and XP do, probably the recent flavors of linux as well). ISO-8859-1 (Which is the most prevalent character set on the internet) is single-byte. UTF-8 and ISO-8859-1 do share characters, Every character from 0x00(0) to 0x7f(127) in ISO-8859-1 is a single byte character in UTF-8, with the same nubmer. So if you are trying to display one of these characters in the other format, it will appear normal, while all UTF-8 characters 0x80(128) and above will be different and not display correctly. Are you just trying to store data to be able to retrieve it later? A block of text submitted to a webform maintains the character set of the webpage that submitted it (at least in my experience, there may be some exceptions to this though it is dependant on the browser). So you shouldn't have any problems displaying the data if the character set on the submitting page and displaying page are identical. If a character doesn't fall into a particular character set, there is no way to store it. UTF-8 is a good catch all because it can handle just about any character out there. Plenty of information about Unicode can be found here: http://www.unicode.org/ Chris -Original Message- From: Louie Miranda [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 9:21 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] Re: Unicode translation Yes, i just learned that windows uses a decimal code and there is a hex value too. Well, since some unicode characters dont have a decimal value, its really getting harder to solve this kind of problems. :( -- - Louie Miranda http://www.axishift.com - Original Message - Luke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] no, but on windows, you should be able to access most of them (depending on the font) by using ALT+(number pad code) eg ALT+(num pad)0169 gives you - © Luke -- Luke -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: refresh data
Nope that didnt work! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditional anchor href value
Chris Shiflett wrote: --- Eric Blanpied [EMAIL PROTECTED] wrote: Still the js approach has been closest to what we need: the php script puts all the possible links from that card into the page, and then the js function uses the correct one. Does anyone have any advice? Let PHP choose the correct one? Maybe something like this will work: a href=foo.php?bar=? echo $bar; ?Click here/a Then, you can let PHP choose what the appropriate value of bar should be. The trouble is that the value of $bar is dependent on the value of a select list. And, as noted in my original post, the hrefs for the pages need to end up being nice, static URLs which cleanly point to the correct data. -e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conditional anchor href value
Martin Towell wrote: you might be able to put the id of the next/prev card as the value of the option and then use javascript to generate the url. the only reliance then would be that the browser as JS enabled, as the above should be possible with the most basic of JS That's not all that different from what I'm doing. The following gets called from the left arrow graphic: function getLinkLeft(form) { var prevDate= ?php echo \$prevDate\; ?; var prevSrce= ?php echo \$prevSrce\; ?; if (form.setarrows.value == date) { location=prevDate; } else { location=prevResults; } } ... a href=javascript:getLinkLeft(self)img src=arrow.gif/a I know next-to-no javascript, so this has all been cobbled together via an afternoon's research. It appears to be what _should_ work, but it only behaves in one browser out of six I've tried (Safari). I'd just as soon ditch the JS, since I don't want to rely on it being enabled for this site. I just can't think of a server-side approach. -e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php