Jump to content

ShaolinF

Members
  • Posts

    314
  • Joined

  • Last visited

    Never

Everything posted by ShaolinF

  1. Hi Guys I am trying to add a file which is located one dir above the current file dir. I do the following to includet the file: require_once('../myfile.php'); However this gives me a 'no such file or dir' error. Any ideas on where Im going wrong ?
  2. Hi Guys, I use the filter_var FILTER_SANITIZE_STRING to filter the textarea input. The function escapes any quotes (which is good) but when I print the data into the html the data is printed with the backslashes. How do I get rid of them ?
  3. Hi Guys Say I have a URL as follows: www.mysite.com/?f=all Now, if the user clicks on the next page I want to carry this variable so the link would be: www.mysite.com/?f=all&p=2 What is the best approach to doing this ?
  4. Hi Guys I am getting a POST variable which will be used to get page numbers (ie. mysite.com/index.php?page=1) Now, in my class I already have the following structure in place to ensure there is no tampering on the user end: isset($page) && is_numeric($page)) ? $page : 1; Is this enough ? Or should I also run it though the filter_var() function ? I assume the is_numeric function is enough to ensure the user doesnt try injecting malicious code but you never know.
  5. None of those worked until I changed the return statement to: return $_SERVER['REMOTE_URI'] . "?currentpage=$previous_page";
  6. Hi Guys, I have a function in my class which returns a string link variable. The problem is it keeps giving me a parse error. See code below followed by error message: function get_previouspage_link() { if($this->CURRENT_PAGE > 1) $previous_page = $this->CURRENT_PAGE - 1; return "$_SERVER['REMOTE_URI']?currentpage=$previous_page"; } Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\wordpress\wp-content\themes\alburujpress\paginate.php on line 50 LINE 50: return "$_SERVER['REMOTE_URI']?currentpage=$previous_page";
  7. Hi Guys Does anyone know of any good pagination implementations ?
  8. Hi Guys I have two dates I want to compare. Below is my current implementation. The problem with it is it always returns false: if(date("d/m/y", $course->finish_date) > date("d/m/y", $today[0])) // do somemthing else // do something
  9. Thanks for the replies. But the thing it is when I format the date I get the following result: 01/01/70
  10. Hi Guys Anyone know why and how I can fix it ?
  11. Thanks. I couldnt use the STR_TO_DATE() but I managed to use strtotime() to convert the date in a 10 digit date number. Now, I need to compare that date number will the current date to workout the difference between the two. I tried DATEDIFF(course_finish_date, CURDATE()) < 0 - Namely all dates that come BEFORE today, but it returns no results when it should. Any ideas where Im going wrong ?
  12. Thanks. Regarding strtotime() it looks like it does convert the string date but its format isnt being accepted. See error below: [incorrect date value: '1228867200' for column 'course_start_date' at row 1] STR_TO_DATE() seems to be a viable option. However I don't know how to implement it since I am inserting arrays into the DB so I cant really call the STR_TO_DATE() function. $DataArr = array('course_start_date' => $course_date, 'sometype' => 'value');
  13. Hi Guys I am having issues converting my user input date into something understandable by the DB. The user inputs a date with the following format DD/MM/YYYY. The DB column is set as follows: course_start_date date How do I convert the user date so that I can insert it into the DB ? I tried strtotime() but that doesnt work.
  14. Hi Guys I am trying to get all records that are less than the current date. See code below followed by problem: CREATE TABLE courses ( course_id integer auto_increment NOT NULL, course_finish_date varchar(10), PRIMARY KEY(course_id) ); SELECT * FROM courses WHERE course_finish_date < CURDATE(); The SELECT statement works but it doesnt return any results (when it should). I suspect the reason for this is because course_finish_date is a varchar and not a date/timestamp. The column stores the date in the following format: DD/MM/YYYY - Is there any way I can convert it to a date and THEN compare ?
  15. Hi Guys I am trying to format a timestamp from the DB using the date function but it keeps returning 1/1/1970. $date_posted = 2009-11-25 22:14:25 date( "d/m/Y", $date_posted); // = 01/01/1970
  16. Hi Guys I am using the func below to get the last number from the URL. It works, but I want to know if there is a better way to do it: example url: mysite.com/courses/100/ (100 is the post id) //Get the 100 from the URL $current_uri = $_SERVER['REQUEST_URI']; $data = explode("/", $current_uri); $post_id = $data[count($data)-2]; $post_id = filter_var($post_id, FILTER_VALIDATE_INT); echo "The number is" . $post_id;
  17. Thanks for the replies Well, I want to generate 10 digit random strings for my password salt. Will something like rand() suffice or should I go for something which produces more unique numbers (like the one on random.org) ?
  18. Hi Guys Are there any 'truely' random number/letter generators for PHP ?
  19. Hi Guys, I am trying to access the $validator var from my extended class but it keeps giving me the following error message: Fatal error: Call to a member function filterStr() on a non-object Code below: require_once('FormValidator.php'); class CoursesManager { protected $validator; __construct() { $this->validator = new FormValidator(); } } // ------------------------------------------------------ class NewCourse extends CoursesManager { function useValidator() { $var = $_GET['somevar']; $var = $this->validator->filterStr($var); } }
  20. Hi Guys Does anyone know how I can implement transaction committ and rollback on my sql transactions ?
  21. Hi Guys Does the foreach loop have an inbuilt iterator ?
  22. Thanks cags. BTW, do you know what the # expression does ?
  23. Hi Guys what do you think of the following approach to validate a 24hour time: http://snipplr.com/view/23007/validate-time/ Are there any better approaches ?
  24. Hi Guys What is the best approach to validate form date/times with the following formats: DD/MM/YY and HH:MM
×
×
  • 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.