Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Sure, not the recommended solution, but it is an option. Since it's an object, it would be much better to pass it in as a parameter. With php5 all objects are passed by reference. The other more OOP solution to this is to use the registry pattern, where you have a singleton registry object that you can get access to wherever it is needed, and typically things like configuration data, and database resources would be added to it, and thus can be made available inside functions, with a static method call. Zend framework has an implentation you can look at just to get an idea: http://framework.zend.com/manual/1.11/en/zend.registry.using.html
  2. I don't know what you mean by this. CPanel is just a web administration system. It does seem to indicate that there is a permissions issue with the script.
  3. Your script emits a form. Then in the same script you attempt to read the value of the variable that will come through via form submission: ($_GET['search']). In other words, the way the script is written it is inevitable you will receive this warning. array_key_exists is one technique that you can use to determine whether or not you should enter the processing part of the script that assumes the form was already submitted and there will be a value to look at in $_GET['search'].
  4. Yes, for functions you need to either pass the variables in as parameters or declare them global.
  5. This error occurs when? on move_uploaded_file? What is the exact error message.
  6. gizmola

    about mysql

    Read these: http://us3.php.net/manual/en/mysqli.query.php http://www.php.net/manual/en/reserved.variables.post.php mail
  7. Please use php or code tags around any further code. I editted your post this time.
  8. ORDER BY ce_cal desc will return results from largest ce_cal to lowest. If there is something more specific you're after you'll have to provide further explanation.
  9. gizmola

    about mysql

    This is not how things work here. You start working on some code, and we will help you.
  10. What is the exact error message you are receiving and when does it occur. -You talk about file permissions, but then you imply that this is a mysql issue (update table). File system permissions have nothing to do with mysql permissions.
  11. Wrong. As you stated correctly, the built in authentication works on directories. Thus you DO want to use php code to restrict access to files -- there is no other option. The ways you can do this with php are described here: http://php.net/manual/en/features.http-auth.php What's nice about this is that you can use your own user table or file rather than using something like the htpasswd program that requires shell access or some wrapper script and is typically difficult and confusing for people who aren't sysadmins.
  12. Sounds like a configuration issue with your host. Use firebug to look at the net console and see what is happening when you click on the link.
  13. If you can't install pecl thne a pecl package isn't going to be of help to you. Extensions by their nature require a php install that is configured to allow for their use. Why can't you install pear/pecl? Without them you'll need to compile php.
  14. jQuery also simplifies javascript and DOM access into a compact one function api that is a lot easier for people to learn than having to hack native javascript which is quirky and hard for a lot of people to understand, due to its prototype based design and first class functions. There are so many little quirks you have to keep in mind with javascript and the dom/css that it's a lot easier for people to use a clean framework/api, especially when you have a number of people that have to work on and maintain the codebase.
  15. On a *nix host, you can exec this: find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r | head -n 1 Replace the "." with whatever the parent directory is of the tree you need to check. I'd probably do something like this: $lastchanged = `/usr/bin/find /path_to_search -type f -printf '%TY-%Tm-%Td %TT %p\n' | /usr/bin/sort -r | /usr/bin/head -n 1`; Keep in mind that this is going to scan the filesystem everytime it's called, so if this is a large tree, that could be some substantial IO. The filesystem is not an indexed database. The results you get are going to look like this: 2011-06-11 12:42:55.0000000000 /home/david/foo.txt So you would have to break the string into pieces but that is something done easily with explode.
  16. Well to be clear, single quotes creates a string constant. Because "\n" is an escape code that has to be replaced by php with a newline character, it requires interpolation (variable replacement) so, this is the reason you need the double quotes around it. It's not because single quotes doesn't work right -- it's simply not intended to perform interpolation.
  17. On the contrary, there is probably a way to get "it" to work. You have never stated what "it" is clearly enough for anyone to give you any meaningful advice.
  18. Your question doesn't make any sense. I'm going to guess that what you are really asking is, how can you make the results Distinct only on the basis of the product_id. The answer is: you can't with DISTINCT, and quite simply it doesn't make any sense to expect that the database should arbitrarily exclude rows from a result based on no actual criteria, which when you come right down to it, is what you are asking mysql to do. The way to achieve this is to apply a group by on the column, although again, I feel it important to point out that the result set will be arbitrary in the sense that the values for the other columns will be completely arbitrary. Add a GROUP BY products.product_id to the end of the query.
  19. Howdy, Your code makes a form. The target of the form is paypal.com. Even if the target was the same script you would not expect this to work without emitting the same form again, however, as the target is paypal.com it most definately will not work, or I should say, there is no way that $test will ever have any values in it. I'm really not sure what you're trying to do here.
  20. Did you even glance at his code?
  21. Well I think it wouldn't hurt to have a faq that summarizes what we wrote here, since this comes up regularly enough, and also we probably all get PM's from time to time about it. Easier just link to the Faq.
  22. Yes either should be able to handle the auth. Try just moving the critical things into header() calls. header("Content-Type: application/json)"; header("Authorization: VKEY ".$key.":".$signature);
  23. JonL, I know you are doing your best to try and help increase the knowledgebase. This is one of those questions we get a lot where the OP was not clear and that's a big reason why this never seemed to get a satisfying conclusion. Let's be clear about some web development related definitions. cookie A cookie is a key/value pair that is stored (or not) by the client (browser). There are plenty of issues and gotchas in regards to cookies, specifically in how to set their expiration and the relevant domain that could explain problems the OP had. Cookies are set by the browser when a request is sent to do so in the HTTP header. So this requires that the setting of a cookie needs to occur before any output has been sent. Once a cookie is set by a browser, it then sends the cookie data in the HTTP header of any subsequent requests, and php makes this cookie data available in the $_COOKIE superglobal array. It's important to note the importance of HTTP headers in both cases. You can't for example, set a cookie in your script and then go read it from $_COOKIE in the same script (chicken and egg). session cookie A cookie that will be automatically deleted when the browser "session" ends, or in other words, when the browser is closed. A cookie is a "session cookie" when you don't specify an expiration when the cookie is created. By default the php session id cookie happens to be a "session cookie" in that it does not set an expiration date, although like just about everything else with php sessions, this behavior can be modified. php session A php session is an automated serverside mechanism that will associate a bundle of data with a session id, and serializes/unserializes it for every request where sessions are invoked. Note that a "session cookie" has nothing to do with php sessions. The preferred way that the php session data is associated with a browser/user/client is through the setting of a cookie. php session variables These are created by making an assignment to $_SESSION for an active session (one where session_start()) was called. $_SESSION variables are just like any other array when a php script is executing, except for the fact that the values are serialized to disk (by default), and will be automatically unserialized and made available in the script in the $_SESSION superglobal array. Given all the confusion possible, it is understandable that there are various ways to approach doing something in particular related either to cookies or to sessions. Again, while it was never clear from the question, many people need to know how to terminate a session, usually because they want a logout feature or redirect that clears things out. PHP provides a way to do that: session_start(); session_unset(); session_destroy(); Some people have claimed that the values in the $_SESSION superglob will live on in a script beyond the session destruction functions unless you assign it to an empty array. I haven't had this problem myself so I can't speak to it. Rather than unset($_SESSION) which will completely disable php session functionality in the rest of the script, you can instead do: session_start(); session_unset(); session_destroy(); $_SESSION = array(); The PHP manual specifically advises against using unset($_SESSION) so I don't think we should endorse it. I think it's worth going back to the original question. Can you make the browser delete a "session cookie" as defined above? The methods he tried did not include simply setting the cookie with an empty value: setcookie('account', ''); Again it has to be emphasized that if I made that call in a script, I would still find $_COOKIE['account'] to have a value even though I requested that the client browser "overwrite it with nothing". On further requests however, the value would not be there. It's also important to note that the OP never provided code that had anything to do with php sessions. He seemed to be setting his own cookies and using them for whatever reasons, so discussion of $_SESSION is probably a complete tangent from the the original post.
×
×
  • 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.