Jump to content

virtual_odin

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by virtual_odin

  1. I am running this query to establish whether the subordinate is in the office today. Tables are: people - person specific data hierarchy - which has the relationships between manager and subordinate absence - start and finish dates of absences It works fine if there is at least one entry for the subordinate in the absence table, returning the id of only those available. But it does not return people if they are not in the absence table at all. The work around is a dummy entry as each user is created, but to me this seems inelegant when it must be possible to modify the query so it also returns values where `subordinate` has no entry at all. Your help would be much appreciated. I have tried endless permutations of AND NOT OR NULL etc and I just know it is in there somewhere but cannot get my head around it...
  2. In all my queries * returns all the values in the row. is what I am looking for help with, please.
  3. I'm probably missing something obvious but I cannot find a simple solution to this issue. I have two tables, users and comments. In the latter is a column for user id, so I have a query with a LEFT JOIN and the COUNT function to find out how many comments each user has made. I am also using the MAX function to know when the most recent comment was. So far so good. What I would like is to pull out a field from the comments table that corresponds to the latest comment made by each user. Here's the syntax so far SELECT `users`.*, `countries`.*, COUNT(comments.author) AS ct, MAX(comments.submitted) AS last_comment FROM `users` LEFT JOIN `countries` ON `users`.`country_code` = `countries`.`country_code` LEFT JOIN `comments` ON `users`.`id` = `comments`.`author` GROUP BY `users`.`id` ORDER BY `nickname` ASC As ever any help would be much appreciated.
  4. Thanks, but I have mastered storing the files outside the web root bit on my host. Turned out not to be half as difficult as I had thought it would be; perhaps it is in one of the more recent Plesk upgrades. Double bonus, I have put my MySQL credentials in a similar folder, which I had always known was good practice but had struggled to deliver. Now I have to do the same for my other sites... Tim
  5. Thanks Scott. I'd done the scripting bit and I once knew that I should use a directory outside the web directory; but had forgotten! Part of the reason for the forgetfulness is that on the host I have it is really tightly locked down (error: open_basedir restriction in effect), but I'll have to investigate opening up the permissions. Tim
  6. I'm trying to create secure document storage for my users. In general, access to the secure area (more than this docs area) is by a username and password stored in a MySQL database (md5 encoded) and session variables to create just one login. Each page tests the session variables are correct and this seems to be working fine. I'd like the same credentials to determine access to the documents directory. I've coded that from the php pages which pull up the documents, but the directory itself, has to be CHMOD 777 in order to allow the uploads, so is there for all to see, if they knew where to look. So the question: is there a way to protect the files in this directory using the session credentials. I don't want to use .htaccess because it would mean aonther log-in for my users. Grateful for any thoughts. Tim
  7. I've found the below, which seems to be pretty much what you are suggesting. Does your book give any help on R squared? Thanks. /** * linear regression function * @param $x array x-coords * @param $y array y-coords * @returns array() slope=>slope, intercept=>intercept */ function linear_regression($x, $y) { // calculate number points $n = count($x); // ensure both arrays of points are the same size if ($n != count($y)) { trigger_error("linear_regression(): Number of elements in coordinate arrays do not match.", E_USER_ERROR); } // calculate sums $x_sum = array_sum($x); $y_sum = array_sum($y); $xx_sum = 0; $xy_sum = 0; for($i = 0; $i < $n; $i++) { $xy_sum+=($x[$i]*$y[$i]); $xx_sum+=($x[$i]*$x[$i]); } $m = (($n * $xy_sum) - ($x_sum * $y_sum)) / (($n * $xx_sum) - ($x_sum * $x_sum)); $b = ($y_sum - ($m * $x_sum)) / $n; return array("slope"=>$m, "intercept"=>$b); } var_dump( linear_regression(array(1, 2, 3, 4), array(1.5, 2.1, 1.3, 1.4)) );
  8. Hey! It's been years since I did a stats course, but I know what these babies can do... And Excel has this built in! I now need one for a site I am building. If only I could find the code to generate the results from my dataset. I really do not fancy going back to school to re-learn how to construct them and then have to convert those principles to PHP. I'm easy as to whether it is PHP, taking a two dimensional array and producing the a, b (as in y = ax + b) and the correlation, or MySQL (I'm running version 5 and I saw somewhere that some additional functions in v5 might help. As always, thanks in anticipation.
  9. Many thanks haku. I'm sure you're right. I'll have to put in a str_replace() to intercept that user input option. I also tried it with IE6 and 8; and 6 is OK, 8 has the same error. So much for upgrades...
  10. Try as I might to track down this error, I cannot. I get no errors in Firefox, no errors in Firefox emulating IE, no errors in Netscape or Opera but in IE7.0.5730.11 a horrid little debug box appears when I Load the page. The site is http://www.garfagnana-food.com/. Worse, IE seems incapable of giving me more information about the nature of the error. The line number it points to doesn't seem to exist in any of the files I have looked at! Your assistance, as ever, would be much appreciated.
  11. htmlentities($_POST['comments'], ENT_QUOTES, "UTF-8") has fixed this. Sorry to have bothered you...
  12. Two suggestions - are you sure the server version of the script is the one you have updated - no mistakes in file name, has it uploaded correctly, etc. Second, try a hard refresh on the page f5 or reload (I can never remember which goes deeper).
  13. I am wondering why you want to do this yourself rather than use paypal or one of the other payment systems. I use paypal myself and their back-end integration is pretty straightforward once you find the bit that works for you (they have to cater for so many, that bit was something of a trial, but I made it in the end). That way your customers have a reputable service to whom they give their details and you get payment and a confirmation but no credit card details to worry about.
  14. I have a textarea in a form where users frequently enter a Euro symbol (€). As I have attempted to do here. I'm using htmlentities to strip out quotes and the like and when I get the result it is a gibberish. Like "â�¬" and in view code "â�¬" The code is htmlentities($_POST['comments'], ENT_QUOTES) I tried making it htmlentities($_POST['comments'], ENT_QUOTES, utf8_unicode_ci) But got an error "htmlentities() [function.htmlentities]: charset `utf8_unicode_ci' not supported, assuming iso-8859-1 in ... on line 99" I'd be grateful for any suggestions. I would use a str_replace to convert the € to the word euro or €, but I don't know what the original symbol would be. I cannot enter it directly.
  15. Thanks Lumio. You are on to the right track, I think. I had not thought to use JavaScript. But I get an error when I run your suggestion. Any ideas?
  16. I want the frame I am extracting from to be the current frame having navigated there say from a search engine, so in the code I don't know what it is. I guess therefore what I am asking is how do I dig out the actual address of the second frame? Here's the idea (not working...) http://sandbox.club-host.com/pic.php
  17. I want to create a frames page where one frame is a php script (triggered by a form button) which reads the content of the other frame. The script will look for certain patterns, eg images, links, etc. Any suggestions gratefully received.
  18. You could try overLIB. It is a really useful class for just this sort of thing developed by Erik Bosrup. Here http://www.bosrup.com/web/overlib/
  19. The workaround can be seen by clicking "Testing" on the same page - http://example.club-host.com
  20. OK, I am creating a control panel pop-up to allow administrators to change certain style settings on a page. The settings themselves are stored in a MySQL table and once the new set-up is acceptable, can be saved back to MySQL so that every future impression of the page is in the new style. So far so good. I have also successfully changed the master document by writing the new style back to the main page using the id/name of a tag, but this requires every instance to have a unique id/name because otherwise if the names are the same, only the first instance of the object is changed. In fact the document has multiple instances of the same style/class. So I want to set up the styles in <head></head> and call them each time they are needed with a class= tag. Bottom line: can Javascript change these style settings in head and have the document change as a result? If so how? My workaround if this is not possible is to save the changes as they are made and re-load the page each time, but I would have to do some fancy footwork to allow regression and it all sounds heavy, when just re-writing the styles would be really neat. As always, I would appreciate suggestions. The test site here is http://example.club-host.com (please excuse the gross colours - they are just there while I sort out table layout, etc). Click on "Admin" to see the control panel.
  21. If I am pulling out the right log, I get Is that the log you mean?
  22. My objective is to allow a list of people (email addresses) to send email from their usual email client, such that the server sends it on to another list of email addresses automatically. CWH build doesn't support the imap functions, so my first idea of a cron job on the mailbox using PHP's imap_open() etc won't work. The help desk advise that I could, at my own risk, use the Procmail filters to pipe mail to a script on the machine which would handle the email as it enters the system. However I am familiar with neither Perl nor Procmail. I have loaded Dada mail to help with this, but its "send from email" feature does not want to work. I have a call in to them. I have found .procmailrc and persuaded it to run a script that I have found. .procmail looks like this: INCLUDERC=/etc/ALAquota/overquotarc VERBOSE=on RECIP=$1 MAILDIR=$HOME/mydomain-mail LOGFILE=$HOME/mail.log INCLUDERC=$HOME/dada.rc INCLUDERC=.procmailrc and the file dada.rc looks like this: :0 * $RECIP ?? ^^list1@mydomain.com { :0 | /home/mydomain/www/cgi-bin/dada/plugins/dada_bridge.pl } ## where list1 is the address for the distribution list The log I get is: I am pretty sure something needs setting in mydomain.com/cgi-bin/dada/plugins/dada_bridge.pl or one of its supporting files, but when I try to load it I get a server (500) error. So my question is one of two. Either has anyone been here and fixed it? If so, how please?. Or has anyone another solution to suggest. As always grateful for any advice. Tim
  23. I'm running on 3.23.49, so I think this is one for the future...  Thanks anyway
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.