Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. I see no difference between the two? You can use either, they have no real difference in JavaScript. You just need to make sure you close the string with which ever you opened it with.
  2. You need to look at the where clause as to why this isn't working. When you printed out the SQL as phpchamps suggested, was the game ID a valid ID within the database? -- If you run select * from gamedetails where gameID = <<that ID>>;, does this return the correct data?
  3. I don't think you've understood how mysql_fetch_array works. It only returns 1 record per-call; meaning you need to loop through, calling it each time, until their are no more records. This is easily done with a while() loop: while ($record = mysql_fetch_array($query)) { // do something } I'd read the manual and take a look at the examples.
  4. To make things easier you may also want to define a kind of "HREF_BASE" constant within your global file, so that at the start of links you can use it without having to worry about the structure of the lang param. So for example: define('HREF_BASE', 'path/to/site/' . $lang); You could then use that within your links like: <a href="<?php echo HREF_BASE; ?>/my_file.php?normal=parameters">...</a> The output of the href being: path/to/site/en/my_file.php?normal=parameters -- this is assuming you're going to use mod_rewrite to create the search engine friendly URLs?
  5. You don't want to primarily use a session variable. Remember that you need to be passing this parameter *every time* in order for search engines to know the difference, which means you should always have $_GET['lang'] available. Plus if the user changes the language you want it to instantly update. In the situation where it's not passed (for whatever reason) then you can use the session variable, just to ensure the user doesn't suddenly get a different language.. Try something like: if (!empty($_GET['lang'])) { // primarily look for the lang parameter $lang = $_GET['lang']; } elseif (!empty($_SESSION['lang'])) { // if not look for the session lang $lang = $_SESSION['lang']; } // check if $lang is set and valid if (isset($lang) && in_array($lang, $valid_langs)) { require '/lang/' . $lang . '/index.php'; // set session lang for later $_SESSION['lang'] = $lang; } else { // else use default require '/lang/en/index.php'; }
  6. A 'search engine friendly' URL (i.e. /en/index.php) would be better, but yeah pretty much. Your code's on the right track, but you leave your file system a little vulnerable. You need to check that the entered language is actually valid: $valid_langs = array('en', 'fr'); if (isset($lang) && in_array($lang, $valid_langs)) { // ... You'll probably want to store that array within the global file you mentioned before. I'm also assuming you're going to declare $lang else-where in the code (and not rely on register globals)?
  7. No it's not a problem, if you do it right. You also don't need to have multiple pages, you could for example use mod_rewrite to turn a request like /en/page_name.php into page_name.php?lang=en.
  8. http://stackoverflow.com/questions/2153949/seo-implications-of-a-multi-lingual-site-with-detection-of-system-culture
  9. I'd definitely take an approach along the lines of spambadger's suggestion, but there's many ways of doing it. Think about when you make a structural change to the HTML and have to make the same updates multiple times; could become a very tedious task if you decide to add even more languages later. For future reference by the way, instead of: substr(strrchr($_SERVER['PHP_SELF'], "/"), 1); You can just use basename on $_SEVER['PHP_SELF'].
  10. You can't really just ask how it's done; that's like asking how do you build a car. What particular area of it confuses you?
  11. You only *need* to convert the characters to HTML entities when you're outputting to the browser. You don't want to store them converted in the database like that as the data would be inaccurate for comparison, but also the size of the string would be modified which may cause problems if the username has a max char length.
  12. With regards to "stealing a user's browser", that would depend upon the implementation. Really you shouldn't depend upon them just having the right session cookie, you could for example also validate them based upon IP. Cookies can be stolen and manipulated, you should never trust them. Why is this a problem? What if I were to login in at home, leave my machine on, and come to work. I'd be unable to log-on. Or what if I just moved to another machine in my house? Have you read about XSS (cross site scripting)?
  13. Yes. You could submit a request to the Twitter API using cURL.. http://apiwiki.twitter.com/ http://php.net/manual/en/book.curl.php
  14. You've written the code to parse them into an array, yeah? So on that array you could just extract them into the variables.. Although seems odd you'd want them in variables and not an array?
  15. .. Sorry, what's the question?
  16. The second comment on the manual for sleep suggests using session_write_close - don't know if you've seen that?
  17. Look at the order in which you have the field names in your insert statement: And then the order in which you have the values:
  18. Displaying the image is no problem, it's positioning it. As ohdang888 said there'll be plenty of jQuery (or other framework) plug-ins available, but I shouldn't think something so simple would really need a bloated plug-in. Can you give more information on how you want the pop-up positioned? Plus, are you using a framework or just standard JavaScript?
  19. "so any changes of table height" - there's no standard event that will allow you to automatically do this. Instead you'll need to identify what can cause changes in the height, and bind a function to an appropriate event there (or to several elements). @priti I think you mean .css('height'), but better is .height() -- the latter returning a unit-less pixel value. Using standard JavaScript makes this a lot more awkward, but you may have some look with .clientWidth/.clientHeight or .scrollWidth/.scrollHeight. The only problem being the differences between browsers make them very hard to work with reliably. If you're already using jQuery (or another framework) I'd definitely use the built-in functions.
  20. You're not showing the code in which you're defining the ALT attribute.
  21. I think this is a little easier on the eyes: /\[youtube=(.+?)\]/
  22. You need to be way more specific with your problem. What errors are you getting, or what are you seeing?
  23. Could you not provide (within code tags) the related code? Also what do you mean by: ...As that doesn't make any sense.
  24. Well when I tried to access the URL it just kept loading, which suggest it's not a permissions problem. Also I'm able to access your index file in that directory, so your server/computer is accessible. What exactly does the code do / could you post it?
  25. A better method would be to use regular expressions for this kind of complex string replacement. Have a good read into preg_match and preg_replace! Passing the 'e' modifier to preg_replace() will allow you to evaluate the code within the replacement parameter -- similar to eval() really but in the situation below a lot less risky. $str = preg_replace('/\[user\](\d+)\[\/user\]/', "getusername($1)", $str); So the expression: \[user\](\d+)\[\/user\] will only match user tags with both an opening and closing tag, and with 1 or more digits in the middle. The matched digits are placed into the string containing the function, which is then evaluated and $str updated with the username. You'll obviously need to make some modifications to use that in your own code, but it's the general idea.
×
×
  • 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.