[PHP] need help with unusual php/mysql/array manipulation script
I run an online gaming fansite, and most people that visit my site want to know what would be best to raise their skill on. I started a script which basically takes numeric data (0-120) and pulls the information they need from my database. I got the easy part down, which you can see here: http://www.tamingarchive.com/main/whattotame.php The complete listing of everything within the database is listed here: http://www.tamingarchive.com/tameables/ Basically, the script pulls the animals from the database based on their "min" value. Problem is when multiple people use the same animal for skill. If Joe tames it, it might be 59.1 required skill, but if Bob comes and retames it, it takes 63.9 skill (+4.9). I need to be able to somehow add creatures into my array that I just pulled from the database with the necessary amount added to the "min" value and sort it all by the "min" value. My desired output would be like this: Rat -0.9 Sewer Rat-0.9 Cow 11.1 Rat (2nd) 3.9 Sewer Rat (2nd) 3.9 Cow (2nd)15.9 Rat (3rd)18.3 Sewer Rat (3rd) 18.3 My select statement just does multiple OR comparisons to see if adding the 2nd & 3rd retame values to the "min" value will still put it within my desired range. The "quality" part of the script is just a comparison on the "min" value. I don't even know where to begin to add these modified values to my array. I'm awful with arrays anyway. Any help would be greatly appreciated. sasha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: need help with unusual php/mysql/array manipulation script
On Sat, 27 Jul 2002 01:08:12 -0400, [EMAIL PROTECTED] (Chris Earle) wrote: > Ahhh, good old UO. I remember GMing my taming, crazy what they've done to > the game since I've quit (120 skill, insane!). > > I'm not completely sure of a few things about your question and I think that > I could help if you supply the answers to my questions. > > Does one tamer's taming of an animal increase ALL animals by a generic > amount (i.e., John tames "a cow" for the first time, then Bill tames it, > then John tames "a polar bear" for the first time and, again, Bill retames > it; do both examples raise the requirement 9.8 points or is it based on the > animal)? > > If it is generic the answer is simple, if not, it might get a little more > complicated. > Exactly, it is a set amount. The 2nd time it is tamed, 4.8 is always added to the minimum amount. The 3rd time it is tamed, 19.2 is always added to the minimum amount. I'm only going up to the 3rd, because anything past that is pretty much impractical. thanks sasha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mailinglists are honey for Spammers
Hi, Currently i'm working on a php script which allow to archive the content of email accounts. It fetch the accounts through the imap extension and store the messages in a database. It is easy to subscribe an address to this list and collect email adresses. I mean the attemp to hide emails, example: myemail () yahoo ! com has only a psychological value, but it prevent from nothing. Regards, atur
[PHP] Question regarding include() and symlinks to directories
Hi let's say we have the follwing directory structure: directory test, with to subdirectories: a and b; both have ssi subdirectory; a has also a subdirectory c with an index.php file in it and in b we habe a symbolic link to a/c. On the shell it looks like this: , | /htdocs/test>ls -gG * | a: | total 8 | drwxr-xr-x 2 4096 Jan 4 20:55 c | drwxr-xr-x 2 4096 Jan 4 20:51 ssi | | b: | total 4 | lrwxrwxrwx 16 Jan 4 20:53 c -> ../a/c | drwxr-xr-x 2 4096 Jan 4 20:53 ssi | ~/htdocs/test>cat a/ssi/a.inc | In directory a | | ~/htdocs/test>cat b/ssi/a.inc | In directory b ` As you see whe have an a.inc in each ssi. If we call now the index.php which does nothing more than to: include('../ssi/a.inc') what would you expect to read if you called b/c/index.php? I expected to read 'In directory b' but I read 'In directory a'. , | ~/htdocs/test>(cd a/c && php -f index.php ) | In directory a | | | ~/htdocs/test>(cd b/c && php -f index.php ) | In directory a ` In my opinion include() should respect symlinks to directories and not dereference them before finding the file to include. Or am I wrong here? The PHP version is 5.1.6 (will soon be updated). KP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Question regarding include() and symlinks to directories
On 6 Jan 2007, [EMAIL PROTECTED] wrote: > On Thu, January 4, 2007 2:47 pm, Karl Pfl=E4sterer wrote: >> In my opinion include() should respect symlinks to directories and not >> dereference them before finding the file to include. Or am I wrong >> here? >> The PHP version is 5.1.6 (will soon be updated). > > WHOOPS! > > My fingers slipped and I keyboarded to "Send" button. > > SORRY! > > ... and use full pathname when you go to read a file. > > Anything else is more like playing an Adventure Game than Programming. IMO you're absolutely right, but I didn't ask the question out of sheer curiosity but it has to do with the way script files (here at work) find the right files to include for navigation, banners etc. Symlinks to files and directories are used a lot and sometimes it's very convenient to include some files with an absolute path (the files which are the same for all) and some files with a relative path (the files specific for one page). mod_include had been used before PHP and it was common to use this technique. KP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Question regarding include() and symlinks to directories
On 5 Jan 2007, [EMAIL PROTECTED] wrote: > > On Fri, 2007-01-05 at 22:07 +0100, Jochem Maas wrote: >> reply at the bottom ... >> >> (Karl Pflästerer) wrote: >> > Hi >> > let's say we have the follwing directory structure: >> > directory test, with to subdirectories: a and b; both have ssi >> > subdirectory; a has also a subdirectory c with an index.php file in it >> > and in b we habe a symbolic link to a/c. >> > >> > On the shell it looks like this: >> > , >> > | /htdocs/test>ls -gG * >> > | a: >> > | total 8 >> > | drwxr-xr-x 2 4096 Jan 4 20:55 c >> > | drwxr-xr-x 2 4096 Jan 4 20:51 ssi >> > | >> > | b: >> > | total 4 >> > | lrwxrwxrwx 16 Jan 4 20:53 c -> ../a/c >> > | drwxr-xr-x 2 4096 Jan 4 20:53 ssi >> > | ~/htdocs/test>cat a/ssi/a.inc >> > | In directory a >> > | >> > | ~/htdocs/test>cat b/ssi/a.inc >> > | In directory b >> > ` >> > >> > As you see whe have an a.inc in each ssi. If we call now the index.php >> > which does nothing more than to: >> > include('../ssi/a.inc') >> > what would you expect to read if you called b/c/index.php? I expected to >> > read 'In directory b' but I read 'In directory a'. >> > >> > , >> > | ~/htdocs/test>(cd a/c && php -f index.php ) >> > | In directory a >> > | >> > | >> > | ~/htdocs/test>(cd b/c && php -f index.php ) >> > | In directory a >> > ` >> > >> > In my opinion include() should respect symlinks to directories and not >> > dereference them before finding the file to include. Or am I wrong here? >> >> I have tested using your exact description and get the result, you can >> be fairly certain this is not something specific to your server/machine. >> >> I would tend to agree with your premise - but the php devs may have >> decided against this behaviour on purpose. > > PHP needs to dereference symlinks so it knows exactly where it is in > case of security violations. This prevents symlinking into paths for > which you don't have access... especially important on shared hosts. I always thought this kind of check would only be done if you used safe_mode. If you're not a shared host there's no need for this kind of check. Everyone who has the ability to place a php script on the server also has shell access (here at work at least). To explain why I asked about this behaviour (so it's not only a convoluted example I showed but a simplified version of an existing directory structure (if it would be done that way today is another question)) see also MID <[EMAIL PROTECTED]>. > > Cheers, > Rob. > -- > .. >| InterJinn Application Framework - http://www.interjinn.com | > :: >| An application and templating framework for PHP. Boasting | >| a powerful, scalable system for accessing system services | >| such as forms, properties, sessions, and caches. InterJinn | >| also provides an extremely flexible architecture for | >| creating re-usable components quickly and easily. | > `' KP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Question re virtual and scope of definitions
Hi, today I wanted to use virtual (an `include' wasn't an option) to get the output from another PHP script. I got errors about functions being already defined, which is true since in both scripts are functions of the same name. I always thought virtual makes an Apache subrequest which gives me a new PHP environment. But similar to include the definitions from script1 are also in the scope of script2. Is this the wanted behaviour? If so, how could I insert the output from another PHP script (I could fetch it with curl or wget but that's the last thing I would like to do)?. What if I inserted with virtual another .html file which in turn uses mod_include to insert with the PHP script (sounds like loop the loop)? KP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Different php.ini files for different apache processes on one server
Hi, suppose you had several directories a, b and c where in each directory you had an Apache http.conf file. For each directory Apache gets started with the http.conf (and other conf files) in that directory. PHP is used a an Apache module. How can I have a different php.ini file for each different Apache process (a, b and c)? (Apache is 1.3.33 IIRC) KP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Different php.ini files for different apache processes on one server
On 19 Jul 2006, [EMAIL PROTECTED] wrote: > You could chroot each apache instance but I would probably try to modify > the apache module to accept a parameter (and in the process verify that > one does not already exist). Thanks to all for the answers. As the solution has to work with Apache 1 I can't use the PHPIniDir directive. One poster suggested to try to set the PHPRC env variable. That seems to be the easiest approach since all Apache instances get started with a different shell script. KP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] "use strict" or similar in PHP?
I have no ideea why my response from half an hour ago was not sent, but here it is again: 1. Error reporting set to show notices, warnings and errors. See http://www.php.net/manual/en/function.error-reporting.php 2. For caching you can use memcache. See http://www.php.net/memcache 3. These are called prepared statements. See http://www.google.ro/search?q=prepared+statements+php Regards, Ovidiu On Thu, Feb 26, 2009 at 10:45 PM, Hans Schultz wrote: > Hello, > I am beginner with PHP and prior to PHP I have worked with java for some > time > and with perl for very short period. I can't help to notice some things > that > are little annoyance for me with PHP, but I am sure someone more > experienced > can help me :-) > Is there in PHP something like "use strict" from perl? I find it pretty > annoying to need to run script over and over again just to find out that I > made typo in variable name. > Is there some way for PHP to cache some data on the page? I like very much > PHP's speed but it would be even better to be able to cache some frequently > used data from database? > Also regarding databases, I liked a lot java's way of sending data to > database > using parameters ("select * from user where username = ?" and then passing > parameter separately with database doing necessary escaping and > everything). > Is there something like PHPDBC similar to JDBC? > > TIA, > Hans > > > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Re: Vote for PHP support in Google App Engine
function sign_petition() { throw new Exception('I WANT PHP may use your email address to personalize your experience on their website.'); } try { sign_petition(); } catch (Exception $e) { echo 'No thank you: ', $e->getMessage(), "\n"; } -- Homer: You know what? Grampa: What? Homer: We're both screw-ups. Grampa vs. Sexual Inadequacy On Thu, 2008-04-10 at 13:40 -0500, Shawn McKenzie wrote: > Paul van Brouwershaven wrote: > > Have you seen the Google App Engine already, the guys from Google are > > crazy! You now can host your application on the Google network, > > including Big Table and GFS! > > > > Ok, one problem... they currently only support Python for programming, > > but the good news is that they will add more languages like PHP in the > > future. > > > > To get PHP as the next language that will be integrated on Google App > > Engine, please give your vote at there Project page at code.google.com!! > > > > http://code.google.com/p/googleappengine/issues/detail?id=13 > > > > Read and see more about Google App Engine: > > - http://code.google.com/appengine/ > > - http://code.google.com/p/googleappengine/ > > > > Regards, > > > > Paul > > Looks like there is a petition also: http://i-want-php.appspot.com > > Sorry, I meant: > > > echo " > Looks > like > there > is > a > petition > also: > http://i-want-php.appspot.com";; > > ?> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Associative vs normal arrays
No functions that I can think of but you can write one like this: $arrayType = 'numeric'; foreach($myArray as $key => $value) { if(!is_numeric($key)) { $arrayType = 'associative'; } } Also remember that an array can be both! Larry > Is there a way to determine if an array is associative or not? Maybe = > something similar to the is_array() function ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: excluding same field values in mysql
In your query throw a 'DISTINCT' in right after your 'SELECT'; Sunfire <[EMAIL PROTECTED]> wrote: > hi > im making a mailing system for a company. i have to find all email addresses > in a table and send email to all of them. the problem comes in when more > than 1 company has the same email address (owned by same person). what i > have to do is if more than 1 company has the same email address only use one > of them that are the same for the email not all of them.. > example: > company1 email: [EMAIL PROTECTED] > company2 email: [EMAIL PROTECTED] > in the example above i want to only use one of those addresses since they > would end up getting 2 emails and that wouldnt look right.. > code i have so far is: > //connect to db stuff here > $query=mysql_query("select company, Email from members"); > while($mail=mysql_fetch_array($query)){ > mail($mail[Email], $subject, $message, "from: $sender"); > echo "mail was sent to: $mail[company]"; > } > echo "go back to main menu"; > ?> > works fine except only using an email address 1 time if more than one of the > same email.. > anybody have any ideas how to fix this? > tnx > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php