Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. Sounds like what happened is some spammer bot posted in one of your topics, and you've setup the forums to send you an email whenever a new post is made. Disable the email notification if you'd prefer not to get notified when spammers end up posting to your topics. You can change your notification preferences by clicking your name in the top right, going to 'My Settings' then 'Notification Options'
  2. You need to change the way your code is generated. For PHP file containing the form should generate the code, then have the image generation script read the code. Eg: <?php //... $_SESSION['code'] = mt_rand(1000, 9999); ?> <img src="captcha.php"> //... imagestring($image, 10, 8, 3, $_SESSION['code'], $textcolor); //create image with all the settings above. header ("Content-type: image/png"); // define image type Then to verify, compare what they enter with $_SESSION['code'] and see if they match.
  3. If you want the value returned to PHP in a different format, you need to use DATE_FORMAT on the column in the columns of the first SELECT, not in the sub-query. SELECT patients.*, addobs.*, DATE_FORMAT(addobs.datetime, '%d/%m/%Y %H:%i:%s') as datetimeFormatted FROM addobs INNER JOIN patients ON addobs.MRN = patients.MRN WHERE addobs.datetime = (SELECT MAX(OLAST.datetime) FROM addobs AS OLAST WHERE OLAST.MRN = patients.MRN) AND addobs.par > 6 AND NOT addobs.hidden = 'yes' AND COALESCE(patients.ward,'') != 'dc' order by addobs.par ASC That will select the field addobs.datetime with the new format under the name datetimeFormatted. So in your PHP you'd access it as $row['datetimeFormatted']
  4. NULL works well, particularly in case #2 which for inheriting. As an example our current permissions system uses that setup, each permission group has a master view/edit/delete setting. Then overrides for various areas can be added and each override provides yes/no/default options for each of the view/edit/delete settings. In the query then I can easily check the setting for a particular area using: SELECT COALESCE(ovr.CanView, mst.CanView) as CanView FROM users u INNER JOIN permissions mst ON u.PermGroupId=msg.PermGroupId LEFT JOIN permission_overrides ovr ON ovr.PermGroupId=mst.PermGroupId AND ovr.AreaId=$AREA_ID WHERE u.UserId=$USER_ID If an override for the given area does not exist, or it's CanView is set to NULL (meaning use default) then mst.CanView will be returned instead of ovr.CanView thanks to COALESCE. This concept can apply to multiple levels, each level is just an additional JOIN and another entry in the COALESCE function. So far 3 levels as described in the first post is the deepest I've used it. Indeed, each child record would need a IsCustomized field or similar. This case I've generally used more when changes to the master generally shouldn't affect child records, the settings are just inherited on creation. I've done a few views to try and help keep the end queries more manageable/readable. Some queries still end up being a bit big and a pain though. Perhaps there is a way I could re-structure the views to make them better, I'll need to evaluate that. As for my current project, of the two methods #2 is probably the route I'll go. Since the issue has come up a few times I though I'd get peoples opinions on the matter and see if maybe there was a third option I hadn't thought of.
  5. Hey Folks Looking for some opinions on how best to solve a particular problem that has come up a few times in various areas of an app I work on. Here's the gist of what I need to accomplish. I need to create a setup in which various settings can be defined at multiple levels. Take three levels for example: - Master - Group - Individual The master level defines the system-wide defaults. For each group that is created, settings can either be "Use Defaults" which means use the master values, or customized for that group. The same principal applies to the Individual level. In the past, I've generally solved this one of two ways: 1) Copy the settings from the previous level when an item is created. or 2) Leave the setting NULL in the DB for that level and do a JOIN for each of the other levels, using COALESCE to get the first non-null. Neither feels particularlly great to me. They both have their own disadvantages 1) Changing the master doesn't change the other levels without some extra code to update everything else. 2) Can result in some messy queries due to the extra JOINs Wondering if anyone has any better options they use when dealing with such a problem.
  6. Ideally you should not perform the request until there is a pause in the typing that way you don't end up just creating a bunch of requests only to immediately abort them. You can do this by using setTimeout to delay the function for a period of time. Eg: var timeout=null; var request=null; function onSearch(value){ if (timeout) clearTimeout(timeout); timeout = setTimeout(function(){ if (request) request.abort(); request = $.ajax({ type: "POST", url: url+'searchManager', data: {search:value}, success: function(html){ $('#theResult').html(html); } }); }, 150); } That will delay the request for 100ms so that someone typing quickly will not cause a bunch of requests to be created then aborted. Only a single request will be made once they have a small break in typing.
  7. That library does use the bcrypt algorithm, it just wraps up some of the complexities behind using it into convenient functions, making it simple to use.
  8. You should learn you use PDO or Mysqli. Mysqli has a procedural style interface if you want to hold off on OOP for a bit longer. Also you should use something other than md5 for hashing passwords. MD5 is weak to collision attacks and also a fast algorithm which means it is easy for an attacker to run through possible hashes very quickly.
  9. Yes, see this post for some details on why.
  10. Rows that have NULL for the ward would not match. In order to match a NULL value you have to use either IS NULL or IS NOT NULL, checking using = will always fail to match. You could use COALESCE to change nulls to an empty string for comparison. AND COALESCE(patients.ward,'') != 'dc'
  11. You're going to give a better explanation than "not working". What are you expecting to happen? How are you determining if it is working or not? Are there error messages?
  12. Your link needs to point to the new URL: http://www.demo.com/demo/cards-aces. You need to go through your site and update your links to access the proper URL. You seem to be mis-understanding the way mod_rewrite works. It doesn't change your links from the non-friendly url to the friendly url. It converts a friendly url into an unfriendly url. The links you present to the user need to be in the friendly format to start with.
  13. -> is used by to accesses a member of an object (function or property)=> is used by to define a key/value pair. For example: $dtobject = new DateTime('now'); //A new datetime object $dtobject->format('m/d/y'); //Access the format method of $dtobject and execute it. $arr = array( //Define a new array 'somekey' => 'somevalue' //Define a key/value pair to store in that array ); No, likewise you cannot use -> in place of => when dealing with arrays. It is an application of variable-variables. What happens is PHP uses the value of $name as the name of the property to access. Eg: $field = 'firstname'; $obj = new stdClass; $obj->$field = 'kicken'; var_dump($obj->firstname); //Shows 'kicken' because the value was assigned to $obj->firstname It loops through all the public properties of $obj and assigns them as a key/value pair to $var (property name [key]) and $value (property value [value])
  14. You must not have looked very hard then, because Opened up just a handful of the ones listed and nearly all of them offered per-month pricing.
  15. Are you typing in the new URL when you load the page? That is what you need to be doing. You might try clearing out your browser cache/history/autocomplete too incase it is remembering the redirect that used to be in place.
  16. That bit of code assumes that $fdarray is multi-dimensional, but your code before that only creates a single dimensional array. Update the code above to create a multi-dimensional array as is expected and it will work.
  17. That doesn't help me understand it at all. In any case, I still have no idea what it is you really want to do. Do you want to create an image of what the rendered page would look like in the browser? For that you'd either need a app that can render HTML to an image or you'd have to install a browser and some screen-capture software on the server to load the page and snap the picture. If that is not what you're trying to do you need to do a much better job of explaining yourself.
  18. That should just be $this->last_name="scott"; You don't use the $ before property names.
  19. Also margin: 0 auto is for centering a block-level element, such as a <div> or a <p>. If you want to center text (or an inline element) within it's block, then you use text-align: center; to accomplish that. Eg: <p style="border: 1px solid black; width: 50%; margin: 0px auto;">This is left-aligned text inside a centered half-width paragraph.</p> <p style="border: 1px solid black; text-align: center;">This is center-aligned text inside a full-width paragraph.</p>
  20. That is going to be evaluated as: $userName = (filter_input(INPUT_POST, "userName") && $bName = filter_input(INPUT_POST, "bName")); $userName is going to be assigned the result of the && operation which is going to be either true or false depending on the arguments. Rather than trying to do both assignments on the same statement, just separate them into two statements. $userName = filter_input(INPUT_POST, "userName"); $bName = filter_input(INPUT_POST, "bName");
  21. Name them as an array rather than a numerical sequence. Then you can do a simple foreach loop over them. On the previous page: <select name="secondDD[]"> ... </select> <select name="secondDD[]"> ... </select> Then on the PHP processing side: foreach ($_POST['secondDD'] as $boxIndex=>$boxValue){ //$boxIndex is the box number: 0, 1, 2, 3 etc... //$boxValue is the selected option's value. }
  22. Remove the R=301 from there. By including that you are telling the browser to request the rewritten URL which means it will update it's display to show the updated url of /demo/cards.php. By not including the R=301 then apache does an internal sub-request for the updated URL so the browser never knows about it and continues to display the originally requested url of /demo/cards-aces
  23. Unless you have a RewriteRule to go from the old URL to the new URL using a real redirect (ie the R flag) then the new URL will not appear in the browser. Mod_rewrite changes the URL and does an internal sub-request within apache, the browser never has the slightest idea that the URL has been changed. You need to have the browser make the request using the new URL format in order for it to appear which means A) Your links should be using this format from the beginning, update any links you have on the site to the new format B) If there are still old links you want converted, you need to do an actual redirect from the old to the new format using a Location: header, which can be done using the R flag in RewriteRule If that is not your issue you may need to explain better because I'm not entirely sure what your trying to say is not working. Posting your rewrite rules may be handy also.
  24. It is a URL, and there is no clicking required for it to pull the image. You output an image tag such as: <img src="get-author-image.php?screen_name=someHandle">When the browser sees that it will make a request to get-author-image.php?screen_name=someHandle in order to load that image. That script then contacts the twitter api, locates the correct image URL for the given handle and forwards the browser there using a Location: header.
×
×
  • 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.