Jump to content

Cupidvogel

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Everything posted by Cupidvogel

  1. Thanks. Can you migrate this question to Application Design, or should I ask this question there again?
  2. I am stuck just at the beginning. That is, say, I have the database designed, and the client side prepared. Now I have to design the PHP. So how do I do it? And what did you mean by This is pretty much "dynamic web pages 101"?
  3. I have noticed that in Stackoverflow, there are basically 4-6 kinds of different URLs. One is for questions, like DOUBLE vs DECIMAL in MySQL. One is for user profile page, like http://stackoverflow.com/users/1469954/cupidvogel. One is for new question, like http://stackoverflow.com/questions/ask, etc. With each page request, the server sends a page as required. Now how do I achieve this on the server side? Should there be one catchall PHP script, which will parse the URL to note what type of page is the client asking (for example, if it parses the URL and finds out that the client is asking for a topic page, it will perhaps extract the question id/text from the URL, query the DB to fetch relevant data, construct the HTTML and send it) and send it accordingly, or should there be separate scripts for each page type? And for either, how do I configure PHP/Apache for this? If I have a page like foo.php, I can see it through http://localhost/foo.php. But if I want it to capture http://localhost/foo.php as well as http://localhost/foo.php/ask/questions, etc, what do I have to do?
  4. So part from the caching bit, this is just like the canonical method of the URI module in Perl which normalizes URLs, resolving unnecessary up and down traversals within the address to give it in a compact form?
  5. Thanks. Please do it and explain what is happening. I am too new to PHP to do these tests myself!
  6. Hi, can anybody explain what is meant by realpath in PHP? In particular, I was studying the documentation for the clearstatecache function in the PHP manuals, it has an optional first boolean parameter named $clear_realpath_cache, which determines whether or not to clear the realpath cache for the file mentioned as the 2nd parameter. So what difference will the absence of the first parameter make?
  7. Wow! So now tell me, is there any situation at all where I should be using $mysql->query($query) instead of the prepared statement? That is, for any data coming from the client side, whether data they have inputted, or data the page itself had hardcoded (for example, attribute of some element), should I always use prepared statement?
  8. So if I use a particular query, like Select * from foo where boo='bar', and I need to use it more than once in the same script, using prepared statements will increase the speed/efficiency?
  9. Hi, we need prepare statements in MySQL to dynamically query or update databases, for it has no exec or eval type of statement that will execute the statement as if it were code, right? However, why do we need a whole slew of prepare related functions in PHP-MySQLi as well? Surely all the variables we intend to bind, we can easily include them in a normal query string where they will auto expand, and then we pass the statement to MySQLi, from where we will get the same result?
  10. Thanks. That looks simple enough, dunno why didn't it occur to me.
  11. Hi, surely we all have seen in Facebook questions like Which of the following IMDB top 250 movies have you seen?, followed by a list of check-options with a button, which on clicking fetches all the members who have voted for that option (if there are two many number of such users, as for this particular question, where each option may be voted by more than a million users, the user-list is retrieved only partly and continues do so on subsequent requests from the client). Question is, how can the list of users be stored in the database? If the survey poll has an id of say, 123, the it is fair to assume that there will be a table like username_123, where there will be a column containing the option value, then one containing the option text. How to insert the list of users? One way may be by storing the user names in a string, delimited by space, and on requests, send the string to PHP, where PHP uses regular expression to split the string and extract the usernames. However the process looks very clumsy, and very painstaking, given the fact that the column value will have to be frequently updated as more voter vote, or some of the existing voters unvote (either by withdrawing their vote altogether, or voting another item in case of radio-buttons). Any idea, anyone?
  12. Please explain solutions 2 and 3 in detail, I am kind of new to PHP! When should I call session_write_close? What is meant by session data? I mean, once the user is logged in, how can a script log out of it during a polling request while the user still continues to browse other pages and expect the pages to be personalized? How come MySQL and memcache help here?
  13. Hi, I was reading an article on long-polling at http://www.nolithius.com/game-development/comet-long-polling-with-php-and-jquery where I found the following lines (scroll down a little in that page to view this, under the PHP sleeps across the entire session heading): I didn't quite understand what it means. Suppose I have a webpage foo.php, and it contains two updateable parts, one calls coo.php to update asynchronously, while the other calls goo.php. Now both coo.php and goo.php themselves poll the database, returns the result set if they get any, or wait for, say, 15 seconds before polling the database again, and this continues, until the total execution time exceeds 100 seconds, upon which PHP results the empty (or populated) result-set. The Javascript on the client side receives that empty or populated data and immediately sends another request. Now aren't these two requests to 2 different scripts (albeit from the same script) independent of each other, or is it that when coo.php sleeps, foo.php and goo.php is forced to sleep as well?
  14. I didn't get what you said. Whatever data I saved was saved while I was active, so how can that be undone when I close the browser?
  15. Yeah. Like in Facebook, where once you log in, you remain logged in for good...
  16. Well, if the client's IP address can change, how ill PHP session help in this case? And I don't know about cookies, but are the information stored by them sent automatically to the server when the user requests a page from that domain, either by clicking a link or typing the address into the address bar?
  17. Oh, so that's why cookies stand out you say, because it can uniquely identify a computer even if others are using the same IP as well, and thus avoiding all gotchas others have mentioned here? My method will fail on a WiFi network if multiple users are using the same browser, because each will have same IP address?
  18. Ummm, can't I extract the MAC address out of the IP address for individual page request? I mean, even if the IP addresses are same, there has to be some way of differentiating two computers!
  19. Yeah, I shall stick to the norm, I just want to know what are the holes in this process. Firstly you said shared computer. Obviously if two users are using the same computer, then the server will have no way of knowing which user is requesting the page, so it will send the page in conformance with the currently logged in user (in fact, even cookies can't help in this case, can they?) I don't know about the IP address change problem. Please explain, I have almost zero knowledge about networking. And multiple browsers are quite possible, that is why I am storing the browser info of the logged in user as well, so that a page request from a different browser provides a normal page.
  20. No no, when the user logs in, say with a user-name of foo, the server will naturally assume that each subsequent page request from that browser in that IP is coming from that user (it will store the user-id, IP address, browser info in a table). Surely if you log in to Facebook, then go to bathroom without logging out, and in the meantime your brother clicks a link to one of your female friend's page, the server will think that it is you, and send a personalized page accordingly?
  21. Umm, I don't know whether I am looking for an alternative, I just felt that this is really neat, so I wanna know whether this is feasible or not...
  22. Hi, I was just wondering about the necessity of using cookies and session_start() to preserve state and provide personalization. Why can't it be done this way: The user logs in, the script adds the IP address of the client, together with his account info (say user id), and browser name, to a MySQL table, and configures the table (by setting a MySQL event) to delete that row after, say, 30 days (if not the user logs out in between, in which case the row is explicitly deleted). Now each time a page request comes from that client through that browser(as verified by grabbing the IP address and browser info), a check in the session table is done to see whether that IP address is in that table. If yes, it means that a user is logged in, and after grabbing the user id (necessary, because many users can log in from the same IP, whether from one or more than one browser), an accordingly personalized page is sent to the client. If no, then it sends just a normal page. Is it feasible or possible?
×
×
  • 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.