Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. I think you're looking for isset(), to check if the form was submitted. ex: if(isset($_POST['Submit'])) { // Was submited } else { // Wasn't submitted }
  2. If I understand you correctly you'd probably want to use explode() ex: <?php $str = 'CATEGORY: ITEM'; echo next(explode(': ', $str)); // ITEM In case you were wondering: next() is only ultized in my example to grab the second element (index of 1) of the array returned by explode(). Because the default array pointer is 0, so using next() increments that to 1 then returns that element. So it would be no different than doing: <?php $str = 'CATEGORY: ITEM'; $arr = explode(': ', $str); echo $arr[1];
  3. There's nothing wrong with your method, they both accomplish the same thing.
  4. If you're wanting to completely separate your HTML from your PHP and you want to take the next step I'd suggest studying MVC. There are many good Frameworks out there that implement this architectural pattern. Things like CodeIgniter, Zend Framework, etc.. It's not something you can familiarize yourself with overnight, but it's definitely worth it in the long run (Both using a Framework and learning MVC).
  5. Function Verify_email_address isn't closed, nor does it have ().
  6. Your conditional would look more like this: $result = mysql_query("Query to select what you're looking for.."); if(!mysql_num_rows($result)) { //Doesn't exist, insert it. }
  7. This comes up quite often.. For any practical use it's random enough, but it's still generated by some mathematical procedure.
  8. You can use regular expressions in PCRE functions like preg_match() to achieve this.
  9. Ah, I see: echo "$arr['something']"; // Invalid echo $arr[something]; // Invalid echo "$arr[something]"; //Valid echo "{$arr['something']}"; //Also Valid Seems a bit inconsistent (though I guess PHP is known for being notoriously inconsistent) , so I guess I'll stick with echo "{$arr['something']}"
  10. Change all of your values inside of VALUE(), accordingly: '$_POST[p_name]' should be: '{$_POST['p_name']}'
  11. First you would need to create a new image resource using imagecreatetruecolor(). Then using imagefill() you can fill it with black color. Finally use imagecopymerge(), along with a bit of math, to merge the two images together placing it in the center.
  12. Your example is exactly correct. What that does is loops through all elements of those arrays and performs that on each element. See array_map()
  13. On the first example without mysql_real_escape string you could easily enter ' or 1=1, which would make the query selected where the username and password are correct OR where 1=1 (which is everywhere, because it's always true). The second example where you're using mysql_real_escape_string, instead of or 1=1 actually being processed it's included in the value for password. So in this case it's password='1 or 1=1'.
  14. I don't see a closing } bracket..? Are you not posting the full code. And here's what I was talking about: <div id="footer"><h1>Copyright 2009 - CrazyQuest</h1></div> ... That's not PHP, so it shouldn't be read as PHP, right? Make sure you place ?> before it, so it knows where to stop.
  15. You're not closing the else statement's opening { with } (As MadTechie said), additionally you're not closing <?php with ?>, so PHP is trying to interpret your HTML.
  16. First off you're not even closing the echo with a closing ('), second off you must escape all additional single-quotes inside of the string. So: echo '<h3>What is crazyQuest?</h3> <p>CrazyQuest is a brand new online website that allows you to test your knowledge! These quests won\'t all be kitty, some of these quests may contain violence. But nothing bad! We believe that all our members should have fun! So, we make fun short and long quests for members to earn points.</p> <h3>Beta</h3> <p>If you signup for our beta, youll gain an extra 100 points that you can use in our shops! So if you want some cool prizes, we suggest you register today! Also, Beta accounts will have access to a special area that no other people can get into after the open beta. Beta members will also receive a crown by their name on the highscores.</p><br /><br /> <h3>Signup</h3> <p>You can signup here: <a href="register.php">Register</a></p> </div>';
  17. You have many mistakes. On the line before the one you mentioned (line 55 I suppose), you're missing a closing double-quote ("). Also, to use arrays inside of double quotes you must use curly braces. Ex: echo "{$r['ip']}"; Finally, you should always use single (or double, doesn't really matter) quotes when accessing elements of an arrays. So $r['ip'] not $r[ip].
  18. You'll need to use $_SERVER['HTTP_REFERER'], and preferably a regular expression to parse out the portion of the url you want.
  19. For WordPress see here. For the other blog it depends. Is it a custom built blogging system? Or is it some other popular blogging system? If the latter chances are it'll also have a configuration option. Otherwise we'd need to see relevant code.
  20. Are you using wordpress or not? If you are there's no need to edit WordPress when it can be easily changed from the control panel.
  21. Yea, but that forum is locked. Not just anyone can post in there.
  22. I'm pretty sure there's a configuration option to change that.
  23. You have a typo, it's mysql_fetch_assoc(), not mysql_fetch_accoc()
  24. I'm pretty sure that there aren't any built in functions for either of that; however, you can do that manually yourself using imagefontwidth() and imagefontheight()
  25. I'd use a combination of wordwrap() and explode(). That way you can easily display only full words, so you don't get things like "Yesterday there was a h... read more". Ex: $str = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."; $chars = 20; if(strlen($str) > $chars) echo end(array_reverse(explode("\n", wordwrap($str, $chars)))) . '... <a href="#">Read more</a>';
×
×
  • 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.