[PHP] Problem with date_format() in indirect MySQL query...
Hello! :) First off, please respond to me directly as I am not subscribed to the list. Thanks! :) Now then, I have a quick question I'm hoping someone can help me with. I have this class method: function query($sql, $type = 'obj') { if(!$result = @mysql_query($this->masl($sql))){ echo "Problem with query: $sql. " . mysql_error(); exit; } $objary = array(); if(@mysql_num_rows($result) > 0){ if($type == 'obj'){ while($object = @mysql_fetch_object($result)){ $objary[] = $object; } @mysql_free_result($result); }elseif($type == 'assoc'){ while($object = @mysql_fetch_assoc($result)){ $objary[] = $object; } @mysql_free_result($result); }else{ echo "Problem with type of query requested."; exit; } return $objary; }else{ return null; } } And this something like this query: $res = $this->query("select *, date_format(thedate, 'M d, Y') as dt, date_format(thedate, 'l:i p') as tm from thetable where foo = '$bar'"); Every other query I've executed in this fashion, I've been successful in retrieving the results. But, when I try doing something with the date_format function, when I try to print out the formatted date and time returned, I get the formats instead. Does anyone have any idea why, and any idea what I can do to rectify this? TIA! :) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Problem with date_format() in indirect MySQL query...
Mark Roedel wrote: > Perhaps a quick re-read of the date_format() section of > http://www.mysql.com/doc/D/a/Date_and_time_functions.html > is in order? (Hint: the % characters mean something.) Thank you very much! That's odd ... in previous scripts I've written there wasn't a need for the % character. Just how long has this change been intact, anyway? -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP vs Perl question
> I'm pretty new to programming - besides JavaScript, PHP is really the first > language I've used. > I'm just wondering, and I'm sure you all would know - should I learn Perl? > Is it considered a necessity for a web developer to know Perl, or is it not > a worthwhile endeavor, considering how easy PHP is to learn and use? Someone > I know told me not to bother, but I just wanted a second opinion. > (BTW - if you think it is worthwhile to learn Perl, what is a good book to > begin with?) Yeah, you should learn Perl. Programming Perl by O'Reilly is the best book out there for that. Then check out the Perl Cookbook by O'Reilly after that. Perl is much more powerful than PHP, but PHP is easier to integrate in to web pages. But not by much. Perl is like a swiss army chainsaw. You can use it for pretty much anything, data manipulation wise. That's where it really shines. PHP has gotten better with PHP4's release, but Perl's syntax is much more lenient and intuitive, making it much easier to do things in Perl than it is in PHP. -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL Query
You wrote: > I have a table that looks like > > Name | Type | X | Y > > Foo| Ship | 9 | 29 > Bar| Base | 9 | 29 > > Is there any way I can write a query that selects > everything with Type = Base, and X and Y = Foo's X and Y? > > ie > > "Select * from table where type = Base and X = {Foo:X} and Y = {Foo:Y}"; $result = mysql_query("select x, y from table where name = 'Foo'"); $info = mysql_fetch_object($result); $x = $info->x; $y = $info->y; mysql_free_result($result); $result = mysql_query("select * from table where type = 'Base', x = 'x', y = 'y'"); $info = mysql_fetch_object($result); // Use properties of $info here. mysql_free_result($result); I think your reasoning is a little jumbled, though. There may be some way to do what you want to do with one query. There usually is for the simple things. I'm not quite sure what you want to accomplish, though. HTH. :) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: array question
You wrote: > Also, consider using print or echo as opposed to printf. And lastly, you > really don't need to use mysql_free_result, PHP does this automagically > after the script dies. Sorry for picking on you, you may have your > reasons. ;-) Really? Then why was it that, when I neglected to use mysql_free_result() in some of my scripts, lots of memory was eaten up because of lingering results? -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL Query
You wrote: "Ryan Fischer" <[EMAIL PROTECTED]> wrote in message 01d901c1101e$9cd43220$80c93fd0@ryan">news:01d901c1101e$9cd43220$80c93fd0@ryan... > You wrote: > > I have a table that looks like > > > > Name | Type | X | Y > > > > Foo| Ship | 9 | 29 > > Bar| Base | 9 | 29 > > > > Is there any way I can write a query that selects > > everything with Type = Base, and X and Y = Foo's X and Y? > > > > ie > > > > "Select * from table where type = Base and X = {Foo:X} and Y = > {Foo:Y}"; > > $result = mysql_query("select x, y from table where name = 'Foo'"); > $info = mysql_fetch_object($result); > $x = $info->x; > $y = $info->y; > mysql_free_result($result); > $result = mysql_query("select * from table where type = 'Base', x = 'x', > y = 'y'"); > $info = mysql_fetch_object($result); > // Use properties of $info here. > mysql_free_result($result); "Marcus Hartmann" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... the statement should look like this: > $result = mysql_query("select * from table where type = 'Base' and x = 'x' and > y = 'y'"); Oops. And I see one other mistake here, too. The query really should be: $result = mysql_query("select * from table where type = 'Base' and x = '$x' and y = '$y'"); -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Capitalize Function ??
You wrote: > So sprach »PHP Junkie« am 2001-07-23 um 21:39:07 -0400 : > > I'm taking in first name and last name data into a MySQL db through a > > form. Users sometimes don't capitalize their first and last names when > > entering the data. Is there a function to clean this up for > > consistency? If so, what is the name of the function that performs > > this? > > Yep, ucwords. > > But this is not a good idea! There are Names (like "Hans vom Bach" or > somesuch) which do NOT have to be captialized. Actually, capitalizing > the "vom" would be wrong. Although this was just a German example, I'd > bet there are names in French, Dutch, Spanish, Italian as well which > should not be capitalized. Hmm, how about English? Sometimes there are > suffixes like "the 3rd", no? Would it be right to capitalize this? Usually, "the 3rd" is written as "John Doe, III," AFAIK, so that's not really an issue. -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Capitalize Function ??
You wrote: > So sprach »Ryan Fischer« am 2001-07-24 um 07:35:37 -0400 : > > Usually, "the 3rd" is written as "John Doe, III," AFAIK, so that's not > > really an issue. > > Okay, III isn't an issue then. What about people with Dr. titles? Like > 'Dr. med John Doe'. There the 'med' shouldn't be capitalized. Never heard of that one before. Usually, a medical doctor adds an "M.D." at the end of his name indicating so. > And I'm sure, there are enough other examples - but: it's your app, > *I* would not do it, but that's just me. If people are too lazy > to type there name correctly capitalized, than it's their problem > IMHO. Agreed. ;) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] bad word filter
You wrote: > I've been reading the "Profanity Filter" thread in the list archives but > haven't found anything real helpful. Here's my code so far, this of course > won't work. > function filterWords($string, &$result) { > $badwords="shit, fuck, ass, bitch"; > $word=explode(", ", $badwords); > for ($i=0; $i $replace = str_replace("$word[$i]", "", $string); > } > } > $string = "Ass monkey"; > filterWords("$string", $result); > print "$result"; > ?> > > How can I scan for the $badwords in $string and replace $badwords with ? Why waste your time? People will find a way around the filters anyway, if they really want to use the words you're censoring. Just a point to be made. Anyway, here's what I would do: function filterWords($str){ $badwords = array("shit", "fuck", "ass", "bitch"); for($i=0; $ihttp://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Example high-profile PHP sites
You wrote: > While I do appreciate people's contributions, let me frame the > discussion a little. The person I need to convince is an > administrator of an organization within North America, and he's never > heard of PHP. The response I'm hoping to provoke in him is something > like this: "You mean _ is using this PHP thing? Wow! They > know what they're doing, so we'd better use it, too!" > > Does this help frame things? Thanks for the suggestions! > > -Maurice Why don't you just say something along the lines of, "Look, PHP is the best programming language for the job you want me to do. What other sites are using doesn't matter. Trust me on this. I don't tell you how to (fill in the blanks of whatever this person does). I assure you that what you're looking for will be accomplished in a way that will please you, and that's all you need to know. :)" Of course, say it in a more tactful, arse-kissing type way than that. But you get my drift, I think. ;) I've always thought "monkey-see, monkey-do" or "what the joneses have" type arguments were better left to the playgrounds of elementary schools, myself. Hopefully, the person you're trying to work with can understand that. :) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] substr question...
You wrote: > I am trying to receive file names but can't quite figure out the proper > substr to do it: > > jeff.dat > jeffrey.dat > chris.dat > tom.dat > > I want to receive the name to the left of the .dat > > Jeff $file = array("jeff.dat", "jeffrey.dat", "chris.dat", "tom.dat"); for($i=0; $i\n"; } HTH! :) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] php.net's index.php
You wrote: > I was wondering what I would have to do in order to have index.php load up > automatcially when someone went to my domain. IE if they go to > www.mydomain.com and I have index.html or index.htm there then those pages > get loaded first. How could I do it so index.php, index.php3, index.phtml > were default as well? Create a file called .htaccess with this in it: DirectoryIndex index.php Upload it to the directory you want it to affect. This assumes you're using Apache, of course. HTH! :) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Large Calculations
You wrote: > I have a mySQL database holding baseball stats and I want to calculate > rankings on these players. Now I'd obviously want this to be as fast as > possible since I go through about 600 players but where is it best to make > them? In the SQL command itself or in PHP? > > players need to have at least 100 at bats for this formula to work for them. > There are 6 steps. > > 1. batting average x .05 > 2. doubles + triples + HR divided by at bats > 3. runs scored divided by at bats > 4. rbi's divided by at bats > 5. stolen bases divided by at bats > next add up the 5 totals then multiply that total by 200. It's a bse 100 > system. a rating over 100 is very good. It all depends on how you're inserting the data. It really doesn't matter where you do the calculations. Math stuff is usually pretty fast when it's simple arithmetic. An SQL query such as this should be sufficient: update tablename set rating = ((avg * .05) + ((doubles + triples + homers) / abs) + (runs / abs) + (rbis / abs) + (sbs / abs)) * 200; Only problem here is, I'm not sure if SQL will do this on a record-by-record basis. If my thinking is wrong, you may end up with the same result for every record, because there's no "where" clause. You may have to sort that out yourself with some sort of loop. I guess selecting all those fields, and then doing the arithmetic for each record should suffice. HTH! :) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP_SELF
You wrote: > It's generally a whole lot better to do your form value checking with > Javascript. It'll be faster and alot less of a waste of your server > resources. IMHO, of course. :) This really isn't that true because if a user has JavaScript disabled, or is using a browser that doesn't support it, the error checking will simply be ignored, and you'll have been given data that is possibly erroneous. -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] What would you want in a PHP web host?
You wrote: > What do you think a medium sized hosting company could do to give you (the > developer) better service and support? Be willing to help their users in any way they can, as far as service goes. > Is access to professional PHP developers useful when an issue arises? Depends on the issue. > Are hosting companies reluctant to give you more access rights? Usually, and that really sucks, because I've found myself having to set up my own "pseudo-server" on my computer, with PHP4, Apache, and MySQL, just to develop, because the hosts I've found are very reluctant to either upgrade from PHP, or build PHP with the necessary extensions I need. IMO, PHP4 on web hosts should always be compiles with *all* options, so there will be no issue there. And it should always be upgraded to the newest stable version within a week of its release. This may be asking a lot, but people should get what they pay for, right? > Are they willing to re-compile their PHP build to add other options? No. See above. > How long do requested changes to the server take? Way too long. The changes requested should take place (ideally) in less than 24 hours. > What other suggestions do you have for improving the relationship between > the server administrator and the PHP developer? Be nice, and be available to help. > I spent some time going through the PHP site looking at the list of hosts > supporting PHP, but I didn't find any real discussion about what people want > in a host (although I did find plenty of things they don't want :). Because things they don't want are obviously more abundant. ;) I think people just want to be happy with the service their host provides, and that means the host needs to be prompt and attentive and ready to assist. -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: FAQ
You wrote: > I have a php book that says it stands for Personal Home Page, not sure if > that is correct or not... It's not. PHP stands for "PHP: Hypertext Preprocessor." It's a recursive acronym. -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Replacing template variables with values?
Hello! :) I have a form with a textarea that contains a template e-mail with variables in it. I would like to be able to replace those variables with values. The variables named in the template are actual variables in my script. This doesn't seem to work: $newmail = preg_replace("/\$(\w+)/e", ${$1}, $template); ...and neither does anything I've tried to do as far as eval() goes. I either get a parse error like this: Parse error: parse error, expecting `T_VARIABLE' or `'$'' in c:\path\file.php on line 16 ...or some other sort of eval() error. Any ideas? TIA! :) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Replacing template variables with values?
You wrote: > This always works for me... > > eval ("\$message = \"$message\";"); > > I use it in the same type of scenario you've described, and also with E-Mail > bodies stored in a DB. Works like a charm. Thanks, that worked great! :D -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: [PHP-DEV] Passing JavaScript variables to PHP
You wrote: > > location.href='mail.php?message=' + message; > > You need to URLEncode that message data. > > Not sure how JavaScript does it... > > probably message.urlencode() Actually, it's escape(message). -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Replacing template variables with values?
You wrote: > > This always works for me... > > > > eval ("\$message = \"$message\";"); > > RED ALERT! SECURITY TO THE BRIDGE! > > "Captain, there's Klingons off the starboard bow!" > > Oh, sorry. Did I type that aloud? Sorry. > > If $message is a free-form email typed in by a potentially malicious user > this looks pretty dangerous to me... > > Have you tried it with things like: > > $message = '";exec("/usr/bin/cat /etc/passwd");'; > > Do *NOT* try this one, but if the above works, think what *THIS* would do! > $message = '";exec("/usr/bin/rm -rf /");'; The e-mail script is for administration, so it's password protected. Do you still see a problem? Do you have any better ideas? -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: Hmmm?
You wrote: > additionally I also tend to always provide an alternative, especially if dealing > with nested ifs or loops, even if just a comment... call it habit (from where I > don't know). > > if($condition){ > do this > }else{ > # oops, $condition didn't exist > } > > saves a hell of alot of time when going back through the code 6 months later > trying to remember what was being done where. personal opinion mind you It's a good idea. The only problem is when you come upon a situation where you don't want to do anything "else" at that point. Where you simply want to skip the rest of the if block if the condition isn't true, and continue on with the rest of your script. Then, using an else isn't what you want to do. -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Problem with require(), determining context.
Hello! :) I have a script that loads another script with require() and based on the context, I'd like different things to happen. So, index.php is calling the required file require.php. And when require.php is run, if there's no HTTP_REFERER and the file is index.php, everything is OK. But if the file is accessed directly (say by GET) then I want an error to be thrown. Reason being is require.php can also accept POST operations, but I don't want it to accept GETs, because it's not supposed to be used alone. Problem is, when it's required with another file, GET is OK. So basically, I want to detect if the file is being required or called on its own. At least, that's what it sounds like I want to do from my above explanation. Any ideas how I can accomplish this? Thanks! :) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] close browser
You wrote: > Can anybody tell me what the code to close the browser is? ALT+F4. ;) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] close browser
You wrote: > > You wrote: > > > Can anybody tell me what the code to close the browser is? > > > > ALT+F4. ;) > PHP cannot execute client side actions, afaik. > > - k 'Twas a joke. See the winky smilie? You may all laugh now. ;) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How to get the query string?
You wrote: > hi guys, > > I'd like to get the query string the browser sends to the script. The > problem is that since the $HTTP_POST_VARS (or $HTTP_GET_VARS ) is an > associative array I can't use numbers to point to the elements of > this array. This piece of code does not work: > > for ($a=1;$a<=sizeof($HTTP_POST_VARS);$a++){ > echo "$a. ".$HTTP_POST_VARS[$a].""; > } Use: print_r($HTTP_POST_VARS); -or- foreach($HTTP_POST_VARS as $k => $v){ echo "$k => $v\n"; } -or- while(list($k, $v) = each($HTTP_POST_VARS)){ echo "$k => $v\n"; } -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] IE Download twice from DB - MAJOR disaster to db users
You wrote: > very amusing indeed. > > Go learn php and when youll have answer send it or stfu. > > you might start with your own site: www.PHPBeginner.com > and then go to http://logos.uoregon.edu/explore/socioling/politeness.html to > learn how to behave ! > > Its amazing how many people are rude ! I see nothing rude about his post. Your's on the other hand ... well, let's just say that telling someone to "stfu" and then insisting that they're rude and need to learn how to behave is both ironic, sad, and a bit amusing. ;) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] a bit off the list but should be easy
You wrote: > Note that the download font thing is Internet Exploder Specific. Internet > Exploder also has a few issues with different charsets. > Also note that *all* html documents should have a specified charset - even > the plain english ones. Most of the html on the internet is coded wrongly, > this does not make it correct. > > I do a lot of simplified chinese development, being located in Shanghai, > China. That's not entirely true. The most basic valid HTML document looks like this: Some Random Title Text. -or- Some Random Title Text. That's it. Three lines. No HTML tag, no HEAD tag, no BODY or FRAMESET tag. They're all optional. Of course, if you want to get really picky, only one character is required to be in the TITLE; same goes for the BODY, which is implied by the end of the HEAD, which is also implied, and so on and so forth. ;) META tags are optional, which means charset specifications are optional, as well. I assume a default charset is sent by the server, anyway, because my phpinfo() settings for my own server return "en-us" for HTTP_ACCEPT_LANGUAGE, but I could be mistaken, because I never cared about it because it was optional after all. ;) /digression -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] If-statement
You wrote: > Is it possible to write this shorter: > > if ($Var != "No1" && $Var != "No2" && $Var != "No3") { > code > }; if(!ereg("^No[1-3]$", $Var)){ // code } -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Assign multiple variables from mysql_fetch_row() call
You wrote: > ($var1, $var2) is magic. I hate magic. It's not magic. It's just simpler. > What do you look up in the Perl > manual when you hit syntax like that? http://www.perldoc.com/perl5.6/pod/perldata.html > In PHP the equivalent syntax is: > > list($var1, $var2) = ... Which is longer, and requires you to learn a keyword that you don't need to learn in Perl. > It does exactly the same thing, and it is legible. Anybody can pop over > to http://php.net/list and get an explanation of what the code does if > they run across it. I use list context a lot in PHP and Perl, and I prefer Perl's way of doing it *because* it allows you to be as verbose or terse as you like. PHP, unfortunately, doesn't give you that freedom. -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Assign multiple variables from mysql_fetch_row() call
You wrote: > >I use list context a lot in PHP and Perl, and I prefer Perl's way of > >doing it *because* it allows you to be as verbose or terse as you > >like. > >PHP, unfortunately, doesn't give you that freedom. > > Hmm... the freedom to write unreadable, unmaintainable code, yes this > is a very important feature. Yes, well, that all depends on who's writing it. I've been writing Perl for several years, and believe you me, the code is plenty readable. And, it's much more concise than anything written in PHP. That freedom is what's so appealing about Perl. But of course, I'm on a PHP list (because I like both), so the people who will agree with me are few and far between. One can write unreadable code in PHP or Perl. It all depends on what you know about the language and how well you are able to use it. Keywords make no real difference, because when I see ($foo, $bar), I know it's a list. I don't need a list() operator to know that. ;) -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Assign multiple variables from mysql_fetch_row() call
> > You wrote: > > > ($var1, $var2) is magic. I hate magic. > > > > It's not magic. It's just simpler. > > > > > What do you look up in the Perl > > > manual when you hit syntax like that? > > > > http://www.perldoc.com/perl5.6/pod/perldata.html > > I said "what" not "where". I still maintain that if you don't know where > to look, () is not an easy thing to search for. Sure it is. Lists or list context. () is not that hard to determine what it means. At least, not nearly as hard as you make it out to be for any moderately-experienced programmer. -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Assign multiple variables from mysql_fetch_row() call
You wrote: > >Sure it is. Lists or list context. () is not that hard to > determine > >what it means. At least, not nearly as hard as you make it out to > >be for any moderately-experienced programmer. > > So it's easy to look it up is if you already know what it does? I > think the majority of people looking it up would be > not-so-experienced programmers :) Yes, but an inexperienced programmer wouldn't know where to look for list, either. When you see ($foo, $bar), you know two or more items are a list. What is a list? Two or more items. What do you have there? Two or more items. Rather simple and intuitive to me. *shrug* The way you learn to problem shouldn't be looking something up to find out what it does, but rather learning what everything does, then applying it by doing the programming afterwards. This sort of backwards thinking is what causes problems in the first place. :\ -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Assign multiple variables from mysql_fetch_row() call
> Which is why you see spoofs like this one > http://bbspot.com/News/2001/03/perl_test.html The Perl code in that spoof isn't even valid. ;) And besides, the fact that you can write Perl code that looks like that and still functions is more of a feature than anything. Code that is written like that is not meant to be readable. It's meant to serve a function, and usually, it's written by one person, and read only by that person. Hehe... and to think this whole line of discussion started because someone advocates list() over () when the latter, IMO, is better because the former is redundant. That's what it comes down to, really. *shrug* > I'm sorry, I have heard the arguments that PERL can be extremely readable > if written properly. The problem with this from the standpoint of someone > trying to learn the language is that many (if not most) people who program > in > PERL don't take the time to write readable code. This makes both > maintaining > and learning from PERL programs more difficult. I think that they would > even > admit on a PERL list that PERL does have a higher learning curve than PHP. The same can be said for PHP. Some people don't take the time to write readable code, no matter what the language. Because of this universality, that makes it a rather moot point. -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] insert space to a string (newbie)
You wrote: > I have a simple question... > How can a space inserted to a string after the 3rd char ?? > > washington ->> was hington $str = 'washington'; $str = ereg_replace('^(.{3})(.*)$', '\\1 \\2', $str); -- -Ryan :: ICQ - 595003 :: GigaBoard - http://www.gigaboard.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]