Jump to content

virtual_odin

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

About virtual_odin

  • Birthday 05/09/1953

Contact Methods

  • Website URL
    http://www.soane.net

Profile Information

  • Gender
    Male
  • Location
    London, England

virtual_odin's Achievements

Member

Member (2/5)

0

Reputation

  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.
×
×
  • 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.