Jump to content

PaulRyan

Members
  • Posts

    876
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by PaulRyan

  1. @QuickOldCar, by refresh, I think he means the vote count is reset every day back to 0.
  2. The image rotation issue, is usually to do with photos taken on a mobile device (iPhones are the main culprit). I'm sure there is a way to detect if the image is rotated, let me get back to you on it.
  3. The forgot password function you are trying to implement isn't really viable. Anyone could go on to your website, enter someone elses username and then reset that persons password. The best method is to firstly, allow a person to enter their username. Send an e-amil to their e-mail address with a password reset link. The link will go to your website, and you will then send out a new password for them to log in with. The benefits of the above is that, if I went to your website and entered a username, the password wouldn't change, unless the user associated with that username clicked on the link sent to them.
  4. You could in fact use .htaccess to parse the .js file as PHP, so it will run the file and parse any variables etc. <Files ~ '^(global.js)> ForceType application/x-httpd-php </Files>
  5. Hello, I'm Paul Ryan. I am 23 years old and have around 8 years experience in programming with the following languages: - PHP - MySQLi - HTML - CSS - JavasScript (jQuery, AJAX) I have worked on many project over the years, including the following: - BoxSelect.com - Taccd.com - FTA.ie - BelfastCookerySchool.com - Dittnyebad.no - MassasjeShop.no - Project: Universe (Personal Project) I have worked on many other smaller jobs, updating outdated code, database and code optimizations etc. You can contact me via the following methods: - PHP Freaks Personal Message - Skype: paulryanmc91 - E-mail: paul.ryan.mclaughlin@gmail.com I am available to start work immediately whether the job be big or small, don't hesitate to contact me. Thanks for your time, look forward to hearing from you. Kind Regards, Paul Ryan
  6. Bar and is correct. You're current statement equates to, that if the user is not an admin or if the users cannot view users them the access is denied. If either one of those is false, then they don't get access. You need to change it to && not ||.
  7. This is quite simple, you should look at pow to complete this. See the following: <?PHP //### Start at 1 $currentNumber = 1; //### While true, continuos till break is hit while(true) { //### Multiply the number by itself $number = pow($currentNumber, 2); //### If the number is less than 20000 display it //### If the number is greater than 20000, break the while loop if($number < 20000) { echo $number .'<br>'; } else { break; } //### Add 1 to the current number $currentNumber++; } ?>
  8. I agree with Ch0cu3r, you have far too much repetition in your code. You have also miscalculated the amount on the pension, it is 2.5% not 25%. So the multiplier would be 0.025 not 0.25. I have restructured your code as follows, I haven't done anything. <?PHP //### Function to return tax amount function tax_amount($salary) { if($salary >= 500000) { return $salary*0.45; } else if($salary >= 300000) { return $salary*0.35; } else if($salary >= 200000) { return $salary*0.2; } else if($salary >= 100000) { return $salary*0.1; } else { return 0; } } //### Set pension contribution amount $pensionContribution = 0.025; //### Employee data in an array $employees = array(array('name' => 'Aron', 'gender' => 'm', 'dob' => '1930-01-25', 'position' => 'manager', 'start_date' => '1998-01-01', 'gross_salary' => 635000.00), array('name' => 'Britney', 'gender' => 'f', 'dob' => '2001-05-06', 'position' => 'researcher', 'start_date' => '2001-03-15', 'gross_salary' => 420000.00), array('name' => 'Daniel', 'gender' => 'm', 'dob' => '2003-01-15', 'position' => 'officer', 'start_date' => '2003-12-06', 'gross_salary' => 260000.00), array('name' => 'Jessica', 'gender' => 'f', 'dob' => '2002-11-21', 'position' => 'officer', 'start_date' => '2007-02-20', 'gross_salary' => 350000.00), array('name' => 'Peter', 'gender' => 'm', 'dob' => '1998-01-07', 'position' => 'assistant', 'start_date' => '2009-09-06', 'gross_salary' => 250000.00), array('name' => 'Keith', 'gender' => 'm', 'dob' => '2003-07-25', 'position' => 'intern', 'start_date' => '2012-06-27', 'gross_salary' => 90000.00) ); //### Iterate over employee data foreach($employees AS $employee) { //### Add tax amount, pension amount and net salary $employee['tax_amount'] = tax_amount($employee['gross_salary']); $employee['pension_amount'] = ($employee['gross_salary']*$pensionContribution); $employee['net_salary'] = (($employee['gross_salary']-$employee['pension_amount'])-$employee['tax_amount']); //### Display employee data echo '<pre>'; print_r($employee); echo '</pre>'; } ?> As you can see, it is a lot easier to read and see what data is where. I also created a function to return tax amount. I calculated the tax amount, pension amount and net salary during the while loop so it's less code to write.
  9. You should really being storing dates in the database as DATETIME. Which would look like '2013-09-29 15:04:00', which is human readable and also easier to work with as you can manipulate the value in the query quite easily, and also manipulate it in PHP just as easily too.
  10. Edit* - Thought it was wrong function, actually malformed time string. <?PHP $string = '2013-09-27 14:00:01'; $timestamp = strtotime($string); if($timestamp < ($_SERVER['REQUEST_TIME'] - (60*60*24))) { echo 'True'; } ?>
  11. You must be hitting the DDOS protection of CloudFlare, which means you or others are accessing the website too many times, so they are limiting your access.
  12. How about you give us the url to work with? Will help someone, to help you.
  13. @Denno - If the posts array does not equal a number that is divisible by 3, then your code will not close the final div. Try this instead. <?PHP //### How many per row $perRow = 3; //### Keep count of posts per row $perRowCount = 0; //### Start output $output = ''; //### Dummy data, replace with your own $posts = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10'); //### Iterate over each post foreach($posts AS $post){ //### If there is no remainer from division, open container if($perRowCount%$perRow == 0) { $output .= '<div class="container">Container Start'.PHP_EOL; } //### Add the comment element with data $output .= '<div class="comment">'. $post .'</div>'.PHP_EOL; //### IF the remainer from the division is 2, close the container ready for opening another next time round if($perRowCount%$perRow == 2) { $output .= 'Container End</div>'.PHP_EOL; } //### Increase per row count $perRowCount++; } //### If the remainder from the division is not 0, then close the final open div if($perRowCount%$perRow != 0) { $output .= 'Container End</div>'.PHP_EOL; } //### Echo the output echo $output; ?>
  14. A possible cause which I myself encountered, is instead of using "localhost" as the host, use "127.0.0.1" as the host.
  15. Try this <?PHP $string = "abc 12,345 def"; $stringElements = explode(' ', $string); foreach($stringElements AS $key => $element) { if(preg_match('/[a-z]/', $element)) { $stringElements[$key] = strrev($element); } } echo implode(' ', $stringElements); ?>
  16. It is still allowing me to log in using the method I posted earlier.
  17. I am able to log in to your system by doing the following. Inspect Element in Firefox, I change the "uname" field to "uname[]" and the "password" field to "password[]". Then any information I enter will allow me to log in.
  18. @vinny42 - it is valid JSON, of you look at the code, it opens the file and reads line by line, each line by itself is valid JSON.
  19. Echo out both queries to make sure they contain exactly what you expect. Then check the database for the id you are updating/selecting.
  20. On the first query, you need to surround the $page variable with quotes.
  21. Here is how I would do it: Feature Videos Table CREATE TABLE IF NOT EXISTS `featured_videos` ( `video_id` int(11) NOT NULL, `featured_date` date NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Cron Job <?PHP //### Connect to database $conn = mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); mysql_select_db("test"); //### Set how many to select $videos = 5; //### Select max ID $selectMaxQuery = "SELECT MIN(`id`) AS `min`, MAX(`id`) AS `max` FROM `video_tbl`"; $selectMax = mysql_query($selectMaxQuery, $conn) or die(mysql_error()); //### Check to see if rows are returned if(mysql_num_rows($selectMax)) { //### Assign record to variable $selected = mysql_fetch_assoc($selectMax); //### Select videos randomly $start = mt_rand($selected['min'], $selected['max']-($videos)); //### Now select videos from database $selectVideosQuery = "SELECT `id` FROM `video_tbl` LIMIT {$start}, {$videos}"; $selectVideos = mysql_query($selectVideosQuery, $conn) or die(mysql_error()); //### Check for returned rows if(mysql_num_rows($selectVideos)) { //### Start query $insertVideosQuery = "INSERT INTO `featured_videos` (`video_id`, `featured_date`) VALUES "; //###Iterate over each row while($video = mysql_fetch_assoc($selectVideos)) { $videosArray[] = "({$video['id']}, NOW())"; } //### Add to end of query $insertVideosQuery .= implode(',', $videosArray); //### Execute query $insertVideos = mysql_query($insertVideosQuery, $conn) or die(mysql_error()); } } ?> And to select the videos <?PHP //### Connect to database $conn = mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); mysql_select_db("test"); //### Select videos from featured table $selectVideosQuery = "SELECT `vt`.`id`, `vt`.`vid` FROM `featured_videos` AS `fv` LEFT JOIN `video_tbl` AS `vt` ON `vt`.`id` = `fv`.`video_id` WHERE `fv`.`featured_date` = CURDATE()"; $selectVideos = mysql_query($selectVideosQuery, $conn) or die(mysql_error()); //### Check for videos if(mysql_num_rows($selectVideos)) { //### Iterate over each row while($video = mysql_fetch_assoc($selectVideos)) { echo '<pre>'; print_r($video); echo '</pre>'; } } else { echo 'No videos to show.'; } ?>
  22. It can be optimized to be more efficient than you have it, could you show me the table structure of the "featuretbl"
  23. I was thinking the same, but it seems like over kill for 3 videos?
  24. MilboW, you replies aren't the greatest, 1 or a few word replies will not allow us to help you. Please show us the code inside the functions getReplies() and getPostById().
  25. I'm assuming that the OP has stored the start time of what ever task is being performed. Providing they have, they can check on submission of a form or something, to see if a certain amount of time has passed and if it has, then they have ran out of time to perform said action.
×
×
  • 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.