Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. You wouldn't put something like this at the top of a bunch of files. You would put it in an initialization of your bootstrap or main controller script. Thus the environment would always be setup for use by any script. As for "putting it in the path" that is what that function does --- define the "php include path" that php will use to look for scripts that aren't in the current directory. The "default" path that is hardwired is the one in the php.ini, so this simply overrides that default, but once set, the performance hit is the same.
  2. So, you can rewrite your query like this, and solve your problem: $query = "INSERT INTO comments (user, comment) VALUES ('{$_POST['name']}', '{$_POST['comment']}')";
  3. See... so easy to find out the problem What is the table structure of the comments table?
  4. Forget the original script, that is irrelevant to the fact that you need to debug your issue, and you don't have any error checking around the database connections and queries.
  5. SOYLENT GREEN IS PEEEPLLLEEE
  6. Shouldn't it be "Phoop while you Poop?" I think that would be funnier.
  7. These type of scripts piss me off. You make database connections, and perform queries, and fetch, but never check to see if those work. $result = mysql_query ($query); Did this work? Well no worries, we'll go try and fetch from it anyways. Start with adding that code, and my guess is the problem will pop out at you. $result = mysql_query ($query); if (!$result) { echo 'Error: ' . mysql_error(); } else { // go ahead and try to fetch }
  8. I'll try and explain the function. As you stated, "shoe" in that example is a parameter. So when the function is called, a real variable will be passed to it in the function call. What can we tell about shoe from the context inside the function? The first thing done is: var source = shoe.getAttribute("href"); So "shoe" is assumed to be a javascript object that has the getAttribute method. You can look at a javascript reference or resource like this one and see that most of the objects in the DOM have that method. Sitepoint has an excellent reference on the javascript language and using that we get this info: http://reference.sitepoint.com/javascript/Element/getAttribute. Interesting to note that this method is described as "badly broken" in most browsers. So clearly what this method is trying to do is get the value of an attribute (object variable) from some javascript object, that has the name 'href'. What type of object has an attribute named 'href'? Well, if we can assume that this is not a user defined class, then the obvious one that jumps out is the anchor tag. Mylink Then you have: var placeholder = document.getElementById("placeholder"); getElementId() is used to locate an object in the DOM by it's id, where it would be something like: So in essence you can break this code down as a getting the url of a link, setting the "src" attribute (img tags have the "src" attribute) another object that has the id of "placeholder", and then getting another object with the id of "descript" and taking that same link, and using it's "title" attribute to set the: description.firstChild.nodeValue = text; If you do some reading, you'll find that nodeValue is the attribute of text nodes, so probably this indicates that "descript" would be the id of some block element like a paragraph. So the goal of this function appears to be to take an anchor tag that also has a title= attribute in the tag, and convert that to an image tag, with a text description above or below it. Basically, the way to go through this type of code, is to start at the top, and satisfy any confusion you have by doing research. You should also have a test script you're using to see what happens when you actually implement the function. Firefox + firebug is a great tool for exploring.
  9. Yes again, your posts are moderated, because you were warned multiple times not to double post, but you ignored the warning. Your warning level will decrease each day, and probably in a few days you'll be able to post again, but continuing your practice of posting the same topic multiple times will eventually lead to someone banning you from the forum.
  10. Ok, well there you go, did you make the file using the htpasswd program?
  11. In PHP the difference between double quotes and single quotes is minimal. If you use double quotes, the variable will be "interpolated". This means that php has to parse the string looking for "symbols" (blocks, variable and constants names) and if found will replace those variables with their values. It is always a good idea to start with the single quotes (which make a string constant) since they will not interpolate, unless you specifically want and need interpolation.
  12. A 500 error is an internal error. The only way to pinpoint this is to look at the various error logs you have setup, in particular the apache error log.
  13. There's also the meta refresh. The bottom line is that "forwarding" is a function of the browser. All PHP can do is to try and instruct the browser to change pages. It is up to the browser to accept or reject this request.
  14. Could you try to restate your question another way. I don't understand what you're asking. In terms of organization, the best practice is to put your classes into seperate files named for the class. Using this convention makes it easy to use autoloading. You can look at the documentation for PEAR, Zend Framework or symfony for examples. One example would be if you had a class named "MyClass" you could name the script, MyClass.class.php. What the autoloader will allow you to do, is use the class in your script, and when configured, if it can not find a direct include() for that script, it can search for a file that will provide the source for the class. It's very easy to setup the autoloader to take the class name, and then attempt to include a file named "MyClass.class.php". You can read more about this feature: http://php.net/manual/en/language.oop5.autoload.php
  15. No. PHP runs serverside. Javascript runs clientside (inside the browser).
  16. Take a look at http://www.simplemachines.org. Search on SSI. Here's one example: http://docs.simplemachines.org/index.php?topic=400.0 SMF has long been used by CMS's and Blogs to provide an integrated forum component.
  17. $_POST is an array. Like any array you can foreach through it. foreach ($_POST as $key => $value) { echo "Field: $key = $value "; }
  18. My advice is to make sure you have your site connected to the Google webmaster tools. Then you can send an email to Google directly pointing out the issue. They don't want sites exploiting their search engine.
  19. md5() simply takes a string and runs the md5 hash algorithm on it, turning it into a hash value. It's also what is called a 1-way hash, in that it is not like encrypt/decrypt where the value can be unencrypted. If you stored md5() version of the passwords when the accounts were created, then you can expect that this query might work. If not, then these will never match. The password column would need to be a 32 character string for this to work.
  20. l4nc3r's reply to you is correct. It might help you to look into the HTTP protocol a bit. Just to reiterate: session variables are stored server side. This is the advantage of using them -- they aren't disclosed. The way the server knows that the client has a session is via the session id. This is generated at the server and by default, gets set as a cookie. Cookies are passed in the HTTP header. On every request, the browser will send the full set of cookies it stored on prior requests for that serve domain/uri combination. So in the setting of the session, the server sends a request for the browser to create the cookie with the session id, and after that the client sends it back on every request. In an "ajax" call there is no difference to the server -- it still looks like a request coming from the client, and cookies are still sent, so the server script can do the same sort of checks for authentication that it would do if this was a non ajax request. Point of fact, there is nothing special about an ajax request at all -- it's still a GET or POST, and the format of data being returned is irrelevant in regards to authentication questions.
  21. The main difference is that the preg_ functions need a delimitter around your regex. Otherwise, the internal regex (if it worked before) will work fine with preg_ equivalents although you might need to read up on the parameters and return values.
  22. If you're already doing well with templates, definately take a look at expanding to drupal and joomla. Wordpress, Drupal and Joomla are the big 3 php based markets at the moment.
  23. number_format does not limit a number to the 1000's. There is something else going on.
  24. Not to mention this tutorial I wrote: http://www.flingbits.com/tutorial/view/xdebug-for-developing-debugging-and-profiling-php
  25. It very much depends on what it will cost you to sell and maintain the software, and the market. There are plenty of people selling scripts, although you might not think of them as such, when you consider people who sell templates for cms systems. Like anything you have to do some market analysis, take a look at costs to advertise with adwords etc.. For something like a "Wedding site" I'm with ignace that you're going to do much better with a site that allows people to make their site, that you host, and provides the SaaS. For something like a payment gateway, that might be something that would sell ok, although I would expect the competition to be stiff. Having it as a plugin to existing cms systems or commerce platforms would help.
×
×
  • 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.