Jump to content

franko75

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

franko75's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm trying to debug a sporadic 500 error which users occasionally get when filling out form sections on my site. Whenever it happens, I try to recreate their environment and fill out the form exactly as they have done, but can never recreate the issue. I have checked my application logs for the framework I am using, but they report nothing related to the error. I'm hoping someone here might be able to help me catch this. This is where the 500 error is sometimes happening and this triggers the error which users report: //In jquery AJAX function, which submits data to PHP form for processing error: function(data,transport){ $.validationEngine.debug("error in ajax response: "+data.status+" "+transport) } Is there a way for me to try and catch what the exact error is here? The problem is I can't recreate the error, either using an AJAX call or not to call the PHP script. I need to catch the error response from the PHP script being called, but I never get an error when trying to recreate the user issue, i.e same OS/browser/form answers. The Apache error logs for the site have very little - unless I'm looking in the wrong place. I'm on CentOS, ran locate error_log and got an error_log.txt file in my vhosts directory for my site, but this just contained a 302 message log, nothing else. I also tried locate error | grep mysite.
  2. Thanks Neil, that helped me track down the problem. Some relative paths in my php script which I've changed to absolute and all working now.
  3. Hi there, I am struggling to try and work out what is going wrong with a cron job i have running daily which opens up an imap mailbox and extracts a rar file to a directory on the web server. The script works ok when run manually, and when it is running from cron, I can see that it opens up the mailbox and reads unread messages, however, there seems to be an issue with extracting the rar file when running from the cron. Permissions are set to 777 on the relevant folder where the rar is being extracted to, so I'm not sure what's going on. My cron line is as follows: 05 20 * * * nicky /usr/bin/php -q /u01/www/vhosts/www.mysite.co.uk/httpdocs/imap_get_rars.php >/dev/n ull I'm a bit of a linux newb so any pointers in the right direction (or how to catch errors in this situation) would be great!
  4. Hi, I'm going round in circles trying to work out how best to do this, i don't think it should be too difficult but i'm making it that way! In my site, each time a member provides some data, I store it against an Entry for that member. The idea is that members who submit data consecutively from month to month will be rewarded at some stage. There are some parameters though: a member who returns to the site within 21 days of their last visit would not have this counted as new Entry, but just another submission for the same entry period as the previous one. Likewise, if the member returns to the site more than 49 days after the last Entry date, then the Entry number will not be consecutive but will be incremented by two, showing a break between the entries. This is what I've come up with to allow distinctions to be made between those members who fill in the data within the correct timeframes - hope it all makes sense! And to my code/design issue, can anyone help me to improve my code here and how best to add in the timeframes check? This is my model, which i'm trying to get to manage the entries, so that it returns the correct entry (i.e a new one - incremented by the last one by one or two, or an already existing one from the current period). Any pointers would be really appreciated! //example call from a controller after successful form submission - $this->entry is then passed around for use within that session $this->entry = $this->pet->update_entry('pet/profile/2'); public function update_entry($stage = NULL) { //get last number entered for this pet $last_entry = $this->last_entry(); //if part one, pet profile is calling the update (passing the next stage as a param) if ($stage === 'pet/profile/2') { //only at this stage do we ever create a new entry $entry = ORM::factory('data_entry'); //if no previous sessions, start from 1 if ($last_entry === FALSE) $num = 1; //here we need to check the time period elapsed since the last submission, still to be ironed out //for now just increment each time, but this may change else $num = $last_entry->number + 1; //save the rest of the data for a new entry $entry->number = $num; $entry->initiated = time(); $entry->updated = time(); $entry->last_category_reached = $stage; $entry->pet_id = $this->id; $entry->save(); } elseif ($stage !== NULL) { //echo $stage; correctly prints out stage //this must be a continuation of a form, not the beginning of a new one //timeframe checks to be added here //just update the stage reached and save $last_entry->last_category_reached = $stage; $last_entry->updated = time(); $last_entry->save(); //assign to $entry for return $entry = $last_entry; } return $entry; } /** * * Returns the the last data entry session */ public function last_entry() { return $this ->limit(1) ->data_entries ->current(); }
  5. I've probably not explained this very well, but there would only be one client accessing this specific script. It's going to be a controlled environment set up in a LAN and only running for 3 hours, so it's a fairly unusual set up, which is why I was unsure of the best way to handle it.
  6. Thanks for the reply Thorpe. Although PHP is stateless, I thought it would have been possible to trigger the sleep function to periodically update a file, i.e via a loop where an update is made to the file, then the script sleeps for 15 minutes, then continues into another iteration of the loop. Having said that, it would be a pretty messy and inefficient way to do this - as you say, a cron job would be the best suited for this I think.
  7. Hi, I want to set up a small php script which simply returns a string, either from an array or from a line in a text file. As well as returning the string any time this script is called, I also want it to automatically cycle through the set of items (either an array or each line in a text file) on a timed basis. For example, every 15 minutes I want the script to step through each item in the list. This script is part of an application which will be run on a LAN in a controlled space. What I'm unsure about is whether or not i can use php's time functions (like sleep()) to continue manipulating the contents of a file over a fixed period of time (3 hours). The script will also be getting called by a client app (Adobe Director) every 30 secs or so, where it will be returning the current element from the file. I've not actually done anything like this before, so i'd be interested to hear any advice. Thanks
  8. Hi, I've got a multi-part form (in a PHP MVC setup) which I have working correctly without javascript enhancement. I'm starting to add the AJAX form handling code which will handle each stage of a form submission, validating/saving data etc, before using AJAX to load the next stage of the form. I'm wondering how best to pass the URL of the next stage to the current form being processed, so that my jQuery form handling code can process the current form, then load the next part via AJAX. The form "action" is different from what the url of the next stage of the form is - what do you think would be good practice here? I was thinking about either appending the url of the next stage to the form action url, via a query string - then just use javascript to extract this url when the form is successfully processed. The other option is via a hidden form element. Not sure what other client side options I have here - half considered using the rel tag on the submit button of each form, but i'm pretty sure this isn't the correct usage of this tag. Any thoughts?
  9. Hi guys, I'm hoping for some feedback on a draft workflow and timescales i've put together for a potential web application i may be working on. The web application is more complex than what i've developed up until now, so i'm hoping i'm on the right track with what i've outlined below. It's difficult to know just how long things will take, especially the programming side of things, however i need to try and give estimates of how long each phase will take. In a nutshell, the project would involve 3 different user groups accessing a feature rich website. There would be a CMS, dynamic form creation, multiple databases, photo albums, system generated graphs/charts, free form query building for end users via a simple web based UI, a variety of reporting techniques and methods to export reports. All of this will take some time to develop and will involve lots of requirements capture and testing, something i've not done a huge amount of for standard CMS website development work. So I'm a bit apprehensive about the timescales part - I'd just be interested to know if what i propose below seems reasonable for a preliminary outline of my proposed approach. Grateful in advance for any pointers! Requirements capture Discussion/interviews with prospective stakeholders and relevant parties to ascertain exact requirements for the website. Use cases and activity/sequence diagrams will be provided for reference and analysis of proposed system behaviour. 5 days Conceptual Design In addition to ascertaining functional requirements in the requirements capture process, the conceptual design would be discussed and analysed by the relevant parties. The conceptual design would be revised until consensus is reached on the basic template to be used for the website. 5 days Design Implementation Phase The design implementation would involve the realisation of the agreed conceptual design through the creation of the necessary graphics, layout and stylesheet information. 3 days Database Design The requirements capture phase and the subsequent agreement on use cases, activity/sequence diagrams and analysis of the expected data would allow the creation of database designs and schema. These would be made available as Entity Relationship diagrams. 2 days Application Design, Iterative Development & Usability Testing The website would be developed using object oriented programming, which would follow the mapping of the application via UML diagrams, which would again be available for reference. At predefined milestones in the development process, usability tests would be designed and carried out with the intended end-users. Where necessary, the UI design would be modified following analysis of test results. 40 - 50 days User Acceptance Testing Functionality would be tested through managed UAT sessions with all end users. Bugs/issues would be resolved as and when discovered. 5 days Training Sessions Training sessions would be delivered to all user groups, along with comprehensive process reference guides. 5 days
  10. Hi, I'm looking at a potential piece of work involving a fairly complex data capture and management site and am wondering how best to approach it. I would be using a LAMP architecture. The backend will involve: Mass user creation via user uploaded csv file - I have done this before so am confident about this part. Once registered, users will submit confidential information on a regular basis. Although the data is confidential, I would simply be planning on storing this in a MySQL database, which would be backup on a regular basis. There would be different roles involved: An administrator, who would monitor user activity and create new roles and user accounts where required. End users - who would simply be supplying information via forms, with the ability to edit their profiles, view previous submissions and other basic stuff like that Management users - who can run a series of pre-defined reports on the data and display this information within the browser. They may also carry out "free-form queries" on the data as well as extract selected results as spreadsheets. A number of these standard reports would also be made available as web services/feeds. The free-form queries part is slightly concerning, as I don't know yet what the data actually is, plus there is a strong likelihood that new questions would be dynamically added to the data capture forms over time. The database structure would have to be flexible to accommodate this, plus I would have to provide this capacity for free-form queries, which I've never done before. Can anyone suggest a sensible approach to this? There would also be some form of versioning, so that if a user updates/revises certain data, the changes would be tracked and the previous record(s) would still be available. I would be planning to incorporate this into the database design, so that instead of updating and overwriting data in the database, a new record would always be created, with the "overwritten" one simply being flagged as archived. This way, I think I would always be able to retrieve the live data row, as well as the archived rows (organised by date). Does that make sense? Thanks in advance for any pointers, this is a bit more complex than what I've worked on before (mainly standard CMSs) - I think i know how to handle the above, but would be grateful for any advice a more experienced developer could provide.
  11. Yeah that all makes sense, thanks again. Re the error() function, i take it this could just be a private function inside the database class which you can pass an error to as a parameter (e.g mysql_error() or a custom error)?
  12. @premiso: thanks for the advice, i'll definitely do something similar for the development and in production stages. In terms of catching errors where they are thrown, for system errors (e.g db connection issues) I am throwing exceptions, but for errors caused in sql queries etc, i am returning error messages with mysql_error() - does this seem a reasonable approach? Also just realised my code wasn't correct in the first post - I've updated it using your snippet as follows: public function query($sql) { if ($sql) { $resource = mysql_query($sql); if (mysql_error()) { $this->error = mysql_error(); return FALSE; } else { return $resource; } } else { $this->error = "No query supplied"; return FALSE; } }
  13. Hi, I'm just looking for a bit of advice about how best to handle database errors - mainly, when to use exceptions and when to use error messages/codes. If i have a database class which i use to perform a query/update/insert/delete - how would you handle any errors by the queries failing? for example, i could do this: public function query($sql) { if ($sql) { return mysql_query($sql); } else { $this->error = mysql_error(); return FALSE; } } and call it with: $db = new Database; $query = $db->query("SELECT id, title, content, item_date, date_posted FROM news where status = 1"); Is it good practice then to check for errors for every query you perform, like this: if ( ! $query) $error = $db->error; //stop processing and show message to user else //continue processing I''m interested in finding out how other people handle this. Previously I used procedural php and didn't really check properly for errors in these types of situation (not good practice i know!).
  14. Thanks premiso, i'll update my constructor as you suggest. Any feedback on how i'm using exceptions as this is one of the main areas i'm not sure about?
  15. Thanks for the reply cooldude832. Think I understand what you mean, instead of hard coding the values in the config class, maybe set them in a config file which i include and then i can assign the config data to the class variables?
×
×
  • 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.