Jump to content

AmandaF

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by AmandaF

  1. Thanks, good to know. I seriously need to learn more about mobile browsers. Gangster, do you want the changes to affect everyone who views the site, or just that specific person? You can set a cookie if you only want the changes to be visible to that person. Otherwise you're going to need either a database or a file or something on the server that keeps track of what's been changed. If you really don't want to use sql, you can always write the changes out to a text file. (Read this for more info: http://www.tuxradar.com/practicalphp/8/0/0) For security purposes, though, it really would be better to use a database.
  2. You don't want it displayed for usability/aesthetic reasons, right? The CSS and JS solutions given are fine if that's all it is, but if there's a security issue involved keep in mind that the user can always get around the css and js by disabling them in their browser.
  3. http://dev.mysql.com/doc/refman/6.0/en/pattern-matching.html Apparently _ is the equivalent of . in SQL regex. ??? I guess you could try escaping it.
  4. Most (all?) browsers interpret onclick as hitting enter while tabbed onto an element in addition to clicking the mouse, so onclick and onchange are equally accessible in this situation. It's just with onmouseover and other mouse-specific functions that you need to include a keyboard equivalent. But other than that, yeah, what Axeia said.
  5. You can use preg_replace to escape the newline characters or replace them with HTML tags (<p> or <br>). Just keep in mind that different OSes represent newlines different ways, so the user's OS will affect how the linebreaks are encoded. (If I remember correctly, it's \n in Linux/Unix, \r in OSX and \n\r in Windows.) So you might want to replace all occurrences of \n\r with \n, and then replace all occurrences of \r with \n, and then replace the \n with \\n or <br> or whatever.
  6. In addition to PHP's date function, MySQL has a date_format function that does the same thing. You might find that that saves you from having to use varchar (you could store the date as a datetime and call date_format in the query).
  7. 1) I thought vikela would need to be able to identify which row the result belonged to. 2) Thanks for catching that for me.
  8. Neil, thanks. Axeia, error handling is what I'm trying to do. I don't need an assert because I'm not trying to prove that something can or can't happen, and I don't need a plain if/else because I want the user to know if their inputs are invalid.
  9. Are you trying to do a foreach loop? I don't think "as $key => $value" works outside of the context of a foreach loop.
  10. If vikela doesn't want the ID, then SELECT ID, colum_that_vikela_wants_the_max_of FROM table ORDER BY column_that_vikela_wants_the_max_of LIMIT 1 Of course, if the column isn't unique and more than one row has the max value, then only one of those rows will get returned. In that case, it would be better to use the max() function.
  11. I'm working on my first serious attempt at creating a php class. (As I said in another thread a few weeks ago, I'm trying to make the transition from programming procedurally in ColdFusion to object-oriented programming in PHP). I know that I can extend the Exception class to make my own custom Exceptions, and was wondering if it's considered good practice to only do this when necessary, or to make all exceptions custom. For example, let's say I have two methods, setFoo and setBar, both of which throw errors if their arguments are false. Which of these would be considered better: class FooBar { public function setFoo($foo) { if(!$foo) { throw new Exception('Foo is false!'); } } public function setBar($bar) { if(!$bar) { throw new Exception('Bar is false!'); } } } class FooException extends Exception {} class BarException extends Exception {} class FooBar { public function setFoo($foo) { if(!$foo) { throw new FooException('Foo is false!'); } } public function setBar($bar) { if(!$bar) { throw new BarException('Bar is false!'); } } } On one hand, the first example seems better because I can use the methods without having to remember which type of exception to catch. On the other hand, the second one seems like it would be better because it makes it easier to determine which type of error occurred. So what's the standard way of doing this?
  12. What are you getting when you try using LIMIT? SELECT ID FROM table ORDER BY ID DESC LIMIT 1 would have been my solution. Is that what you tried?
  13. Technically, it would pick up on it. Since the page is read linearly, though, if the change is made to a part that was already read, the user wouldn't realize it. As far as I know, the best way to get around that is to make sure all the content can be accessed without javascript (i.e. make sure your page "degrades gracefully") and then give the user some way to turn off the changing content. One way I've read about is to make a checkbox that says something like "check this box if you're using a screenreader" and position it off-screen with css, so sighted users don't see it.
  14. It won't wrap because it's not supposed to wrap mid-word. You can insert soft hyphens into the text to make it wrap mid-word. The soft hyphens will only appear if they're necessary for wrapping the text. For example, if you write really­long­word instead of reallylongword, and reallylongword is 4 characters or fewer too long for the div, it will become: reallylong- word If it's more than 4 characters too long, it will become really- long- word because that's where you put the soft hyphens.
  15. Hey, no need to apologize! It's good to consider different approaches to the problem.
  16. Actually, I was just thinking: If all you need is the ability to make templates, why not just get a copy of Dreamweaver and use their template system, rather than learning an entire language? Learning PHP just to make templates is like buying a Swiss Army knife when all you need to do is slice bread. Dreamweaver lets you create a template file, associate it with html files, and then any time you edit the template it automatically updates all the files. There are also probably cheaper/free programs with templating capabilities similar to Dreamweaver's.
  17. Also, this one: http://www.tuxradar.com/practicalphp It's literally the entire contents of the O'Reilly book "PHP in a Nutshell", put on the web in a wiki format.
  18. Like stewart said, you can use the css overflow:scroll to create the same sort of scrolling effect that an iframe would have. I'm not 100% positive about this, but I'm pretty sure it will work as well on a table cell as it would on a div, so you don't need to stop using a table-based layout to do it.
  19. well, this way all the js and css is kept out of the html, so it's better for separation of content and presentation. Also, is noscript valid xhtml? I don't know why, but I was under the impression that noscript tags were sort of an archaic, hacky way to get around js problems.
  20. If you know that the field in your WHERE clause is unique, then only one row will get returned regardless. (e.g. "SELECT * FROM foo WHERE ID = $bar" when ID is the primary key). My question was whether using LIMIT 1 has any effect on the efficiency of the query. (like if it makes MySQL stop searching as soon as it find the row, whereas without the limit it would keep searching even though it already found the one row it's going to return.) Also, the IT department gets weirded out when I try to hug their database servers...
  21. It worked! Using javascript to insert the css to hide the menu did the trick. Thanks, Ken2k7. I ended up using the DOM instead of innerHTML, because IE doesn't allow innerHTML to insert things into the head. I also ended up using display:none for IE instead of the css positioning thing I'd been doing, due to css bugs in IE7. (I'll try to figure out how to get it working in IE7 later, but that isn't really relevant to the javascript problem I was having, so I'm flagging this thread "solved".) In case anyone reading this is having similar problems, here's the relevant parts of the code. (Note that it's not in a function to run on load. It runs the moment it's found by the browser.) var add_css = document.createElement('style'); add_css.setAttribute('type','text/css'); var css_text = document.createTextNode('ul#nav li ul{position:absolute;left:-999em;height:0;}'); //or display:none or whatever the css should be try { add_css.appendChild(css_text); } catch(e) //the above try block fails in IE6 and 7 { add_css.styleSheet.cssText = 'ul#nav li ul{display:none}'; } document.getElementsByTagName("head")[0].appendChild(add_css); Thanks again, Ken2k7 and Nightslyr.
  22. What if you use the DOM instead of innerHTML? Something like this: function addRow() { var elem = document.getElementById('areas'); var input_min = document.createElement('input'); var input_max = document.createElement('input'); var newText = document.createElement('p'); input_min.setAttribute('type','text'); input_min.setAtttribute('name','minValues[]'); //Set the other attributes for input_min and input_max. I'm too lazy to write it out. ;-) newText.appendChild(input_min); newText.appendChild(document.createTextNode(' - '); newText.appendChild(input_max); elem.appendChild(newText); }
  23. What are you trying to use the object/iframe for? Is it something you could just put in a div, or is it something that requires a plug-in?
  24. You could just give them blank default values, e.g. $name = ''; $name2 = ''; etc. right before the loop. And now I'm going to make myself sound like a total noob: Then how do you get the values? I've always used while even when I know that there's only one row. Can you just write $row = mysql_fetch_assoc($result); without a loop? Does that actually have an effect on the speed at which MySQL retrieves the result? (using LIMIT 1, I mean, not hugging MySQL. ) Thinking about it now, it seems like that would make sense. It would just stop as soon as it finds the row, instead of going over all the rows. It never occurred to me before to do that, though.
×
×
  • 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.