Re: [PHP] Question About Blocking Email Addresses in Forms
Javier Huerta wrote: I am wondering if there is a way to block out email addresses in specific format from a form? We ahve a form that people have to enter an email address, and the form has been getting used by bots to send spam to a listserv. The email address they enter is in this type of format [EMAIL PROTECTED], and of course it is always just a bit different every time. Any help is greatly appreciated. http://en.wikipedia.org/wiki/Captcha HTH, cheers! Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DESC order results
$query = 'SELECT * FROM eChart WHERE clientNo = "2" ORDER BY ChartNo DESC'; If you want just one record: $query = 'SELECT * FROM eChart WHERE clientNo = "2" ORDER BY ChartNo DESC LIMIT 0, 1'; BTW, you'd better ask the MySQL mlist: http://lists.mysql.com/ HTH, cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql date question
Uhm, a shot in the dark - try: select date_format(contract.length_start, '%m-%d-%Y') as length_start HTH, cheers! Silvio Adam Williams wrote: I have a field in mysql as shown by describe contract; | length_start | date| YES | | NULL || Which stores it in the mysql format of -MM-DD. However, I need the output of my select statement to show it in MM-DD- format. I can select it to see the date in the field: select length_start from contract where user_id = 1; +--+ | length_start | +--+ | 2006-01-12 | +--+ 1 row in set (0.00 sec) so then I do my date_format() select statement, but it returns a NULL value. Why? select date_format('contract.length_start', '%m-%d-%Y') as length_start from contract where user_id = 1; +--+ | length_start | +--+ | NULL | +--+ 1 row in set, 1 warning (0.00 sec) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Comparison Problems with 5.2.5
Magnus Anderson wrote: ...snip... This will not work (I expect this to work since _USER['level'] is 5) if($_USER['level'] => 5) Try if($_USER['level'] >= 5) maybe it helps ('=>' is used when assigning values in an hash, maybe you are triggering something strange...) -- Antinori and Partners - http://www.antinoriandpartners.com Soluzioni web - da professionisti -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] is_prefix() - checking wheather $A is prefix for $B
You should benchmark and tell us - anyway, just looking at the code, I'd say 'is_prefix2()' is faster since there's 1 function call instead of 2 AmirBehzad Eslami wrote: In case you haven't realized it, I have already written two functions to check for a prefix !! The question is: Which function is better? (is_prefix1() or is_prefix2()) On 12/29/07, Zoltán Németh <[EMAIL PROTECTED]> wrote: 2007. 12. 29, szombat keltezéssel 13.39-kor AmirBehzad Eslami ezt írta: I want to write a function to check whether string $A is a prefix for string $B or not. if (strpos($B, $A) === 0) { echo '$B begins with $A'; } else { echo '$B does not begin with $A'; } greets Zoltán Németh I writing this function in order to prevent directory traversal during a download request. (e.g., download.php?file=..\index.php) I want to make sure that the realpath() of the requested file is within the realpath() of the download-directory. Trying to make sure that the the $download_dir is a prefix for $filepath. @see: http://en.wikipedia.org/wiki/Directory_traversal ** *TWO FUNCTIONS:* function is_prefix1($prefix, $str) { return (0 == strncasecmp($prefix, $str, strlen($prefix))); } function is_prefix2($prefix, $str) { return (0 === stripos($str, $prefix)); } *USAGE:* if (is_prefix1('a', 'abcdef')) echo 'prefix1 returned True!', ''; if (is_prefix2('a', 'abcdef')) echo 'prefix2 returned True!', ''; Do these functions do the same job? Which one provides better performance? -behzad -- Antinori and Partners - http://www.antinoriandpartners.com PHP solutions - in Italy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Getting The Document Root
Jeremy Privett wrote: I'm looking for a method that would be able to extract the user's true document root (e.g. /home/jeremy/public_html/) so that I can use it for some filesystem scanning functions. I'm trying to avoid hard-coding supported document roots in favor of being able to dynamically detect it, but nothing is coming to mind. I thought I would consult some of the minds of the mailing list for advice. Any ideas or code would be greatly appreciated. You can try with __FILE__ http://php.net/manual/en/language.constants.predefined.php";> The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path whereas in older versions it contained relative path under some circumstances. and then use 'dirname()' http://php.net/manual/en/function.dirname.php Ciao! Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP hosting with multiple domains?
[EMAIL PROTECTED] wrote: hah.. I'll stop now. Think you get the idea. The convenient management of multiple domains with a hosting provider is my ultimate goal. Go with http://www.hub.org I've got a couple of domains with them - and I think they are great. Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular expression
Barry wrote: Simple reg help please i want to match the last "," in "a,b,c,d" and replace it with " and " Without using a regexp, you could do: $string = 'a,b,c,d'; $letters = explode(',', $string); $last_letter = array_pop($letters); $final_string = implode(',', $letters) . ' and ' . $last_letter; Not very efficient - but should work... Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 Backwards Compatability
Tod Thomas wrote: Is their a list of portability problems to be aware of when switching from v4 to v5? Maybe a table that compares the two? Thanks. You can start here: http://www.zend.com/php5/migration.php Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I get ENUM values from column info?
[EMAIL PROTECTED] wrote: If I have columns type ENUM('live', 'hidden', 'pending'), $flags will show ONLY 'enum'. How can I get all ENUM values? Thanks for any help or direction. -afan This doesn't really seem a PHP question... BUT... give a look here: http://dev.mysql.com/doc/refman/5.0/en/enum.html There is one user comment ('Posted by J. Santiago Scarfo on March 31 2005 7:16pm') that I think can help you. Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] query problem.
Angelo Zanetti wrote: (...) Why does the < > cause that not to be displayed? or is it retrieving it correctly but not showing it because of the < > (which might be conflicting with HTML tags? When showing things in an HTML page it's always a good idea to use 'htmlspecialchars' (or htmlentities) first http://php.net/manual/en/function.htmlspecialchars.php http://php.net/manual/en/function.htmlentities.php HTH, ciao! Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: hiding the index.php page.
Barry wrote: Gregory Machin wrote: Hi I would like to know how i would hide my index page so that it is not shown at the end of the url like how gmail does it and many cms do it .. And what is it called when one does this .. Thank you If you use Apache, what you are looking for is probably the 'DirectoryIndex' directive: http://httpd.apache.org/docs/2.0/mod/mod_dir.html#directoryindex But it could also be that you mean something that needs 'mod_rewrite', in this case I guess it's better if you search the archives: http://marc.theaimsgroup.com/?l=php-general&w=2&r=1&s=mod_rewrite&q=b HTH! Ciao, Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting list of files included
Diana Castillo wrote: does anyone know of a command in php that will give you a list of the files already included . Something that would tell you whether a file is already included before you do the require_once ? Try this: http://php.net/manual/en/function.get-included-files.php Oh, and maybe next time try to RTFM... :-) Cheers! Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] adding script
Ross wrote: This was a page I did ages ago http://www.ecurry.net/menu2.php The problem with it is when you add or subtact an item is it always button press behind. This must be because of the way the page self submits or something? The script is here http://www.ecurry.net/calculate.phps This is ok when I put it in an iframe it updates on every click. http://www.ecurry.net/menu.php This is the ideal situation for an AJAX solution: http://en.wikipedia.org/wiki/AJAX http://marc.theaimsgroup.com/?l=php-general&m=112198633625636&w=2 Ciao Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date("H", $datevalue) always adds an hour?
David Grant wrote: Murray, I can't think what else it might be. Sorry! David What does date("I", $datevalue) return? (it's a capital 'i') I guess you already checked out this page... http://php.net/date -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] input validation?
William Stokes wrote: > Hello, > > I need to check that user input text is less than 300 characters long. How? > > Thanks > -Will > Try with strlen: http://php.net/strlen Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fopen/fwrite and owner/group settings
Mathijs wrote: > Hello there, > > I Have a problem with some file writeing. > > I Use fopen to create a new file, but that file gets the owner and group > the same as the apache owner and group. > > How can i change it so that the file gets the same owner/group as the > files i upload with FTP? > > Thx in advanced > You can use FTP functions to create the file (for example 'ftp_put') http://php.net/ftp HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Access Client IP address
Nilanjan Dasgupta wrote: > Hi, > Is there any way to client's IP address inside a php document. I am > trying to generate a code that depends on the IP address of the client. > > thanks a lot, > Nilanjan > Give a look at $_SERVER, and more specifically $_SERVER["REMOTE_ADDR"] http://php.net/manual/en/reserved.variables.php#reserved.variables.server HTH, cheers. Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] forms
Mark wrote: > Hi can any one show me how make another form appear below another once the > 1st form has been submitted. > [not really a PHP solution...] You can do like this: the 'SUBMIT' button of the first form only makes visible the (hidden) DIV where the second form is, and only *that* 'SUBMIT' button actually submits the form. CSS reference: http://www.w3schools.com/css/css_reference.asp HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML Reader
[EMAIL PROTECTED] wrote: > Is there any easy php script to run to view an xml file such as new > headlines like so: http://news.google.com/?output=rss or can anyone point > me in the right direction for good online tutorials or books. > You can start here: http://magpierss.sourceforge.net/ Magpie RSS is a good RSS parser for PHP. HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Earlier versions hurt PHP 5
Anas Mughal wrote: > Here is a PHP5 hosting company: > http://www.a2hosting.com/ > Aaargh! I wouldn't suggest that one, I've had a really really bad experience with them (they shut down my site *w/o any notice* because they said I was using too much of their resources - while this was not true). I am now using hub.org (http://www.hub.org) and I find they have a really good service (and PHP5) -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Location ....
Christian Ista wrote: > Hello, > > Could you tell me a efficient solution for change page (new location) in > PHP? I tried this code : header("Location: mypage.php"); > note: HTTP/1.1 requires an absolute URI http://php.net/header > But in some case, I have error message "heade already send". Then I use a > javascript solution : window.location.href="mypage.php"; > > Is there a good solution in php ? > Check out 'headers_sent', you can choose how to redirect ('header' or JavaScript) depending on whether you have sent the headers or not. http://php.net/headers_sent HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mutiple file upload
Ross wrote: > Hi, > > I am trying create a multiple file upload to a mysql server. > Google is your friend... http://www.google.com/search?hl=en&q=multiple+upload+php&btnG=Google+Search And, by the way, if you are uploading and storing images in your MySQL DB, you might want to consider that there is a much better database for storing files. It's called 'filesystem'. HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gdf fonts
Adrian Bruce wrote: > Hi > > Does anyone know where i can get some decent gdf fonts for using in the > imageloadfont() function, i have found some on the net but they are all > a bit naf so far. I'm really just looking for something like Arial or > verdana. Im creating pie charts on the fly but at the moment they look > like something that would be produced by a spectrum or commodore 64! > > Thanks > Adrian > Try here: http://www.widgnet.com/gdf_fonts/ HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Filtering URLs problem..
Anders Norrbring wrote: > > I'm writing a filter/parsing function for texts entered by users, and > I've run into a problem... > What I'm trying to do is to parse URLs of different sorts, ftp, http, > mms, irc etc and format them as links, that part was real easy.. > You might want to consider using vbCode, there is a nice class for PHP here: http://www.phpclasses.org/browse/package/1379.html HTH, cheers. Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with fopen and sending POST vars
Barry wrote: > Hello everyone! > > I have a problem sending POST vars via fopen. > It was possible for me to send some xml data but that's all. > > Anyone know how to send POST vars? > Big probleme here is also that i have to connect via SSL. > cURL can be your friend... http://php.net/curl http://www.zend.com/pecl/tutorials/curl.php HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Passing $_POST values to a php script
Jay Blanchard wrote: > [snip] > I am trying to develop a testing framework for a bunch of php scripts. These > > files expect various kinds of data from the $_POST array. They work fine > when invoked from the browser. > > But I am wondering if I can programmatically pass these values so that I can > > stress test them in a systematic manner. > [/snip] > > You will probably want to use http://www.php.net/curl > You can also try the Apache benchmarking tool - ab [http://httpd.apache.org/docs/2.0/programs/ab.html] It can also do POST request (check the -p option) http://httpd.apache.org/docs/1.3/programs/ab.html> -p POST file A file containing data that the program will send to the Apache server in any HTTP POST requests. The contents of the file should look like name=value&something=other, with special characters URL encoded. HTH, cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [Bulk] Re: [PHP] PHP errors in Apache error logs
Jose Borquez wrote: > I installed PHP from the ports and did not do any configuration. I set > up the phpinfo page and the configuration line did not set disable session. > > Thanks in advance, > Jose > Maybe you have this: '--disable-all' (not sure, thou, this should enable sessions anyway, IIRC...) Maybe you could point us to your phpinfo(), it sure would help. Cheers Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random Images with no duplicates?
Silvio Porcellana [tradeOver] wrote: > > > $file = "images.txt"; > $openFile = file($file); > $num_images = 10; > # don't need this is PHP > 4.2.0 > srand((float) microtime() * 1000); > $random_keys = array_rand($openFile, $num_images); > foreach ($random_keys as $random_key) { > echo " width='100'>"; ops, sorry, that obviously should be: echo ""; > } > Sorry about this! Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Random Images with no duplicates?
Jared Williams wrote: > Hi, > Just unset the ones you've picked > > #random images example > #this is your file > $file = "images.txt"; > #open the file > $openFile = file($file); > #generate a random number > srand((double)microtime()*100); > #get one of the entries in the file > for ($i = 0; $i < 10; ++$i) > { >$r = array_rand($openFile); >$random_image = $openFile[$r]; >echo ""; >unset($openFile[$r]); > } > ?> > > Jared > Sorry if I jump in late in this thread, but wouldn't this work? $file = "images.txt"; $openFile = file($file); $num_images = 10; # don't need this is PHP > 4.2.0 srand((float) microtime() * 1000); $random_keys = array_rand($openFile, $num_images); foreach ($random_keys as $random_key) { echo ""; } array_rand: http://php.net/array_rand Maybe I'm missing something... Anyway, cheers everybody! Silvio -- tradeOver | http://www.tradeover.net ...ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XSS via curl
Sandy Keathley wrote: > > Is there a way to detect that a script is being accessed by curl, and > not by a browser? ENV ($_SERVER) variables won't work, as > those can be forged. > Use a CAPTCHA test: http://en.wikipedia.org/wiki/Captcha HTH, cheers! Silvio -- tradeOver | http://www.tradeover.net ready to become the King of the World? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with logic :(
[EMAIL PROTECTED] wrote: > > include ("../utils.inc"); > > $date = date("U"); > $dateExpire = $date + 90 * 86400; > > $code = "jack"; > > $query = "INSERT INTO CouponTable VALUES > ('','$date','0','$code','preset','$dateExpire','3.75')"; > > $result = mysql_query($query); > > echo mysql_error($result); > > ?> > > This SHOULD error out but I'm getting the error instead. > > It's just a test page to test my logic... > If you read carefully this page: http://php.net/mysql_error you will notice that it says that you need to pass to mysql_error *the MySQL connection*. Not the resource returned by mysql_query. HTH, cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Run a php script as a separate thread/process
Tommy Jensehaugen wrote: > > > > The reason why I want to do this is because separate_script.php has to be > fully executed even if the request for example.php is stopped in the middle > of "more logic". > I am using PHP Version 4.3.11. > You might also want to give a look at this: http://php.net/manual/en/function.ignore-user-abort.php HTH, cheers. Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Handling competing edits in a wiki engine?
Murray @ PlanetThoughtful wrote: > > Out of curiosity, does anyone know if it's possible to tell whether an > individual session is still alive from PHP? I don't mean from within > code being run for a particular user, but in code that, for example, > might be executed by a cron job, which would examine a table in which > session ids have been recorded automatically for each visitor, and > determining which of those sessions are still theoretically alive? I > suspect this isn't possible, but I've also learned to never > underestimate the ingenuity of those faced with things that aren't > possible. > [Ok, I AM an AJAX fan] The problem with "normal" session management is that session data (timestamp etc.) gets updated only when and if the user does something: therefore, if he is reading an article and he doesn't click anywhere for 10 minutes, he still is on your site, but you "lose" him. An alternative approach is the AJAX [1] one: you set up a JavaScript 'setInterval' and call an "AJAX" function that makes a query to the PHP script that updates the session (with the current timestamp, user_id, whatever...) Ok, I don't know if this makes much sense, but you end up with a script that gets executed (without user interaction) every 'n' microseconds, so your session data is always up to date (at maximum, with a delay of 'n' * 2 microseconds). The bad side of this is that you have a script that gets executed quite often for every user visiting your pages: but, if you keep it minimal (a couple of queries) the overhead isn't that much and you get a *near-to-real* number of open sessions. I hope I made some sense: in any case feel free to ask, I just developed something like this for a web site I'm working on (but we're still in alpha), so if you want to see it in action, lemme know. Ciao! Silvio [1] http://en.wikipedia.org/wiki/AJAX -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Select from database
A.J. Brown wrote: > > [code] > $values = join(', ', $array); > $query = "SELECT * FROM client WHERE clientaccountmanager IN ('$values')" > [/code] > Actually this doesn't seem right, the join should be: $values = join("', '", $array); # notice the ' inside the " In addiction, I would (SQL)escape the values joined: supposing you are using MySQL, I'd do: $values = join("', '", array_map('mysql_real_escape_string', $array)); HTH, cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array - partical path to the array's path....
Scott Fletcher wrote: >What I want this to work instead is >[code] > $array = array(); > > $array['col1']['col2'] = "Test #1"; > $array['col3']['col2'] = "Test #2"; > > $prefix = "['col3']['col2']"; > > echo $array.$prefix; //Spitted out result as "Test #2"... >[/code] > > Try something like this: $var = "\$array".$prefix; eval("echo $var;"); HTH, cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pre global configuration
Jake Gardner wrote: > This is a stretch and I doubt you can do this very easily, but I was > wondering if there is a way to define behaviors that happen throughout > a script before execution for example if the OS is windows, all > strings are terminated with \r\n, if Linux, then \n without adding > addition ifs throughout the code. > I don't know if it may help you, but why don't you set a constant in a config file included by all your scripts to the CRLF value you want (if you want it dependant on the OS you can use http://php.net/php_uname) and then you append this constant to all your strings? Example: - config.inc.php: define('CRLF', ( strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? "\r\n" : "\n" ) ); - other_script.php require_once 'config.inc.php'; $string = 'Hi! My name is Pippo!' . CRLF; Or something like this... ;-) Cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] variable instant value
FSA wrote: > Hi all, i have a question :), i need to display the instant value of a > variable (think at a variable that stores the interface trafic at one > moment) in browser, without having to refresh browser. I was wondering > if i can do that with php (not perl, cgi, etc). > If i missed something in my description let me know and i will try to be > more clear. > > ty, Dave. Hey Dave It's the second time this week that I suggest the same approach to similar problems... Why don't you try the AJAX way? http://en.wikipedia.org/wiki/AJAX or search Google for 'ajax+php' HTH, cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql/php date functions..
Jim Moseby wrote: > > Hi Bruce! > > MySQL and PHP both have extensive built-in date functions that are clearly > documented and extraordinarily easy to use. For the vast majority of > situations, there is no need to manually write any custom date-handling > code. The decision to use MySQL or PHP to manipulate a date for a given > instance depends largely on the particulars of that situation. > > For instance, if you want to increment a MySQL date column by one day, it > would likely be better to use the MySQL date functions to do it, because to > use PHP, you have to read the date, manipulate it, then write it back, > whereas if you use a SQL statement, you can do it with one DB call. > > See: > http://www.php.net/datetime > http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html > > Cheers! > Just my 0.02 euros. When I need to use dates in PHP *and* MySQL I usually use the UNIX timestamp (seconds since the epoch, that is, the PHP http://php.net/time output). This way I can (quite) easily calculate date differences etc. (usually all the calculations are done in PHP, also when building SQL queries). As I said, just my 0.02 euros... Cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new ways to add an html body?
Ross wrote: >Hi, > >I am using php mailer and am trying to find a new way to make the html email >body instead of the old > > $mail_body = " src=\"my_logo3.gif\" width=\"100\" height=\"139\">"; > $mail_body .= ""; >$mail_body .= "sans-serif\">$mail_text "; >$mail_body .= ""; >$mail_body .= " > >Any good/innovative suggestions are welcome. > > > Not really innovative, but what about heredoc? $mail_body = << ... $mail_text ... EOT; http://php.net/types.string HTH, cheers! Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] selfreferencing script with output
Sabine wrote: > Thanks you very much Silvio, for your answer. > Yes, it seems to be complicated. Especially regarding the time I have > to do the programming for this part of my work. > Now I reduced the time the preparing of the mailtext needs and hope > for the moment that the servers time my script gets will be sufficient > for the task. > I have to check out the circumstances of the productive machine. > But I will surely have a closer look on the AJAX approach later. > Well yeah it sounds difficult at the beginning, but if you have time to study it a little bit this approach can be quite useful in your future projects (in some cases, in my opinion, it could be a much better solution than Flash...) Anyway, thinking about your current approach I guess it would be better of you let a background process (triggered by the user input or scheduled with cron - you can use free ones on the net, like http://hostedcron.com (never used it, thou)) do the mailing: what if your user hits 'Reload' while the script is sending the emails? All the emails get re-sent? Or if it hits the 'Stop' button? > Thanks again and have a nice sunday > Sabine > You too! ;-) Cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] selfreferencing script with output
Sabine wrote: > Thanks for your answer, Gustav, > > now I see I didn't explain good enough what my problem is. > My problem is not how to construct a status bar, but not it is > possible to provide any output before the headering (*Warning*: Cannot > modify header information - headers already sent by). Neither after it. > > Best regards > Sabine > > P.S.: I played around with PEARs HTML_Progress. It's really worth > trying. The user doc on Laurent Lavilles page provides a lot of > explanation and examples. > (http://pear.laurent-laville.org/HTML_Progress/). > Hi Sabine why don't you try an AJAX approach? (Kinda like GMail and stuff like that?) You can create a DIV in your page that contains the *output* (maybe an image with the width set to the percentage of mails sent): the content of this DIV is updated by another script (the one that sends the email) that gets called (via JavaScript) at specific intervals with a specific query (in your case, the messages to send). This way your main page never gets reloaded and you see a nice progress bar in your DIV. I know it sounds a bit difficult, but it's a cool "technology" and after the initial difficulties it can be really useful. As a start, have a read here: http://en.wikipedia.org/wiki/AJAX HTH, cheers! Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Connecting To Multiple MySQL Databases
Richard Lynch wrote: > > Actually, you want a few SPARE MySQL connections, so you can use the mysql command line monitor to do things -- Particularly in case of a run-away PHP/MySQL script which slams the server into over-drive... If you don't have a connection available cuz they're all used up by Apache/_pconnect, you can't log into mysql monitor and you can't use mysqladmin to bring it down nicely and... Don't do that. :-) > Actually, MySQL already takes care of that as it allows 'max_connections + 1' clients to connect, leaving the '+1' connection for the user(s) with SUPER privilege (that can therefore issue a "SHOW PROCESSLIST" or nicely bring down the server). http://dev.mysql.com/doc/mysql/en/too-many-connections.html Back to lurking, cheers everybody. Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple permisions, different sessions.
Hi Pablo it really depends on what you want to do. I mean, if you want a hierarchy of users (like: guest, normal, administrator, root) or you wnat to limit certain users to an "area" of your site and certain others to another area (no hierarchy here, just "fences"). Anyway, in both cases I suggest you to check at the beginning of every script of the users is allowed on that page. What differs is *how* you decide if the user is allowed on the page: - for a hierarchy-based system, you could assing a number to every users (guest: 100; normal: 1000; administrator: 1; root: 10) and compare this number with the "access number" of your page (saying for example that your "orders.php" can only be accessed by users >= 1, so only administrators and root) - for "fences", what I would suggest is to create groups, assing users to these groups (based on what they can see) and then check at the top of your PHP page if the current user belongs to an allowed group. Obviously I made it quite simple here and there could be other "twists" to this thing (we are talking about a read-only system, but you could specify also "edit" permissions, kinda like the ones you have on files on Linux): anyway, I hope it helped a bit. Silvio Porcellana Pablo D Marotta wrote: Hi, I´m developing an intranet on Apache-PHP-Mssql. I need to know if there´s any way of managing users to have access to specific areas inside my site, and at the same time, managing other users, giving them permision to acces other areas only, because all of the codes and information I´ve found (at least for Windows), simply give permission "to acces" and pass the "login screen", but don´t limitate the users navigation priviledges. Thanks in advance! Paul from Argentina. American Express made the following annotations on 10/22/04 06:06:01 -- ** "This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you." ** == -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Copy
Chris Dowell wrote: Aidal Could you post the relevant parts of your code so we have a little context to work in? You say you're copying a file from one location to another on the same server. If this is the case you are very unlikely to be in need of the ftp family of functions, which are only valid for use over an established ftp connection. You can indeed establish an FTP connection to your local server - provided it has an FTP server running. The files are actually copied by Apache (or whatever Web server he's using), so this is why the server becomes the owner. I suspect that the file is indeed now owned by the webserver has it changed from aidal:somegroup to nobody:nogroup or something like that? I guess this is the problem Aidal is experiencing. In order to maintain file ownserships, what he can do (since he doesn't have PHP 5) is "copy" the file with 'ftp_fput()' [http://php.libero.it/manual/en/function.ftp-fput.php]. That is, he opens the files he wants to copy and PUTs it via this function. Since he is logged in - using 'ftp_connect()' and 'ftp_login()' - the files will be owned by the user he used to login. My .2 euros... Cheers, Silvio Porcellana -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] File Copy
Aidal wrote: Hi NG. I'm experiencing some problems when trying to copy a file from one location to another on the web server. example: dir1/subdir1/some_image_name.jpg --> dir2/subdir2/some_new_image_name.jpg When I do this the file permissions changes and I'm no longer the owner of the file. I tried to use chmod('the_new_file', 0777); but it doesn't work, because chmod() wont let me change the permissions since I'm not the owner of this new file. The owner should now be the user the Web server is running as. To change file ownerships you need to use the PHP FTP functions. Check out these pages: http://php.libero.it/manual/en/ref.ftp.php HTH, cheers! Silvio Porcellana -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] str_replace problem
Chris Ditty wrote: Hi all. I'm trying to do a little code snippets page for a site I am working on. I figured it would be simple enough. I would do a str_replace and replace the various html codes with the ascii eqivulant. Unfortunately, it is not working as expected. Can anyone help with this? What is that you are actually expecting? This is what I am using. $snippetCode = str_replace("\n", "", $snippet['snippetCode']); nl2br() [http://php.libero.it/manual/en/function.nl2br.php] $snippetCode = str_replace("<", ">", $snippetCode); $snippetCode = str_replace(">", "<", $snippetCode); $snippetCode = str_replace("&", "&", $snippetCode); This is what is in $snippet['snippetCode']. ?> This is what is showing on the web page. ?<>pre<>? print_r($ArrayName); ?<>/pre<>? This is what you are asking PHP to do. Actually - to achieve this - it would be better to use the 'htmlspecialchars()' function [http://php.libero.it/manual/en/function.htmlspecialchars.php] Anyway, probably I didn't understand what you want from your code... Cheers! Silvio Porcellana -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Add to regex help
Uhm, I guess you are looking for links (following a 'href') in your HTML page, so why don't you just do something like: preg_match_all('/href=[\"\']?([^\"\'>\s]*)[\"\']?/i', $url, $matches) (note the '\s' added inside the bracket that should match the link, as you could have: - that is, a link "terminated" by a white space) HTH, cheers! Silvio Mag wrote: Hi, Quite some time back I modified a regex (to the one below) to work with my script: if (preg_match_all('/ ]*)[\"\']?[^>]*>.*?<\/a>/i', $url, $matches)) { foreach($matches as $match){$links[] = $match;} } Problem is, I dont really know REGEXs properly and dont remember how I modified it and it completly ignores the below: because its a map and I guess it does not start with but I need to make sure it catches even the above... Can someone help me add to the above regex please? Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) ___ Do you Yahoo!? Declare Yourself - Register online to vote today! http://vote.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to create multiple selects within php
You can do something like this: - - choose one - - fff aaa . and then in your PHP: Anyway, you can catch this only *after* the form is submitted: in case you want to block the user from submitting the form if the 'foo' select is empty you need to use some javascript: <br> function check_form(form) {<br> if (form.foo.value == '') {<br> alert("C'mon!!!");<br> return false;<br> }<br> }<br> and in your HTML you need to add something like this to the tag: Anyway, this has more to do with HTML and JavaScript than PHP... HTH, cheers Silvio Porcellana bruce wrote: ok... it appears to be a case of user err.. the spec seems to state that if the user doesn't select/specify an item, the select should return the 1st item within the list... arrrgggh!! this is what's happening... so my question is still, how can i implement some logic that requires the user to actually select an item? or, how can i detect when a user has actually selected a list item?? thanks... -bruce -Original Message- From: bruce [mailto:[EMAIL PROTECTED] Sent: Monday, October 18, 2004 7:07 AM To: [EMAIL PROTECTED] Subject: [PHP] how to create multiple selects within php hi... i can create a form with a single select by something like: fff aaa however, i need to know how to create a multiple menu/list within a single form. i've tried a few different approaches, but i'm doing something wrong, in that the querystring is being populated with a value for the select list var even though i don't select the item. if someone can point me to an actual working example of php code that generates multiple lists/menus within a form, i'd appreciate it!! thanks -bruce ps. if needed, i can supply the actual test code i've used to create the condition i'm describing... -- 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] Searching My Database
I don't think this is the best list to ask questions about SQL, try http://lists.mysql.com Cheers! Silvio Porcellana Harlequin wrote: Morning everyone. I've read around the subject of searching and although using the FULLTEXT capability of MySQL might be the proper way of doing this I feel it's somewhat limited and have decided to use a simple select procedure. I'm sure there's a better way of doing this, as I'm quite new to MySQL and even newer to searches, However - here's my conundrum: I'm declaring variables at the top of my query like so: Code: $WorkPermit == '" . $_POST["WorkPermit"] . "'; And then execute the query like so: Code: SELECT * FROM MembersData WHERE `Work_Permit_Rqd` LIKE '$WorkPermit' But I have many other fields that the searcher can use. What do I do if they leave this field blank...? I appreciate that I should be using the MATCH function but I'm not entirely happy with the way it searches. What I need to do is actually omit a field (s) from the search if the value the searcher submitted was NULL. For example: Search field X and Y and Z and if x or Y are null continue... Am I explaining this OK...? Any suggestions gratefully received. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple pages of data.
You can solve it totally with SQL, using the FOUND_ROWS() function [http://dev.mysql.com/doc/mysql/en/Information_functions.html] I think this is the most efficient way of doing it... HTH, cheers Silvio Porcellana Nick Patsaros wrote: I'm trying to build a bulletin style system right now. I have topics and replies to each topic. If a topic gets more than 15 replies I want them to start carrying over onto page 2 and then 3 and so on with 15 replies per page. The key that I'm missing I guess is, how do I keep track of the last accessed row in the database? So if I run a LIMIT 15 I can go back and pick up where I left on previously? Using the primary key isn't going to help because if posts get deleted I would have less than 15 per page. Maybe I'm totally lost on this though, if someone could give me a bit of help on the most efficient way to accomplish this. --Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Setcookie doenn't work
> > $ok = setcookie("client_id", "argh", 259300); //* expire in a month ish > Nope, it expired a long time ago... :-) Read the manual for setcookie: http://php.libero.it/manual/en/function.setcookie.php (mainly the part about the "expire" parameter) HTH, cheers Silvio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Split haystack at nth occurrence of needle?
Hi if you want the *rest of the string from the nth *, I think 'preg_match_all' with PREG_OFFSET_CAPTURE can help you (see http://www.php.net/manual/en/function.preg-match-all.php) You could do something like: $string = "onetwothreefourfive"; $count = preg_match_all('/([^<]+)/', $string, $out, PREG_OFFSET_CAPTURE); and you will have an array of 2 arrays, where the first one contains the full pattern matches and the second one contains arrays for each string matched *and the starting offset* of that string. Therefore, to know where the 2nd ends (so we would get 'three') all you have to do is: $out[1][1][1] => 14 Just my .2 euros... Silvio Porcellana - Original Message - From: "Brian Dunning" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 22, 2004 5:54 PM Subject: [PHP] Split haystack at nth occurrence of needle? > I've been RTFMing for about an hour and I can't find a string function > to split haystack 'onetwothreefourfive' at the nth > occurrence of needle ''. strpos gives me the position of the first > needle, and strrpos gives me the position of the last needle. But I'm > looking for the position of one of the in-between needles, so that I > can use substr() to trim everything from there on. What very obvious > function was I unable to find in the manual? > > Thanks, > > - Brian > > -- > 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