Re: [PHP] Optional Vars in Functions
On Fri, Jan 02, 2004 at 01:20:50PM -0800, Chris wrote: : Jason Williard asked: : : Is there a way to make a variable of a function optional? : : http://www.php.net/functions More specifically: http://www.php.net/manual/en/functions.arguments.php e.g. function puke ($stuff = hairball) { echo puking .$stuff.\n; return; } puke(beer); // echoes puking beer puke(); // echoes puking hairball -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [posibleOT] Forcing entering te site thru index.php
On Sun, Dec 21, 2003 at 03:57:24PM -0300, Fernando M. Maresca wrote: : : Well, i'm trying to avoid access to the site for the middle. Say there : is a initial page with a form and other pages that depends on this. Is : there a way to force users access the site thru the initial form page, : regardless of the url? : Something like this: : lynx http://mysite/forma2.php/ : produce the browser to redirect to : http://mysite/index.php/ : : Of course, the forma2.php must be served if its accesed after index.php. There are several ways to do this. The most obvious is with cookies. Set up your index.php to initially create a cookie that authorizes a user to look in the site. On the rest of your PHP pages, check that this authorization cookie exists. If not, redirect to index.php. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [posibleOT] Forcing entering te site thru index.php
On Sun, Dec 21, 2003 at 04:11:36PM -0300, Fernando M. Maresca wrote: : On Sun, Dec 21, 2003 at 01:03:43PM -0600, Eugene Lee wrote: : On Sun, Dec 21, 2003 at 03:57:24PM -0300, Fernando M. Maresca wrote: : : : : Well, i'm trying to avoid access to the site for the middle. Say : : there is a initial page with a form and other pages that depends : : on this. Is there a way to force users access the site thru the : : initial form page, regardless of the url? : : Something like this: : : lynx http://mysite/forma2.php/ : : produce the browser to redirect to : : http://mysite/index.php/ : : : : Of course, the forma2.php must be served if its accesed after : : index.php. : : There are several ways to do this. The most obvious is with cookies. : Set up your index.php to initially create a cookie that authorizes a : user to look in the site. On the rest of your PHP pages, check that : this authorization cookie exists. If not, redirect to index.php. : : Thanks for the response. : No, this way don't do it: once the cookie is set up in the client's : browser, there is no way for me to prevent the client to type the url : pointing to another page, and the cookie will be valid on that page. : What i'm trying to do is to force the client to travel pages in the : order expected, forbidding him/her to access a page out of sequence, : wich take him to an error message (because, for example, for abscense : of POST data or something). : So i'm stuck. Not really. It depends on how you use your cookie. The cookie could be some unique ID to some session-based system (whether you use PHP session functions or not) that keeps a track of where the user is. So let's say the user did the right thing, went to index.php, got a cookie, and went to the next page (let's say forma1.php). Your session system notes that the user is currently on forma1.php. But the same user gets distracted, does not go through the form normally, leaves for a few hours, and then tries to return but jump directly to forma2.php. Your session system realizes that he's not supposed to be there, and kicks him out to whereever you want him. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [posibleOT] Forcing entering te site thru index.php
On Mon, Dec 22, 2003 at 01:09:37AM +0100, Andreas Magnusson wrote: : : You can use the Referer header found in $_SERVER['HTTP_REFERER'] to check : from which page the user comes from. Unfortunately, HTTP_REFERER is not guaranteed to exist. In fact, several Windoze firewall software actively block this information from being sent to the web server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Update issue - more then likely simple problem
On Thu, Dec 18, 2003 at 01:39:57PM +1100, Eric Holmstrom wrote: What im trying to do is read the information from a field in a table called PARTNO. Then add RU to the front of whatever is in the PARTNO field. So far i have this. //connect details rarara //query $query= SELECT PARTNO FROM russell2 ; Didn't you say the table was called PARTNO, not russell2? // make a query to get old stuff from DB col $oldstuff = mysql_query($query, $conn) or die(mysql_error()); while ($new = mysql_fetch_array($oldstuff)){ $final = $new['PARTNO']; //new infomation i want to add infront of PARTNO data $newstuff = 'RU'; //Combining the two resluts together $results = $newstuff.$final; // just use this to check it was going through properly print_r($resultsbr); } The problem i have to get it to update. If i add this (see below) inside the while statement it continually loops, and outside it doesnt work. $update = UPDATE rocket SET PARTNO = '$results''; mysql_query($update); I know the answer is simple but i seem to be stuck on it. I don't think you can just update a row that you just fetched within the same query. If you do this in PHP, you should split the update into a separate loop. Of course, it would be faster and more efficient to have MySQL do it for you: UPDATE rocket SET PARTNO = CONCAT('RU',PARTNO) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php special permissions
On Thu, Dec 18, 2003 at 12:24:21PM +, Mat Harris wrote: : : I am building a web interface to the vacation autoresponder program : on linux. : : I let users login, edit their message and enable the autoresponder. : : The last step (enabling) is where the fun begins because php is run : as apache on my box, and each users' .vacation.msg and .forward are : not owned by apache. : : So you say, ok lets make apache run as group 'vacation' and also : change the ownership on .vacation.msg and .forward. : : Well this makes sendmail cry out because it doesn't like having : group-writable .forward files. DontBlameSendmail http://www.sendmail.org/tips/DontBlameSendmail.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php special permissions
On Thu, Dec 18, 2003 at 12:52:14PM +, Mat Harris wrote: : On Thu, Dec 18, 2003 at 06:42:37 -0600, Eugene Lee wrote: : On Thu, Dec 18, 2003 at 12:24:21PM +, Mat Harris wrote: : : : : I am building a web interface to the vacation autoresponder program : : on linux. : : : : I let users login, edit their message and enable the autoresponder. : : : : The last step (enabling) is where the fun begins because php is run : : as apache on my box, and each users' .vacation.msg and .forward are : : not owned by apache. : : : : So you say, ok lets make apache run as group 'vacation' and also : : change the ownership on .vacation.msg and .forward. : : : : Well this makes sendmail cry out because it doesn't like having : : group-writable .forward files. : : DontBlameSendmail : : http://www.sendmail.org/tips/DontBlameSendmail.html : : Thanks for the reply but I have already tried the DontBlameSendmail options. : : Either the flags are ignored or I am using the wrong combination : (there are several flags I believe). If there is a good sequence for : those options then I would love to know. There are several more options listed in the URL. Two of them: GroupWritableForwardFile GroupWritableForwardFileSafe might look like they could address your specific issues. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Round() behaviour issue
On Tue, Dec 16, 2003 at 11:13:25AM +, Scott McDaid wrote: : : Hi there. I've been looking at the behaviour of the round functionality in : PHP. We're currently still using v4.2.3, (but the documentation seems to : suggest it's the same for versions after this). : : Doing the following rounds always rounds *up* to the nearest whole number. : i.e. : : 0.5 = 1 : 1.5 = 2 : 2.5 = 3 : 3.5 = 4 Any non-zero fractional component that gets rounded to the next whole number is done with ceil(). : In earlier PHP docs, it stated that halves would be rounded to the nearest : even number. : i.e. : : 3.5 = 4 : 4.5 = 4 I recall seeing those docs and getting very confused, especially with your listed example. Personally, I think the current behavior for round() is mathematically correct; i.e. any number whose fractional component is greater-than or equal-to 1/2 is rounded up to the next whole number, otherwise it's rounded down. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Opening large file problem - fopen
On Tue, Dec 16, 2003 at 01:30:14PM +0100, Kim Steinhaug wrote: : : I found out that what the script accually does is choke on \n\n, : empty lines. I havnt found a way to solve this with the script, : : What I do now is use TextPad and just replace all occurencies : of \n\n with \n-\n or something and it works all nice. But this : is a bad way of doing it, since the script still doesnt accually work... You have two options: 1) massage your data beforehand so that your script works properly 2) buffer your input lines so that you process them only after you have read a complete entry, since one entry may span multiple lines in your error_log. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email problem
On Mon, Dec 15, 2003 at 12:05:54PM -0800, Naveen Glore wrote: : : I have freebsd server with apache, PHP and mysql. i wrote a simple PHP : program using mail(). The mail() function returns true without any : error. but the problem is the email is never delivered. I viewed the : log file for mail(/var/log/maillog) and i saw the following error: : : Server sendmail[351]:NOQUEUE:SYSERR(www):can not chdir(/var/spool/clientmqueue/): Permission denied. It's a Sendmail issue. Make sure that directory has the right permission and ownership settings. Mine looks like this: drwxrwx--- 2 smmsp smmsp68 11 Dec 07:17 /var/spool/clientmqueue -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Email problem
On Mon, Dec 15, 2003 at 12:58:17PM -0800, Naveen Glore wrote: : : thanks for the quick response. I have the same permissions as yours. : My email server is working fine, i use sendmail MTA and outlook MUA. I : am able to send emails and view my received emails in outlook through : my server. But I am having problem when i use mail() function in php : code. Email is never delievered. Hmmm, what about the permission and ownship of Sendmail itself? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg is failing on this simple test
On Fri, Dec 12, 2003 at 07:54:16PM -0800, Manuel Ochoa wrote: : : Why is this test failing? : : $data = A Simple test.; : If (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) { : echo Valid text; : } : else { : echo Not valid text; : } You can't use the character class \s within a range. And you need to escape a few special characters. The working version should be: $data = 'A Simple test.'; #if (ereg(^[a-zA-Z0-9\s.\-_']+$, $data)) if (ereg(^[a-zA-Z0-9[:space:]\.\-_']+$, $data)) { echo Valid text\n; } else { echo Not valid text\n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] enable_trans_sid problem
On Fri, Dec 12, 2003 at 09:49:29AM -0500, Ewald Geschwinde wrote: : : I have the following problem : : I have htmlcode like this: : form name=login method=post : /form : : and with this feature : it's printed out like this: : : form name=login method=postinput type=hidden name=SID : value=aa55e1a335a4d32af8b38953f077e18b / : /form : : The problem is the / at the end. : : Has anyone seen this before? : What can I do against it? It's an XHTML thing. Does it cause problems for you? Like what? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Evaluating a page in a different order
On Wed, Dec 03, 2003 at 11:42:09AM -, [EMAIL PROTECTED] wrote: : : I have a php page class that i use as a template for my website. Every : page in my website creates an instance of the class and passes values : like title and meta tag keywords. The class includes the layout from : different files e.g. title.lay contains the title and logo. : : In the top right hand corner of my page i have a login status, which : displays if the user is logged in or not. This is included as : loginstatus.lay by the class. : : If the page performs a php scripting function, it is included in the : main content area. This main content area comes after the : loginstatus.lay, so is evaluated afterwards. While this answer functioned, it was obviously fundamentally flawed... : My problem is when creating a logout page. The loginstatus is : displayed as logged in, but the main content area logouts out the : user. At last, the fundamental flaw is ultimately expressed. :-) : The reason i designed the class and page layout like this is because i : wanted to seperate the design and code as much as possible. As a : temporary solution i have added some code to loginstatus.lay, but this : is edging towards including code in the layout files which i dont : want. MVC-ish patterns are good. The problem you've encountered is that code in your main content area may do something that changes the output of entire page (or in your case the top portion of the page). You need to modify your app to first evaluate all code, let it reach its next state, and *then* generate the correct templated output based on the new state. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fastest loop code/best way to get database results into array
On Mon, Dec 01, 2003 at 03:24:35AM -0500, Robert Cummings wrote: : : On Mon, 2003-12-01 at 03:06, Galen wrote: : : I'm working on some code that deals with a LOT of results from a MySQL : database and drops them into an array. It deals with about 17,200 : results on a very fast box in about 0.5 seconds, which is not too bad, : until I realize I may need to call it on about that many results : several times in a page. : : Is there any way to speed things up? Change to a different loop type? : Some other technique for pulling the data out of the database faster? : My only requirement is that the array format remain unchanged (yes, : associative values are important). : : Here's the code, which seems awfully simple: : : for($i=0; $i $num_results; $i++) : { : $search_results[$i] = mysql_fetch_array($result, MYSQL_ASSOC); : } : : You might squeeze a little more speed by using the following: : : while( ($search_results[] = mysql_fetch_assoc( $result )) !== false ); : array_pop( $search_results ); For large query results, you might consider using mysql_unbuffered_query() and the while-loop instead of mysql_query() and the for-loop. Otherwise, if the PHP code is optimal enough, the other obvious place is to maybe optimize the query itself or that particular MySQL table. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file uploads
On Mon, Dec 01, 2003 at 02:00:34PM +, Jon Bennett wrote: : : Hi Chris, : : I think you're referring to this: : : $_FILES[image][tmp_name] : : In my class I pass this as a reference: : : $aArgs['Image'] = $_FILES[image]; : : Then, $aImage in my storeBigImage() method is passed the : $aArgs['Image'] when it's called: : : $this-storeBigImage($productID, $aArgs['Image']); : : All the image details are there because otherwise functions like : getimagesize would fail, it just won't save the resized or, if the : dimensions of the uploaded image aren't bigger than my max width and : height, original image, and I really have no idea why!! In your storeBigImage() method, what do you get if you do: print_r($aArgs); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Suggestions for optimization?
On Sat, Nov 29, 2003 at 09:32:19AM -0800, Galen wrote: : : I'm working on some database search ranking code. It currently : represents 95-98% of the time spent when doing fuzzy seaches. I have : tried my best to optimize my code - algorithmic shortcuts, eliminating : session variables, unsetting irrelevant results, etc and benchmarking : to find the best techniques. That's given me over a 10x improvement. : Unfortunately, because of the number of results it must process (up to : 20,000), it is still somewhat slow. I think it could use some code : structure/formating tweaks to eek out that last bit of performance, but : I don't know much about optimizing PHP code in that way. Does anybody : have suggestions? You should profile your code a bit more and see how much time getting spent in your foreach loops and your usort(). You could always rewrite your foreach loops into for loops and manually iterate through the array itself instead of a copy. And you use strtolower() and trim() on every pass through the data. That's a lot of work that can be pre-massaged in the database so that you don't need to do it within your loops (granted, this doubles your needed storage space in the hopes of speeding your fuzzy searches). Also, I noticed that your usort() was doing a normal numeric sort. That being the case, why not switch the line: usort($search_results, cmp); and use: sort($search_results, SORT_NUMERIC); : Here's my code: : : if ($search_results[0][relevancy] == ) : { : function cmp($a, $b) : { : if($a[relevancy] $b[relevancy]) : { : return 1; : } : elseif($a[relevancy] $b[relevancy]) : { : return -1; : } : else : { : return 0; : } : } : : $search_statements = $_SESSION[search][statements]; : : foreach($search_results as $key1 = $value1) : { : $num_fields_matched = 0; : $result_score = 0; : $metaphone_ratio = 0; : foreach($search_statements as $key = $value) : { : if ($value != AND $value1[$key] != $value) : { : $value = strtolower(trim($value)); : $value1[$key] = : strtolower(trim(($value1[$key]))); : $num_fields_matched++; : $value_metaphone = : metaphone($value1[$key]); : $search_metaphone = : metaphone($value); : $search_position = : strpos($value1[$key], $value); : $string_count = : substr_count($value1[$key], $value); : $levenshtein = levenshtein($value, : $value1[$key], 0.5, 1, 1); : : if ($search_metaphone == : $value_metaphone AND : $value_metaphone != ) : { : $metaphone_ratio = 1; : } : elseif ($search_metaphone != 0) : { : $metaphone_ratio = 0.6 * (1 : / : levenshtein($search_metaphone, $value_metaphone)); : } : : $result_score = $result_score + : ($levenshtein + (8 * $search_position)) - (2 * ($string_count - 1)) - (1.1 : * $metaphone_ratio * $levenshtein); : } : elseif ($value1[$key] == $value) : { : $result_score = $result_score - 5; : } : } : if ($num_fields_matched == 0) : { : $num_fields_matched = 1; : } :
Re: [PHP] How to see the table structure
On Sun, Nov 30, 2003 at 11:53:41PM +0530, narayanan wrote: : : BlankCan any body tell how to view the structure of a table from php. : I was thinking around for the past two days. I am using postgresql : database. From the command line psql monitor, do a \d tablename. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array problems
On Thu, Nov 27, 2003 at 08:19:02PM -0500, Curtis Maurand wrote: : On Wednesday 26 November 2003 21:53, Marek Kilimajer mumble: : Curtis Maurand wrote: : Sorry, its a typo. it should be: : : $city = Ipswitch; : $city_found = 0; : $contentfile = fopen(content.txt, r); : while (!feof($contentfile) $city_found == 0); : { : $my_line = fgets($contentfile, 16384); : $content_array = explode(\t,$my_line); : if ($content_array[0] == $city) :{ : $city_found = 1; : print(Matched on $content_aray[0]br\n); : : /* Break out of the while loop */ :break; : :} : } : print($content_array[0]\n); : : //end : : Is it me, or is that rather odd behavior? Shouldn't array elements : set within a loop be available to me outside the loop if the loop : exits normally? It should. However, you must be sure to take the right action if the loop exists unnormally. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular expressions
On Thu, Nov 27, 2003 at 01:20:57PM +0400, Sheni R. Meledath wrote: : : Could anybody help me to create a regular expression to remove a pattern : from a string. : : $querystring = http://10.100.1.7/cdms/prfl.phtml?action=searchcusttype=1gender=x=22y=10page=2 : : I would like to remove page=2 from this query string. The page number : changes. That is the reason why I want to use regular expression to replace : the variable value from the string. $qstring = preg_replace('/?page=\d*/i', '', $querystring); : Now I am using this option to remove the variable name only, so that it : will not collide with the variable value that is submitted again. Instead of using regexps on the URL, it might be easier (and safer) to loop through $_GET, build a new $geturl array, add/delete/change any variables in $geturl, then build a new $geturlstr string that can then be appended to your hyperlinks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Add Reply-To to this list(s)
On Wed, Nov 26, 2003 at 04:38:50PM +0900, Dave G wrote: : : I find the fact that the topic has come up multiple times in itself : indicative of what natural human expectations are. I find that M$ Outlook does a number of things that going against natural human expections. : On the lists I belong to where responses go only to the list, this : topic has never come up before. Some lists I have been on for years : and years, and I swear this is the first time I have ever encountered : this issue, here on this list which uses this system. I'm on several other lists, and this particular topic always pops up on an infrequent but regular basis. [...] : My opinion is that this is a multi person discussion forum, not a : person to person forum. - Thomas Svenson It would help if you provide attributes to these quotes. : I agree very strongly with this statement, and most of the email : that follows it. If someone posts a question, and gets a private email : solving the problem, how does everyone else benefit? The user who answers your question via a private email might have reasons to answer you privately. The fact is that the user chose to send an email to you and not the list. If you think the user was mistaken and wanted to answer your question on the list, then you are now questioning the choice and the intent of the user. Do you really want to guess the wildly different expectations of the user? I've seen several instances of people getting a private email in response to a list question who in turn respond to the private email and post to the *list* instead of a private email. Many people get offended when their private email response gets posted to a public list. Others respond by staunchly refusing private email feedback from other list members, and vehemently assert that all private email received from list members are considered public material. See how nasty this gets? In summary, there are several problems. Some don't know the difference between a private email response and a public mailing list response. This is solved by educating the end user. Another problem is that some mail clients fail to inform the user that a particular reply will go to a mailing list, to a person, on to both. This is solved with superior mail clients that lets the user know. This leads to another problem where some list members reply to both the mailing list and the original poster. However, the original poster may or may not want to receive two or more copies of the exact same message. This is solved by informing the possibly offending user that the reply, while good-intentioned, is too verbose and needs to be trimmed. The final problem is that some people have wildly different expections of proper netiquette regarding mailing list responses. And the answer? This is solved by reminding the end user of the list rules, that the list may be configured to obey those rules, and that all users should be obliged to work within those rules. : If you would stop using M$ Outlook and switch to a better mail : client... - Eugene Lee, just some random person : MS Outlook suffers from code bloat, but that does not mean it : does not successfully do the task that I acquired it for, which is to : receive, send, and filter my email, every day. And it has successfully : handled the many mailing lists I belong to, including this one. Blaming : the email client is just bias against brands. Let's look at the problem again: http://news.php.net/article.php?group=php.generalarticle=170904 http://news.php.net/article.php?group=php.generalarticle=170950 If M$ Outlook can handle the php-general mailing list, then the problem is that the solution is not easily accessible to those who need it. This is a documentation issue that should be addressed to those who maintain the PHP web site. If M$ Outlook cannot handle the php-general mailing list, then the problem is with M$ Outlook and the solution is to use a better mail client. This is a stubborn user issue. All other issues, see above. : Just to add an authoritative answer here. Mucking up the reply-to : header is simply wrong. I don't really care what arguments you come up : with... - Rasmus Lerdorf, not some random person, like the guy who invented PHP, is one of PHP's primary core developers, and other sweet nothings : This seems to describe the tone of the debate. The idea of an : authority on a matter that is incapable of considering alternate : viewpoints seems oxymoronic to me. You're asking to break correct standards and practices that have worked well for lots of people for a long time. Read the issues above. Some issues are with broken or misconfigured mail clients. Other issues are with people who don't understand or do understand but have different expectations of behavior. You claim that you understand...the theory behind the reply-to munging debate very well. And the topic of using the Reply-To: header to work
Re: [PHP] Could some one check my code
On Wed, Nov 26, 2003 at 11:23:19AM -, PAUL FERRIE wrote: : : i am getting this error returned but i dont know why :( : error: : : Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result : resource in /home/pferrie/public_html/vinrev/adm/insert2.php on line 6 : : php file : ?php : include(connection.php); : if(!empty($rating)){ : $query=SELECT * FROM $tablename WHERE rating = '$rating'; : if(mysql_query($query)) { : $myrow = mysql_fetch_array($query);// This line returns an error! mysql_query() might fail, in which case it returns a boolean FALSE. You should first check whether the query succeeded or failed. $result = mysql_query($query); if ($result === false) { // query failed, report the error echo mysql_error(); } else { // query succeeded, do your thing } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $ of variables, php, mysql
On Mon, Nov 24, 2003 at 09:42:30PM -0800, Joffrey Leevy wrote: : : Would appreciate in anyone can help me. Some more code would be helpful. : Let's say I do a query in php, eg. $query = select : shed from structure; With the mysql_fetch_array : function and a loop I could see all the values stored : in the column, shed, using the command: echo $shed; $query = select shed from structure; $result = mysql_query($query); while (($row = mysql_fetch_array($result)) !== false) { echo $row['shed']; } : Let's say now that I am carrying over a variable from : a form called $form where $form = shed. I can still : say $query = select $form from structure; because : $form = shed. Try using more variables to make life a little easier to parse: $colname = $_FORM['form'] $query = select {$colname} from structure; $result = mysql_query($query); while (($row = mysql_fetch_array($result)) !== false) { echo $row[$colname]; } : The problem I have now is with the strings and how do : I see my column values. Use better variable names. And avoid register_globals. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Add Reply-To to this list(s)
On Tue, Nov 25, 2003 at 04:57:41PM -, Thomas Svenson wrote: : : It would be nice if the moderator of this, and the other PHP-lists : could fix so the listserver automatically add a Reply-To header to all : the mails. : : When I hit Reply my message would then automatically reply to the list : and not the author. Less hassle for me when replying and less risk of : forgetting it. If you would stop using M$ Outlook and switch to a better mail client that supports mailing lists, your problem would be solved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $ of variables, php, mysql
On Tue, Nov 25, 2003 at 11:38:27AM +0100, Marek Kilimajer wrote: : Eugene Lee wrote: : : Try using more variables to make life a little easier to parse: : : $colname = $_FORM['form'] : $query = select {$colname} from structure; : $result = mysql_query($query); : while (($row = mysql_fetch_array($result)) !== false) : { : echo $row[$colname]; : } : : : Very dangerous. $colname can be anything, e.g. mysql.user.password : colname FROM mysql.user # I wrote it out this way because: the other user provided no source code, I wanted to show working code, it was late and I didn't feel like adding anything to secure against intrusions like SQL injection attacks. For the sake of completeness, redo the first line above as: $colname = mysql_escape_string($_FORM['form']); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Add Reply-To to this list(s)
On Wed, Nov 26, 2003 at 02:51:58AM +0900, Dave G wrote: : : Telling people that they need to use proper email software and go : about things in the way they don't expect is not a path to sensible : human interfaces. Computers, machines, systems, should match us, not : us to them. In any case, despite the difficulties, computers are much : easier to change than people. Composing email is a learned behavior. There is nothing intrinsically natural or sensible about it. If you learned something the wrong way, you can relearn it the right way. It's true that computer systems are designed around humanity's needs. But computers are still in their infancy and cannot tell the difference between a user making a wrong choice and a user purposefully making a choice that appears to be wrong. : I remain steadfast in my opinion that automatically replying to the : list is a much more natural option. Again, you're asking the computer to make a guess based on insufficient data. The headers from every php-general message contain information indicating that the email comes from a mailing list. When a mail client receives this email, it should be able to distinguish it as a list email instead of some other random email. If the mail client cannot perform this simple task, then it is up to the end user to do so, and to reply appropriately. If the user refuses to perform the task, the burden is on the user to properly configure the mail client or switch to a mail client that can do it. Don't tweak the content to work with your broken client software. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array problems
On Tue, Nov 25, 2003 at 03:45:11PM -0500, Curtis Maurand wrote: : : Hello, : consider the following code (content.txt is tab delimited). : : $city = Ipswitch; : $content = fopen(content.txt, r); : $city_found = 0; : while (!feof($content) $city_found == 0) : { : $my_line = fgets($content, r); : $content_array = explode(\t,$my_line); : if ($content_array == $city) : { : print(Matched on $content_array[0]); : $city_found = 1; : } : } : print($content_array[0]br\n); : : Here's the trouble. : : inside the while loop $content_array is available to me. : outside the loop $content_array is not available. What : am I doing wrong? Your if statement is wrong. You can't compare an array with a string. And your $content_array is not guaranteed to exist when it reaches your print() statement. You can test for existence with is_array(). But you already have this knowledge via your $city_found variable. Use it. Here's a revision (untested): $city = Ipswitch; $content = fopen(content.txt, r); $city_found = false; while (!feof($content)) { $my_line = fgets($content, r); $content_array = explode(\t,$my_line); if ($content_array[0] == $city) { print(Matched on $content_array[0]); $city_found = true; break; } } if ($city_found) { print($content_array[0]br\n); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Add Reply-To to this list(s)
On Tue, Nov 25, 2003 at 10:27:10PM -, Thomas Svenson wrote: : Eugene Lee suggested: : : If you would stop using M$ Outlook and switch to a better mail client : that supports mailing lists, your problem would be solved. : : I wouldn't mind that at all. What clients do you recommend for : WindwosXP? I want a small client (note: I have to use Outlook for : business purposes, but have the lists on a separate account). Personally, I use Mutt. It's a console-style mail client with roots in Unix, but it also run on Windoze via Cygwin and a SourceForget port: http://www.cygwin.com/ https://sourceforge.net/projects/unixmail-w32/ Have you tried other popular mail clients like those from Eudora or even Netscape/Mozilla? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML email enconding
On Mon, Nov 24, 2003 at 02:56:25PM +0530, Binay wrote: : : Is it necessary to encode the message using base64 or quoted-printable : format while sending the HTML email. Not always. Sometimes you can get away with only: Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit : What if i don't encode the message i.e (no Content-Transfer-Encoding : specified)? Does it impose some security vulnerabilities? These headers just provide more information to the mail client so that it can properly handle and display the message. Some mail clients may be more error-tolerant than others. But really you don't want your messages to be handled and displayed incorrectly. Just as your PHP code should generate HTML-compliant web pages, your code should also generate correctly format email messages. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML email enconding
On Mon, Nov 24, 2003 at 03:33:57PM +0530, Binay wrote: : : So does it mean that if i don't encode the message then no need of : specifying the Content-Transfer-Encoding?? : And almost all mail client will interpret it correctly?? No. If your HTML message is guaranteed to be in the ISO-8859-1 range (e.g. only Latin-based languages), then you could likely get away with just these two headers. But you still need to specify both of them. : Content-Type: text/html; charset=ISO-8859-1 : Content-Transfer-Encoding: 7bit You need to follow the various RFCs to generate correct messsages. If you don't have time for that, I suggest you look at existing classes like PEAR's Mail_Mime package that does much of the work for you: http://pear.php.net/package/Mail_Mime -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] A Tricky Time Calculation
On Sun, Nov 23, 2003 at 03:42:58PM -, Shaun wrote: : : Given the time range: 09:15 - 17:30 how can I tell how many 15 minute : intervals occur between these two times? Obviously here I can work it out, : but I need a calculation that will perform the maths for any two time : ranges... $time1 = '09:15'; $time2 = '17:30'; $intervals = floor((strtotime($time2) - strtotime($time1)) / 900); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form with browse for file to upload ftp
On Sat, Nov 22, 2003 at 08:18:30PM -, PAUL FERRIE wrote: : : Bronislav kluèka [EMAIL PROTECTED] wrote in message : news:[EMAIL PROTECTED] : : User executing the script (www-data or nobody or some other user) has to : vave the permission to wotk with this directory. : : eh? I think he meant to say: : The user executing the script (www-data or nobody or some other user) : has to have the permission to work with this directory. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] detaching and running php processes in the background
On Fri, Nov 21, 2003 at 03:40:05AM -0700, Gary C. New wrote: : : What is the best way to detach and run a command line based php script : in the background from a web-based php script, without the need for : reporting? How about exec('command ') ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Crossed paths?
On Fri, Nov 21, 2003 at 06:09:44AM -0500, MIKE YRABEDRA wrote: : : A customer of mine has recently started to see a weird error. He will get : the typical 'open_basedir' error, but it will say his allowed path is : another clients allowed path??? See an example below. : : Warning : Unknown(): open_basedir restriction in effect. : File(/Sites/thissite.com/www/forums/admin/template.php) is not within the : allowed path(s): (/sites/othersite.com) in Unknown on line 0 : : I set all my clients up with 'php_admin_value' parameters in their config : files. Each vhost is assigned their own directory. : : Any ideas? Where should I look to troubleshoot this one? The most obvious difference is /Sites vs. /sites. If your PHP server is using a case-sensitive filesystem, I'd check the whole uppercase-lowercase thing first. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] tar and ownership
On Fri, Nov 21, 2003 at 01:10:28PM -0500, Rodney Green wrote: : Marek Kilimajer wrote: : Rodney Green wrote: : : I'm writing a script that downloads a tarball from an FTP server and : unpacks it into a directory. Here's the line of code that does this. : : exec(tar -C /scripts/ -zxv --preserve-permissions -f . : /scripts/mailfiles.tar.gz) or die('Tar failed!'); : : My problem is that the files' ownership is changed when the tarball : is unpacked. I'm executing the script from a web browser and Apache : is running as the user apache so the files are unpacked and : ownership given to the user apache. How can I make it so the files : will keep the original ownerships? This is important because the : files are mail files and the script is used to restore the mail files : from backup so the users can access them. : : Only root can change file ownership. : :Thanks for replying. Any suggestions on how to do this then? sudo? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print
On Fri, Nov 21, 2003 at 07:55:05PM +0100, Wouter van Vliet wrote: : : (.. long bunch of HTML ..) : Jay asked ?=$Question?, then Tom said ? echo $Answer; ?. ?php I don't like this because it doesn't protect your content from being misinterpreted. It should be more like: Jay asked ?php echo htmlentities($Question); ?, then... Of course you could call htmlentities() on all of your variables in a previouw block. But then you cannot use the variables again unless you undo it with html_entity_decode(). It's a bit of a mess. Also, I find inlining to be less flexible and less extensible than some kind of template system. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: Prefilled forms (solved)
On Thu, Nov 20, 2003 at 11:22:02AM +0200, Veress Berci wrote: : : Scuse me, if I write some totally dumb thing. : I am quite new to PHP and programming, and maybe I'm not understanding : the question, but: : : What if you assign a value to every form field like this: : : input type=text name=something value=?php echo $something; ? : : or - safer, with register_globals off: : : input type=text name=something value=?php echo $_POST['something']; : ? Actually, you can do one more thing: input type=text name=something value=?php echo htmlentities($_POST['something']); ? : Again, please apologize, if i'm stupid. Ummm, what is the question? :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why is the php loop, 'for()', so slow????
On Thu, Nov 20, 2003 at 09:45:45AM -0500, Scott Fletcher wrote: : : I can give the strpos() a shot but I seem to have problem with getting the : strpos() to give me two seperate !CDATA[[]] tags instead of just hte : first one only... Use the offset parameter: ?php $haystack = 'To be or not to be.'; $needle = 'be'; $needlesize = strlen($needle); $pos = 0; while (($pos = strpos($haystack, $needle, $pos)) !== false) { echo '$pos = '.$pos.\n; $pos += $needlesize; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] echo or print
On Thu, Nov 20, 2003 at 12:36:42PM -0500, John W. Holmes wrote: : : Jay Fitzgerald wrote: : : when should i use echo ' '; vs. print ' '; : : You should always use echo. It'll make a significant performance : increase in your scripts as it's only four letters instead of five. p class=tonue-in-cheek Also, the letter 'e' is smaller than 'p', so ASCII-based function lookups will be faster as well. /p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prefilled forms (solved)
On Tue, Nov 18, 2003 at 06:00:12PM -0800, b b wrote: : : No I am saying that if you have: : input type name = w1 value = lkjlkjlj : input type ... name =w2 : : and you click submit then if you click back to see : the form the value you set w2 will be blank. If you : reverse the order however then you will see what you : entered in w2 This is a client caching issue and is beyond your control, unless you want to delve into the depths of JavaScript. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP or maybe JavaScript or CSS] protecting my PHP from bad input
On Wed, Nov 19, 2003 at 08:18:32AM +0100, Miroslav I. wrote: : : #The problem: : This is about protecting my PHP from bad input (e.g.: letters instead : of numbers). Good idea. You need to make sure user-inputted data is valid. : ## : Is there a way to prevent user from even inputting a letter in a text : box? There's two general ways to do data validation: client-side and server-side. PHP is server-side. JavaScript is client-side. With PHP, you allow the user to enter any data in the textbox, then code in logic to check for illegal characters (e.g. no letters in a textbox for one's phone number). Of course you must also code a nice response to let the user know when the data is found to be illegal, repost the form, etc. With JavaScript, you can do data validation as they press the submit button, or even disallow illegal characters as they type in a textbox. The response is far more immediate and thus far more effective, IMHO. Of course, if the user's web browser isn't running JavaScript, bad data may still slip through. Then you must use PHP and do server-side data validation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [PHP or maybe JavaScript or CSS] protecting my PHP from bad input
On Wed, Nov 19, 2003 at 10:21:16AM +0100, Miroslav I. wrote: : : I'm familiar with the concepts, but I've seen sites with textboxes : that would not show any letter typed - only numbers are displayed in : the textbox. This is what I like but don't know how to achieve. :-) Base on what I mentioned earlier, it sounds like you're looking for JavaScript-based data validation. Your best bet is to look at examples of JavaScript code. Here's a link to HotScript.com: http://www.hotscripts.com/JavaScript/Scripts_and_Programs/Forms/index.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why is the php loop, 'for()', so slow????
On Wed, Nov 19, 2003 at 03:10:39PM -0500, Scott Fletcher wrote: : : Why does the for() loop for PHP so slow when it is digesting a large : amount of data? Is there a way to make the loop go faster? Maybe it's your for() loop that's constructed in a less optimal way. Some source code would help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why is the php loop, 'for()', so slow????
On Wed, Nov 19, 2003 at 04:54:39PM -0500, Scott Fletcher wrote: : : Ray [EMAIL PROTECTED] wrote: : try : $res_str_len = strlen($res_str); : for ($i=1;$i$res_str_len;++$i) : : one less function call in the loop and the prefix version of ++ is : sometimes a tad faster then the postfix version. : : That's a great idea! Recently changed the code and the postfix of ++ to : prefix of ++. Still about the same... : : What so odd about this script is that I wrote it in Visual Basic for one of : the application. It took only a few seconds for a PC workstation (Pentium : 3 - Windows 2000). So, converting this code to PHP and place it on the Unix : Server (RS/6000) Webserver and it take way too long I tried it myself. The old code that calculated strlen() on each iteration took around 8.2 seconds. The new code that ran strlen() once and stored the results in a variable took around 5.6 seconds. However, the big problem with your code is that you manually iterate through every character of the string, then do your search for both ![CDATA[ and ]]. That's not an efficient search algorithm at all. Take a look at strpos() to get at least 1-2 orders of magnitude of speedup. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ereg_replace help
On Tue, Nov 18, 2003 at 04:37:52PM +1100, Martin Towell wrote: : : I have an array of strings in the following format: : abcd - rst : abcd - uvw : abcd - xyz : foobar - rst : blah - rst : googol - uvw : : What I want to do is strip everything from the - bit of the string to : the end, _but_ only for the strings that don't start with abcd : : I was thinking something like the following: : echo ereg_replace((!abcd) - xyz, \\1, $str).\n; : but obviously this doesn't work, otherwise I wouldn't be emailing the : list... You can't use ! because it's not a valid special character in regular expressions. It's really hard to craft do-not-match-this-word patterns. You're better off separating the two pieces of logic. $arr = array( abcd - rst, abcd - uvw, abcd - xyz, foobar - rst, blah - rst, googol - uvw ); reset($arr); while (list($key, $value) = each($arr)) { if (substr($value, 0, 5) != 'abcd ') { $arr[$key] = ereg_replace('^(.*) - .*$', '\1', $value); } } print_r($arr); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] .html extension PHP page be interpret
On Tue, Nov 18, 2003 at 10:46:48AM -, BennyYim wrote: : : I using WinXP + Apache 1.3.24 + PHP 4.3.3 : : My apache default will interpret .php extension file. (e.g. : index.php) : : If I have a PHP page, but I want to use .html file extension (e.g. index.html). : what I need to set to make those html extension page be interpret by server. : : I want those .html extension PHP page be interpret. Look for the following line in your Apache configuration file and change it thusly: AddType application/x-httpd-php .php .html See the online docs for more specifics: http://www.php.net/manual/en/install.apache.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sorting an array of regexes
On Tue, Nov 18, 2003 at 01:15:32PM +0100, Adam i Agnieszka Gasiorowski FNORD wrote: : : There is an array of regexes, for example : : $array = array('moon', '[wh]ood', '[^as]eed' ... : (about 300 entries). : : I want to sort it comparing to the : character lenght of a regex. For example : [wh]ood is 4 characters, moon is 4 characters. : There are only letters of the alphabet and : letter ranges present in those regexes. I : want the longest ones first. : : How would you write the sorting function? This might be the most functionally correct, although it's definitely not the fastest route. function re_len($pat) { return strlen(preg_replace('/\[[^]]+]/', '_', $pat)); } function re_sort($a_pat, $b_pat) { $a = re_len($a_pat); $b = re_len($b_pat); if ($a == $b) { return 0; } return ($a $b ) ? -1 : 1; } usort($array, 're_sort'); BTW, re_len() will bomb on certain oddball patterns with strange ranges. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sorting an array of regexes
On Tue, Nov 18, 2003 at 01:52:39PM +0100, Wouter van Vliet wrote: : Eugene Lee suggested: : On Tue, Nov 18, 2003 at 01:15:32PM +0100, Adam i Agnieszka : Gasiorowski FNORD wrote: : : : : There is an array of regexes, for example : : : : $array = array('moon', '[wh]ood', '[^as]eed' ... : : (about 300 entries). : : : : I want to sort it comparing to the : : character lenght of a regex. For example : : [wh]ood is 4 characters, moon is 4 characters. : : There are only letters of the alphabet and : : letter ranges present in those regexes. I : : want the longest ones first. : : : : How would you write the sorting function? : : This might be the most functionally correct, although it's definitely : not the fastest route. : : function re_len($pat) : { : return strlen(preg_replace('/\[[^]]+]/', '_', $pat)); : : I think you meant: : : /\[[^\]]+]/ : : as regex ;) Not sure, but I think one more block-bracked needed to be : escaped ;) Nope. My pattern is legitimate. Within a range, if the first character is a closing-square-bracket ']', it is treated as the literal character and not as the end of range. If the range starts with a negation '^', then the same rule applies to the second character. This is also a sad indication that I really know my regular expressions, or I need a vacation. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] window.open problem
On Tue, Nov 18, 2003 at 04:48:20PM +0200, David R wrote: : : I am using php and mysql and am having difficulty using window.open () . I : have cut the code down to the basics. : Why does a new window not open? : : html : script language=JavaScript : function boo() { : window.open (www.google.com); : } : /script : : head : body onload=boo() : why does no window open? : /body : /html 1. try window.open(http://www.google.com/;) 2. try onload='window.open(http://www.google.com/;);' 3. what browser are you using? 4. have you tried the same browser on other machines? 5. have you tried different browsers? 6. have you tried different browsers on other machines? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Prefilled forms
On Tue, Nov 18, 2003 at 01:24:23PM -0800, b b wrote: : : The Problem again: : I have a form, I fill it, click submit and then hit : back. Usually in other sites I see the data that I : attempted to submit. Forms originating from my site : are coming up blank. So what do you see if you put a print_r($_POST) in your form handler? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how to trap eval error?
On Tue, Nov 18, 2003 at 02:03:25PM -0800, david wrote: : : Cpt John W. Holmes wrote: : : From: david [EMAIL PROTECTED] : : if(function_exists($function)){ : eval('$return = $function($input);'); : }else{ : // function does not exists : } : : which works quit nicely for now. not sure if that's a good thing to do. : : Why not just do this: : : if(function_exists($function)) : { $return = $function($input); } : else : { //function does not exist; } : : because i didn't know PHP can do that. thanks for the tip! any differences : between the 2 version in turns of performance and safety? You don't have to invoke eval()), and you don't have to worry about quoting issues in eval(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP]{OT} Prefilled forms
On Tue, Nov 18, 2003 at 02:52:42PM -0800, b b wrote: : : Some people don't read carefully before responding. I : didn't say he sent me a private email!!! Anyway it : would be appropriate not to forget to take out the : email addresses other than the php-general... when : clicking reply-all. I just don't see how someone who : forgets and includes your address (so that you get : duplicate responses, 8 from this person so far) : complains that you replied to the wrong version. And : he does it in the general list. That is not right. I've run into this problem myself. It's really a matter of personal experience, learning as you go. Nowadays, when I respond to a public list posting via a private email, I usually prefix the message body with some descriptive blurb like This is a private message. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Microsoft .NET arguement
On Mon, Nov 17, 2003 at 11:06:37AM -0500, Mike R wrote: : : I have someone here at my desk arguing that Microsoft's .NET is better : than PHP - faster to process, easier and quicker to program, etc. : : They also (claim) that Microsoft's SQL is much faster and such vs. MySQL. Without real benchmarks, all claims on speed are just that: unsubstantiated claims. But one nice thing about .NET is that it provides a nice framework that is available at all times and is fairly optimized. It's like having PEAR installed automatically. And having your APIs consistently named also helps the developer to more easily remember the interfaces. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] rmdir withour rmdir function.
On Mon, Nov 17, 2003 at 09:37:52PM -0500, Vincent M. wrote: : : I can't use the function rmdir: : Warning: rmdir() has been disabled for security reasons : : But I do need to delete a directory with php. How can I do ? Is there : any way to delete an empty directory without using the rmdir function ? : : I tried to use the unlink function on the directory, but It does not : work, it only works for files... Sounds like your PHP host did a thorough job of securing themselves. If you can't do it, then you can't do it. Then it's a matter of talking to your PHP host's admin and convincing him that the feature you need is worth the effort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime bad logic or strtotime bug?
On Fri, Nov 14, 2003 at 08:53:41PM -0800, Gnik wrote: : : One of my servers required a PHP upgrade. Afterwards one of the PHP : projects stopped functioning. When it would run one section would : scroll endlessly. I can't figure out if it's a 'bug' or if it's bad : logic in the coding. Bad logic. But it took me a while to figure it out. I'm glad I did; I know it will save me countless headaches in the future! :-) : I isolated the problem to be in the 'strtotime' function. Here is a : test I ran - when it runs, after getting to 2003-10-26, it scrolls : incessently: : : BEGIN CODE-- : ?php : echo htmlheadtitleTesting strtotime /title/head; : print BR ; : $stop= 2003-12-27 ; : $start= 2003-01-01 ; : While ($start $stop) { : echo BR Date: . $start ; : $start = date('Y-m-d', strtotime($start) + 86400); : } : ? : END CODE-- It's a logic bug due to the wonderful world of Daylight Saving Time. When the clock strikes 2003-10-26, adding 86400 seconds to calculate the next day's timestamp is normally correct. However, that date is also the last Sunday of Octobor when the U.S. officially reverts from Daylight Saving Time back to normal time. Your next day's timestamp loses one hour, i.e. 3600 seconds; your timestamp for 2003-10-27 12am is now 2003-10-26 11pm. Because your date() call extracts only the date, your truncation error is causing you to get stuck on 2003-10-26. This is the cause of your infinite loop. There are several ways to avoid this problem. The easiest way to change date() to gmdate(). This gets you on UTC time, which is independent of Daylight Saving Time or your timezone. Hope this helps! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include an encoder into PHP distribution?
On Sat, Nov 15, 2003 at 07:52:28PM +0200, John Smith wrote: : : I have no connection to Turck MMcache in any way than just a user who needs : it. But distributing software encoded with it is difficult while it is not : so easily available (have to be separately downloaded and installed). I'm still having problems getting Turck MMcache to work on FreeBSD. It looks like the configure script is Linux-centric. That's a bit of a minus when it comes to distributing software across multiple platforms. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] auto_prepend/append in htaccess....
On Thu, Nov 13, 2003 at 11:32:34AM -0600, Jonathan Villa wrote: : : I want to prepend a configuration file which is located outside of my : document root into my scripts. I can use auto_prepend_file, but I'm not : sure how do it with an htaccess file or a virtual host entry.. I would : prefer VHost. : : Anyway, this is what I am trying/assuming... : : VirtualHost 127.0.0.1 127.0.0.1 : ServerAdmin [EMAIL PROTECTED] : DocumentRoot /var/www/testdomain/www : ServerName testdomain : ErrorLog logs/testdomain-error_log : CustomLog logs/testdomain-access_log combined : IfModule mod_php4.c : auto_prepend_file=header.inc : auto_append_file=footer.inc : /IfModule : /VirtualHost : : Is it possible to append/prepend more than file? I don't think this is possible with auto_prepend_file. : Or would be better : to simply include one file and in that file include the others. This sounds workable. : What should the file be relative to? Or should it be an absolute value? It can be a relative pathname, in which case PHP will search its defined include_path. Absolute pathnames should be okay too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why would this eregi() function not work?
On Fri, Nov 14, 2003 at 04:32:35PM +0900, Dave G wrote: : : ... escaping isn't necessary. : : Thanks so much for all the helpful advice! : Okay, included the + character, and removed the escaping. And I know I'm : supposed to checking into preg_match, but I'm looking at this as an : opportunity to learn about regular expressions, so I still have a : question. I'm confused why hyphens wouldn't still need escaping. Hyphens : are used to express a range of characters. If there's a hyphen there, : won't PHP think I'm looking for a range from nothing to nothing? Or is : it clever enough to figure out what's going on? : (!eregi('[EMAIL PROTECTED]', $email) The last part of your pattern needs to be changed because it allows for a top-level domain to contain numbers and hyphens. Currently, such a thing does not exist. Also, the 2nd part of your pattern allows for a 2nd-level domain to start and end with a hyphen, which is also disallowed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] date()
On Fri, Nov 14, 2003 at 10:51:57AM -0500, Chris Mach wrote: : : Does date() give the local time of the Server? or is it based on : something else? The server. : Because I have this code: : : echo date (F n, Y); : : and it should say November 14, 2003 but it echos November 11, 2003. : 3 days behind. : : Is the date wrong on the server? or is this something I can fix? Sounds like a server problem. Contact the server admin to be sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I license a php script?
On Fri, Nov 14, 2003 at 03:54:33PM -0800, Chris W. Parker wrote: : : Robert Cummings mailto:[EMAIL PROTECTED] : on Friday, November 14, 2003 1:34 PM said: : : Be careful though, if your code incorporates other peoples code, for : instance Smarty, or PEAR::DB then it may fall under their license. For : instance if your code depends and I believe the key here is depends, : on GPL code, then it falls under the GPL, even if you don't package : GPL code with it. Feel free to correct me if I'm wrong. : : Ok so let's assume this is true (which it sounds like it is). So if you : wanted to make a profit (or break even, whatever the case may be) you : wouldn't necessarily be able to charge for the software itself but you : *could* charge for support and stuff like that right? I guess that's : like what RedHat and other vendors do? Phase 1: write PHP scripts. Phase 2: Phase 3: profit! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] split()
On Wed, Nov 12, 2003 at 09:48:37PM -0600, erythros wrote: : : trying to use split(). i want to split a paragraph by sentence. so of course : i used split('[.!?]', $data). but then i noticed i use ... or every now : and again at the end of a sentence. i don't know how to do this though... How about preg_split('[.!?]+', $data) ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST bug?
On Thu, Nov 13, 2003 at 12:59:11AM -0500, Jake McHenry wrote: : : -Original Message- : From: Jake McHenry [mailto:[EMAIL PROTECTED] : Sent: Thursday, November 13, 2003 12:53 AM : To: [EMAIL PROTECTED] : Subject: [PHP] $_POST bug? : : I have 5 fields, all 1 character in length, numbers being : entered. If zero's are entered in the boxes, and the form is : submitted, the corresponding $_POST variables are empty? Is : there a way around this, or am I doing something wrong? : : I guess I could just do, if (isset(... Blah.. Then if it's : not set then manually set the variable name to 0... : : Just to test, I changed the input field length to 3, and every time I : tried it, single 0 does not create the $_POST variable. Double 0's : create it, along with any other numbers, it's only when a single 0 is : entered. Is this a bug or happening for a reason? In your form handler script, what does print_r($_POST) come out with? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Cannot bind to port 80
On Thu, Nov 13, 2003 at 01:11:43AM -0500, Teren wrote: : : Hi, I recently upgraded my box to php 4.3.4 and i copied the current : configure line and then ran it in the un-tared directory. I ran make, : then make install. I tried to restart apache and it wouldn't restart. : Any ideas? I tried the things that were on google but those didn't : work. The apache error log said it couldn't bind to port 80, but i'm : 100% sure it's the php upgrade problem, not apache. Thanks You cannot bind to port numbers below 1024 without being root. You must gain root access and then start Apache. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_POST bug?
On Thu, Nov 13, 2003 at 04:04:16AM -0500, Jake McHenry wrote: : : print_r($_POST) shows me that $_POST has the single 0 value. I solved : my problem, instead of having just if ($_POST['test']), I changed it : to if ($_POST['test'] != ). Right after I posted, I tried this, and : a couple other things.. The problem only happens when I don't have any : conditions within the (). That's due to PHP's automatic type conversion. In other words, certain string values can get evaluated to either a boolean TRUE or FALSE. So you have to do explicit tests. For example, what does this code snippet do? if ($_POST['test']) { do_right(); } else { do_wrong(); } If $_POST['test'] has an empty string, it calls do_wrong(). If $_POST['test'] has the string 0, it still calls do_wrong(). http://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting Your move to change your if-statement is a good start to doing the right thing. The next step is to scrub your $_POST data and make sure that it is valid. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] register_globals security
On Thu, Nov 13, 2003 at 01:55:08PM +0200, Fernando Melo wrote: : Jon Haworth responded: : : Fernando Melo wrote: : : : : I have a PHP application that passes variables (values) from a form. : : I get these using $_POST : : : : However I do also post some variables via a link. Which ofcourse : : requires register_globals to be ON. : : : : Do you mean variables in a URL, like this: : : www.example.com/index.php?foo=1bar=2 : : : : If so you can access these via the $_GET array and leave : : register_globals turned off. : : Thanks. : : I don't see how this makes it more secure though? : : The values are still picked up the same way from a URL If you want to prevent casual packet sniffing, you need to move your code to a SSL-enabled web server. If you want to minimize data exchange between PHP pages via POST or GET methods, consider switching to sessions. http://www.php.net/manual/en/ref.session.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] validate names with regex
On Wed, Nov 12, 2003 at 01:56:10PM -0800, Chris W. Parker wrote: : : Can someone post a function or regex that can validate names (first and : last)? The most important bit is that names like O'Malley and Hope-Jones : are not barred. The range of human names is so wide that there probably isn't a way to validate names. What part of one's name do you consider valid? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: ssh within PHP
On Mon, Nov 10, 2003 at 11:05:02PM -0800, tirumal b wrote: : : Its enough if i have the apache privileges. Can i : login to apache user and to remote computer apache : user with public key authentication and run some : command there. Usually, the user that Apache runs under does not have a real shell. And ssh by default (and for good security reasons) is configured to disallow logins for users that do not have a real shell. If you need a web-based method to run a program as a specific user, consider suexec: http://httpd.apache.org/docs/suexec.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Reset auto_increment field
On Tue, Nov 11, 2003 at 10:34:17AM +0100, Christian Ista wrote: : : It's not really a PHP question, sorry. : : How reset a MySQL auto_incrment field ? There are several suggestions in the User Comments of MySQL's online documentation. You should check them out. http://www.mysql.com/doc/en/example-AUTO_INCREMENT.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] location= Construct Doc
On Tue, Nov 11, 2003 at 01:46:33PM -0800, Mark wrote: : : --- Lee Stewart [EMAIL PROTECTED] wrote: : : Here's a *working* section of code... Note the :location = browse.php; : on line 23 : : In v4.3.2, it throws a Parse error: parse error, unexpected '=' in : /path/to/file/test.php on line 23. It'd be helpful to see the rest of the code snippet. But it kinda looks as if it should be: $location = browse.php; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] \n and br
On Mon, Nov 10, 2003 at 06:57:54AM -0800, Chris Shiflett wrote: : : --- PHPLover [EMAIL PROTECTED] wrote: : : is \n same as br : : This is not true. : : I know that \n creates a break in source and not in display. : Is it possible to make \n does the same function as br : : No, but you can convert your newlines to the HTML equivalent: : : http://www.php.net/nl2br Warning: nl2br() is not safe because it emits br / tags which do not always work on all browsers (especially browsers not explicitly advertised to be XHTML-compliant). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] \n and br
On Mon, Nov 10, 2003 at 04:05:07PM -0800, Chris Shiflett wrote: : : --- Eugene Lee [EMAIL PROTECTED] wrote: : : Warning: nl2br() is not safe because it emits br / tags which do : not always work on all browsers (especially browsers not explicitly : advertised to be XHTML-compliant). : : Can you name a single browser that cannot properly render a br / tag? There were rendering problems discovered with one popular web forum software called vBulletin. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese character validation
On Sat, Nov 08, 2003 at 06:26:39PM +0900, - Edwin - wrote: : : On Fri, 7 Nov 2003 13:43:06 -0600 Eugene wrote: : : Actually, kana are not simplified kanji because it is not : the case that kana can replace kanji while preserving the : exact same meaning. In fact, most kana by themselves have : no meaning. : : Well, I'm sure there's a very good reason why the dictionary : I quoted called it simplified kanji. I disagree with the term simplified kanji. The kana may have been derived from kanji and evolved over the centuries, but they are no longer kanji in the sense that they carry any intrinsic meaning by themselves. Nor can they replace kanji in meaning and function. They are just phonetic alphabets. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese character validation
On Sat, Nov 08, 2003 at 11:20:27PM +0900, - Edwin - wrote: : : On 2003.11.8, at 20:32 Asia/Tokyo, Eugene Lee wrote: : : On Sat, Nov 08, 2003 at 06:26:39PM +0900, - Edwin - wrote: : : : : Well, I'm sure there's a very good reason why the dictionary : : I quoted called it simplified kanji. : : I disagree with the term simplified kanji. : [...] : : The kana may have been : derived from kanji and evolved over the centuries, but they are no : longer kanji in the sense that they carry any intrinsic meaning by : themselves. : : ?? Who said that they are kanji? Edwin, you quoted the American Heritage Dictionary: kana: (quoted from the American Heritage Dictionary) 1. Japanese syllabic writing. The characters are simplified kanji http://www.phparch.com/mailinglists/msg.php?a=729121s=japanese+characterp=g= I am simply explaning that part of the dictionary definition is incorrect. The statement above, The characters are simplified kanji, is equal to the statement, kana are simplified kanji. The ISA relationship between kana and kanji is false and does not exist. However, I do agree without question that kana evolved from kanji. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] SQL Injections
On Fri, Nov 07, 2003 at 09:43:20AM -, Shaun wrote: : : does anyone know of a function i can include in my scrpits to ensure all : $_POST values sent from a page don't include any SQL? If you're using MySQL, look at mysql_escape_string(). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] BTML 2.0 released!!!
On Fri, Nov 07, 2003 at 01:55:45PM +0300, Burhan Khalid wrote: : : Pablo Gosse wrote: : : What is it meant to top post? I've mainly been a lurker in forums : such as phpbuilder and devshed until recently, but this list is : proving to be a much better resource than those two. : : Top post means posting on top of the text (what you did). Always paste : below the text that you are replying to (what I did). http://www.faqs.org/docs/jargon/T/top-post.html http://www.faqs.org/docs/jargon/B/bottom-post.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese character validation
On Sat, Nov 08, 2003 at 02:20:00AM +0900, - Edwin - wrote: : : Besides, there are some issues (for example with Shift_JIS) that : bothers (with no easy solution) even members of the Japanese PHP : Group ML. (Like the recent thread [PHP-users 18803] on : http://www.php.gr.jp/ or : http://ns1.php.gr.jp/mailman/listinfo/php-users mentioned about the : SJIS trouble.) Force the end-user not to use Shift-JIS. It's a brain-dead format used only for internal processing purposes and not meant as a for-the-public encoding method. Stick with something nice like normal JIS or Unicode. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese character validation
On Sat, Nov 08, 2003 at 01:35:40AM +0900, - Edwin - wrote: : : On 2003.11.7, at 18:37 Asia/Tokyo, Marek Kilimajer wrote: : : ...[snip]... : : Are Kanji and Kana chracter sets? : : Kan - Chinese + ji - character : : kana: (quoted from the American Heritage Dictionary) : 1. Japanese syllabic writing. The characters are simplified kanji Actually, kana are not simplified kanji because it is not the case that kana can replace kanji while preserving the exact same meaning. In fact, most kana by themselves have no meaning. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] question about :: usage
On Fri, Nov 07, 2003 at 11:28:18AM -0800, Chris W. Parker wrote: : : Anyway... Here is my problem. I have a class called Validate that has a : method called ValidateInput. There is another method in this class : called phonenumber. ValidateInput calls phonenumber at some point like : this $this-phonenumber($input);. Won't work. $this refers to the instance of an object. : Does this mean that one method cannot call another method in the same : class unless that class in instantiated into an object? I think so, since your class method is using $this. : Or does it mean I'm just being brain dead and doing something wrong? I'm still learning PHP's way of OOP. I don't know the correct way to do this in PHP, or if there is a correct way, or if it's not doable in PHP4 but is doable in PHP5. Thoughts anyone? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] High bandwidth application tips
On Wed, Nov 05, 2003 at 05:17:29PM -0800, Chris W. Parker wrote: : : One thing you can do to make loops faster is the following: (yes I've : posted this in the past!!) : : Unoptimized: : : $upperlimit = 100; : : for($i = 0;$i $upperlimit; $++) : { : // your stuff : } : : Optimized: : : $upperlimit = 100; : $i = -1; : : while(++$i $upperlimit) : { : // your stuff : } Still, doing a greater-than or less-than comparison is a bit slow. You could try this: $upperlimit = 100; while ($up-- != 0) { // your stuff } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ive lost a zero somewhere
On Thu, Nov 06, 2003 at 03:03:35AM -, Richard Cook wrote: : : when i multiply for example 25 . 50 * 3 i get 76 . 5 how would i get : PHP to recognise the last 0 ie make it 76 . 50 What's with the extra spaces before and after your decimal points? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php executable and environmental variables
On Thu, Nov 06, 2003 at 11:11:13AM +0200, Tom Diamond wrote: : : I am trying to implement a simple web server (in Java) and I want to add : php support. For the moment I do a Process p = : Runtime.getRuntime().exec(php /path/to/php/file), I grab the output, : seperate headers from body and send it back to the client. For simple : php pages this thing works fine. But (obviously) it does not work for : pages requiring parameters. : So my question is what exactly the php executable searches for in the : environment? Which are the (CGI???) variables I'll have to set so that : it will process POST and GET correctly? POST and GET variables come through via the web server. Since your PHP script is getting invoked at the command line, it does not get these variables. So you'll have to find another way to pass these variables. Maybe via a bunch of command-line switches? Or an external, session-ish data store? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FLAG
On Tue, Nov 04, 2003 at 03:19:20PM +0800, [EMAIL PROTECTED] wrote: : : Hi calling out to all programmers: : : I heard that there is a term used by most programmers called FLAG . : Anyone aware of that?? Its a kinda Indicator eg. I have a table with : YES column equal to 1 and NO column equal to 0. Does anyone : know of any useful links with regards to that?? A flag is just something (a variable, a memory location, etc.) that stores some binary-ish information (e.g. true/false, yes/no, 1/0). It is a fairly general term and is used all over the place in the computing world. Some programmers have extended the meaning of flag to include more than binary data, e.g. a set or a range of values. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Setting up PHP5 alongside PHP4 on apache
On Tue, Nov 04, 2003 at 10:30:39AM +0200, Luke van Blerk wrote: : : I'd like to set up PHP5 to parse php files with a .php5 extension on Apache : 1.3.28. Anybody know how to do this? I don't know about loading PHP4 and PHP5 modules in the same Apache server. It may be easier to build a separate Apache server just for PHP5 testing and development, and run it off another port. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Setting up PHP5 alongside PHP4 on apache
On Tue, Nov 04, 2003 at 11:41:45AM +0200, Luke van Blerk wrote: : : I currently have Apache 2 (port 8080) setup with PHP 5 which can run : simultaneously with the Apache 1.3.28 (port 80) and PHP4, but I'd like to : find out if they can both run on the same Apache. I don't think its possible : to specify diferrent locations of your php.ini file though for each PHP (on : Windows that is). I don't know if this is possible as there are probably lots of symbol conflicts between PHP4 and PHP5. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String Array Creation and assigment
On Wed, Oct 29, 2003 at 12:47:58PM -0500, Dan wrote: : : please help with the following: : : I tried this first : : $b[] = 'Book Worzel, Richard (1989). From Employee to Entrepreneur: how to : turn your experience into a fortune. Toronto: Key Porter books.'; : $b[] = 'Book Ries, Al and Jack Trout (1994). The 22 Immutable Laws of : Marketing. New York: Harper Business'; : ... : : then tried this : : $b[0] = 'Book Worzel, Richard (1989). From Employee to Entrepreneur: how to : turn your experience into a fortune. Toronto: Key Porter books.'; : $b[1] = 'Book Ries, Al and Jack Trout (1994). The 22 Immutable Laws of : Marketing. New York: Harper Business'; : ... : : none of the above work, what's right? Both of these examples worked for me without any problems. What exactly do you mean, none of the above work? What happens when you do a simple print_r($b) ? Or even a basic is_array($b) after each set of variable assignments? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Japanese entry into MySQL and into emails
On Thu, Oct 30, 2003 at 10:36:37AM +0100, Marek Kilimajer wrote: : : Unless you want to do string manipulation you don't need mbstring. You : only need to pay atention to these details: : 1. Set charset to kanji for your html pages using : header('Content-type: text/html; charset=kangi'); a. it's spelled kanji and not kangi. b. charset=ISO-2022-JP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Apache 2
On Thu, Oct 30, 2003 at 11:22:38AM +0200, Fernando Melo wrote: : : I would like to use apache 2 in a production environment, but initially : there seemed to be some issues with the PHP module. Does anybody know : if it is ok use it now or is it still buggy with apache 2? The combination of PHP 4.x and Apache 2.x are not considered stable for a production environment. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OT - Quick JavaScript Question
On Tue, Oct 28, 2003 at 02:27:28PM -0500, Jake McHenry wrote: : Chris Shiflett responded: : --- Jake McHenry [EMAIL PROTECTED] wrote: : : I know this is a bit off topic, but does anyone know of a way I : can take the server time in php and get it into javascript? : : JavaScript and HTML are the exact same thing from the perspective of : PHP; they're output. So yes, you can get any information from PHP to : JavaScript by writing it: : : script language=javascript : ... : ? : $ts = time(); : echo var ts = $ts;\n; : ? : ... : /script : : I have tried this already, and it works, the JavaScript get's the server's : time, but then the JavaScript clock doesn't keep counting, it's stuck at the : servers time. It needs that Date() function to keep pulling the time from : the local machine I guess. I was wondering if anyone knew of a way I could : pass the server time into the JavaScript Date() function to make it start : counting from that time, instead of the users machine time. That's because you're only giving it a static time and not a real JavaScript Date() object. Try this: script language=javascript ... var ts = new Date(?php echo time(); ?); ... /script -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Post variables getting lost
On Mon, Oct 27, 2003 at 03:00:32AM -0200, Joao Andrade wrote: : : Hey people, : : Something odd is happening :) I've this form on a page: : : form method=post action=\basics\quotation-add Backslashes are allowed? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Post variables and mysql queries
On Mon, Oct 27, 2003 at 09:38:32AM -0800, Justin Patrin wrote: : : $query='Select * from users where userid='.$_POST['userid'].''; : : I tend to use single quotes whenever I can and to use concatenation : instead of using in-string variables. I do this for three reasons. The : first is efficiency. Strings surrounded by single chars are not parsed : for any values, such as variables and backslashed characters (except for : '). This saves in execution time every time the script is executed. No argument here, except that I don't know if the savings is really noticable for such a small string. : It also helps with readability of the code as some syntax highlighting : doesn't catch variables in strings. IMHO, in-string variables are more readable that trying to read some-string-with-some-quote-character, dot, some-string, dot, some-string, etc. : The last reason is that I know : exactly what the code is going to do. I never really know what will be : used as the variable when I do it in a string. Will it follow a -? What : about two? I don't always know and it's easier to debug without all of : the extra hassle. That's what the curly brackets are for. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: reading/parsing file names
On Sat, Oct 25, 2003 at 04:16:49PM -0700, koly wrote: : : [EMAIL PROTECTED] (Koly) wrote: : : I've got a list of files in a directory, and I'd like to get a only of : filenames that end in .jpg, however, exlude the files that end in : .thumb.jpg : : ex: : file.php : index.htm : photo.jpg : photo.thumb.jpg : etc : : sorry, after re-reading, I'm not sure this post makes sense - : : I'd like to get a count of all the .jpg files in a specific directory : and exclude all other files. $dir = '/path/to/specific/directory/'; $files = glob($dir.'*.jpg'); $count = count($files); : Secondarily, I'd like to be able to refer to only .thumb.jpg files for : another instance (displaying those images) - but I assume once I figure : out how to parse/explode/read/exclude unwanted random file names, I'll : be able to figure out how to look for specific file names I want. : : Basically, I need a kind of wildcard filename parse? Something like: : : if($file == '*.thumb.jpg') foreach ($files as $file) { if (preg_match('\.thumb\.jpg$', $file)) { # do something } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Globals on/off , PHP.ini and .htaccess - Best solution?
On Fri, Oct 24, 2003 at 02:59:58PM +0200, Ryan A wrote: : : (we are on a shared host and so dont have access to our php.ini file) : we are planning to turn globals off via a .htaccess file...nearly all our : php files are in root (/www/) , but we are also running a third party : application 1 directory above root (/www/theApplication/) which requires : globals on, when we tried to use a htaccess to turn off globals in the root : all sub directories too went off...so we added another .htaccess in the sub : and we got errors : : What to do? how can we have globals off everywhere but in the : /www/theApplication/ You should be able to put an .htaccess file disabling globals into /www/, then put an .htaccess file enable globals into /www/theApplication/. If this setup causes problems, feel free to report back. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session_destroy causes backspace on IE
On Fri, Oct 24, 2003 at 01:24:32PM -0400, bill wrote: : : The following code causes IE to break the /h1 tag. : : ?php : session_start(); : header(Cache-control: private); : echo html : headtitlelogout/title : /head : body : h1 align=\center\Logout page/h1; : $_SESSION = array(); : session_destroy(); : echo pSession destroyed/p\n; : echo /body : /html\n; : ? : : View/Source in IE: displays this (note /h1 broken): : : html : headtitlelogout/title : /head : body : h1 align=centerLogout page/pSession destroyed/p : /body : /html : h1 : : Details: Works fine in other browsers I've tried, and this version of IE : (5.5) does -not- have cookies enabled. Besides tossing out IE? :-) Try splitting your big echo() statement into smaller pieces and see what happens. echo 'html'.\n; echo 'headtitlelogout/title'.\n; echo '/head'.\n; echo 'body'.\n; echo 'h1 align=centerLogout page/h1'.\n; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with SELECT statement and reference material wanted..
On Thu, Oct 23, 2003 at 01:57:38PM +0200, P M wrote: : : I'm having trouble retrieving a selection of my database contents. The : problem is when I search for entries that exactly match a search : criteria, see below: : : (database connection established successfully here..) : : $result = mysql_query(select * from complete where authorf = '$authorf'); Try changing this to: $result = mysql_query(select * from complete where authorf = ' . mysql_escape_string($authorf) . '); : (QUESTION 2) : Also, another question relevant to PHP/SQL RDBMS's interfacing: Does : anyoone know where I can find thorough documents on PHP commands for : this purpose? Some texts which tangents database modelling and : optimization would be optimal, since I'm interested in those areas : also! If you're using MySQL, be sure to be familiar with PHP's MySQL functions. And the User Contributed Notes is also a valuable source of information. http://www.php.net/manual/en/ref.mysql.php As for database optimizations, that more of a MySQL thing. So you should familiar yourself with MySQL's optimization documentation: http://www.mysql.com/doc/en/MySQL_Optimisation.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Avoiding blank lines in HTML when field is empty
On Thu, Oct 23, 2003 at 12:46:29PM -0500, Robb Kerr wrote: : : I'm a PhP /MySQL newbie so please excuse the simple question. I'm returning : results from a MySQL query on a webpage. My code includes... : : td valign=top : ?php echo $row_rsVandyDivAddresses['First_Name']; ? ?php echo : $row_rsVandyDivAddresses['Last_Name'];?, ?php echo : $row_rsVandyDivAddresses['Degree']; ? : br : ?php echo $row_rsVandyDivAddresses['Address']; ? : br : ?php echo $row_rsVandyDivAddresses['City']; ?, ?php echo : $row_rsVandyDivAddresses['State']; ??php echo : $row_rsVandyDivAddresses['Zip']; ? : br : Phone: ?php echo $row_rsVandyDivAddresses['Phone']; ? : br : Email: ?php echo $row_rsVandyDivAddresses['Email']; ? : /td : : Here's the problem. Some of the fields are empty (for instance 'Address') : and the way my code is configured a blank line appears in the returned data : when the field is empty. How do I change this code to add a conditional that : only echos the field contents AND the br when the field is NOT empty? Make a wrapper function instead that does the proper tests: function print_field($field) { if (!empty($field)) { echo $field . br\n; } } Then change your code a bit: td valign=top ?php echo $row_rsVandyDivAddresses['First_Name']; ? ?php echo $row_rsVandyDivAddresses['Last_Name']; ?, ?php print_field $row_rsVandyDivAddresses['Degree']; ? ?php print_field $row_rsVandyDivAddresses['Address']; ? ?php echo $row_rsVandyDivAddresses['City']; ?, ?php echo $row_rsVandyDivAddresses['State']; ? ?php echo $row_rsVandyDivAddresses['Zip']; ? br Phone: ?php print_field $row_rsVandyDivAddresses['Phone']; ? Email: ?php print_field $row_rsVandyDivAddresses['Email']; ? /td You get the idea. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Conversion project problem
On Thu, Oct 23, 2003 at 03:51:30PM -0700, Mike Alderson wrote: : : I am trying to gather information from one database, : process it, and insert it into a new one. When I run : this script I am getting the following error: : : Warning: mysql_fetch_array(): supplied argument is not : a valid MySQL result resource in : C:\web\aldersonfamily\convert.php on line 11 : : Here is my code: : : ? : : $connectionnew=mysql_connect(localhost,app,aardvark) : or die(Can't connect to database new); : $dbnew=mysql_select_db(alderson_cms, : $connectionnew) or die(Can't select db : cms_alderson); : : : $connectionold=mysql_connect(localhost,app,aardvark) : or die(Can't connect to database : $DBASEURL,$DBASENAME,$DBASEPASS); : $db=mysql_select_db(aldersondb1, : $connectionold) or die(Can't select db aldersondb1); : : $sql=SELECT * FROM users; : $result=mysql_query($sql, $connectionold) or : die(mysql_error()); Are you sure your query succeeded before you entered your while loop? : While ($row=mysql_fetch_array($result)) : { : $id=$row['id']; : $fname=$row['fname']; : $lname=$row['lname']; : $password=$row['password']; : $username=$row['username']; : $security = crypt(user, 12); : $password = crypt($password, 12); : : $sql = INSERT INTO cms_users (id, fname, : lname, username, email, password, security, origip) : VALUES (\\, \$fname\, \$lname\,\$username\, : \\, \$password\, \$security\, \\); : $result=mysql_query($sql, $connectionnew) or : die(mysql_error()); : } : : ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Age from birthdate?
On Wed, Oct 22, 2003 at 06:31:21PM +0200, DvDmanDT wrote: : : How would I get the age of someone if I store the birthdate in a date field? : I just realized FLOOR((UNIX_TIMESTAMP(NOW()) - : UNIX_TIMESTAMP(birthdate))/60/60/24/365.25) wont work for persons born : before 1970... :p I must get the current age in years, and I must be able to : select by age... :p Any ideas? Determining someone's age based on Unix timestamps was discussed earlier this month. Check the archives for a working function. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Print mysql errors
On Mon, Oct 20, 2003 at 05:28:08PM -0500, Joseph Bannon wrote: : : How do you print the error message sent back from MySQL? : : $resultCC = mysql_query($queryCC) or die(???); Stop using stupid Perl syntax. $res = mysql_query($query); if ($res === false) { # print error to stdout # echo mysql_errno() . : . mysql_error(). \n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gmdate problem
On Tue, Oct 21, 2003 at 12:44:38PM +0800, [EMAIL PROTECTED] wrote: : : Having some problem with 'gmdate' here. However, the time doesn't : match with the current time on the system. What could be the problem? : Do I have to set any timezone or stuff like that?...Hope to get some : help here. : : Tue, 21st Oct 2003, 04:25 : : ?php : echo gmDate(D, dS M Y, H:i); : ? gmdate() returns the the GMT/UTC time (i.e. timezone 0). Unless your system's timezone is zero because it is in Greenwich, gmdate() does not adjust its result to your local timezone and you will not get the answer you expected. What's wrong with date()? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] run PHP script in clean memory space
On Tue, Oct 21, 2003 at 02:48:09AM +0200, Honza Malik wrote: : : I want to give administrators of our CMS the possibility to use PHP commands : in HTML templates. Templates are parsed by our PHP script. : : The problem is, that I don't want administrators to be able to list our : $GLOBALS (where is database password) or call our functions. Is there the : possibility to run administrator's PHP code (from our PHP) in clean : environment? Other solution? PHP doesn't really have the concept of a safe interpreter. The next best thing is to take a look at PHP's safe mode stuff and see what you can tweek: http://www.php.net/manual/en/features.safe-mode.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php