Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. Remember, PHP scripts are executed from the top down. Having: $form_message = true; if ($form_message) { ?> <!-- html --> <?php } Will simply spit out the HTML where it is. Why does it work for $form? It works because you set $form as false before you check for it and try to output the form. Again, top-down execution.
  2. The HTML will always show because you're always setting $form_message as true. What you need to do is check if the form has been submitted first, then set $form_message accordingly.
  3. jQuery is worth using simply for its AJAX API.
  4. First, never, ever, ever use 'global'. Parameters to functions should be passed in via the functions' argument list. That's why it's there. Functions have a public interface - their names and what parameters should be passed in. 'Global' adds an implicit requirement which is hidden to the system at large, since the requirement is not a part of the function's interface, and ties the function it's used in to the larger context of the system, which negates one of the points of using functions to begin with - modularity. I don't know where beginners get the idea to pass parameters in via 'global', but it's the absolute wrong way to do it. Find a better tutorial site/book/instructor. Second, with all that said, adding another if-conditional is easy: function metadescription($db) { //checks if it's our category page if (isset($_GET['cat_id'])) { $cat_id = mysql_real_escape_string($_GET['cat_id']); $query = "SELECT * FROM categories WHERE cat_id = '$cat_id'"; $result = $db->query($query); $result = $db->fetchrow($result); $metadescription .= $result['cat_meta_description']; if (empty($metadescription)) { // run additional query and do stuff } } return htmlentities($metadescription); }
  5. I think you have to use count. feed[0][count(feed[0])-1] JavaScript, not PHP.
  6. You don't need to use a loop. Just access the element at feed[0][feed[0].length-1], if your feed[0] is actually an array itself.
  7. What is the second one then as it doesn't return any syntax errors when i run it... It's not returning any errors because you're using bitwise OR rather than logical OR. | is for bitwise operations, || is for logical operations. So, the following: if($fileExt != ('jpeg'|'jpg'|'png'|'gif'|'pjpeg')) Is saying "If $fileExt does not equal ('jpeg bitwise OR'd with 'jpg', bitwise OR'd with 'png', bitwise OR'd with 'gif', bitwise OR'd with 'pjpeg'), do the following...." For what bitwise OR actually is, see: http://en.wikipedia.org/wiki/Bitwise_operation#OR Suffice it to say, your particular OR's do a particular thing, which isn't what you want them to do.
  8. We're not mind readers. Code and context is required.
  9. Right, except the second one is not valid PHP and will not work.
  10. Because it's not? You have two options - use double quotes and have the variable value automatically substituted for you, like: $s = "<a href='../u/{$r['feedusername']}'>"; Or use single quotes and concatenation: $s = '<a href="../u/' . $r['feedusername'] . '">';
  11. That's not Flash, it's JavaScript. @web-developer - you need to tighten up the language you use on your pages, specifically with verb usage. Example: On your 'About Us' page, you have: 'is having', grammatically, makes no sense. What you need is: 'Has' denotes ownership, in this case. There are many other examples of that kind of thing sprinkled throughout the site. I realize that English is likely not your first language, but since the site is written in English, and is aimed at an English-speaking audience, you'll need to fix the grammatical oddities.
  12. That's one way to get that variable, yes. Also, once again, your data members should either be private or protected, depending on whether or not you anticipate making child classes. Making them public breaks encapsulation. In other words, do this: class testClass { private $config; // rest of class }
  13. The easiest way to do it is to fill a template with the data retrieved by the server. That's how the pros do it. Stores like Amazon don't have individual pages for each item they sell. Rather, they have a generic template which they fill with a particular item's info. shopping.php?item=0001 should essentially be something along the lines of (most general psuedo-code possible): if isset($_GET['item'])) { // query database for item based on the GET value passed in. // include item template, which will anticipate and display that info } That said, you'd probably be better off using a MVC framework for this, which would help automate and organize the process for you while making everything more extensible in the long run.
  14. It's telling you that you haven't created an $array variable at that point. You can't use functions on something that doesn't exist.
  15. Unless you plan on serving your pages as XML, there's no real point in writing XHTML anyway. XHTML is essentially dead. It never went anywhere, and I doubt there will ever be a new version of it. Stick with HTML 4.01, with some HTML 5 enhancements. It's far easier regarding doctype.
  16. Then you read it incorrectly.
  17. Re-read what it says. Only the name attribute for those particular elements has been deprecated. Note that input is not on the list.
  18. That doesn't tell us much. Where is your JavaScript being invoked in relation to your HTML?
  19. I don't know if this will help, or if it's something you already know, but your $inside variable must not be set in those cases.
  20. Like the sticky says, you can't have any output sent to the browser before attempting to send a header. Your form is output. You need to redesign your page. As a hint, well-formed PHP pages do all of their processing first, then show output.
  21. Hmm... nothing is jumping out at me. You may want to double check your regex in do_clickable, since that seems to be the method that actually creates a clickable link. You can test regex here.
  22. That's because you have spelling errors. <inpuy type="hidden" id="cat" value="emf-meters" /> <orm action="" method="GET">
  23. Please put all code in either tags or tags. I took the liberty of doing it for you above.
  24. Have you manually tested one of your stored strings with just html_entity_decode to see if it's all being decoded properly?
  25. Which method is responsible for what you're trying to do: do_clickable or parse_message? Also, what's with all the globals? Globals and OOP should not be used together. Globals really shouldn't be used at all, regardless. Look into OO design patterns and concepts.
×
×
  • 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.