Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. I meant rasmus but thank you for the correction.
  2. There are 2 options here. One use single quotes echo 'Hello, dave said "What are you doing today", and that was it'; or echo "Hello, dave said \"What are you doing today\", and that was it"; If you aren't doing extrapolation or aren't planning on it, then you want to stick with single quote's to keep it cleaner, if there are some extrapolations then you have to use double quotes, or you can't do that with variables, unless you concatenate them in like echo 'hello what is ' . $user . ' doing today.';
  3. Again, eval was something I was told "not" to use. Not saying thorpe is wrong, but I just know that I read somewhere (I know this is true), that there was a quote from rasmon (Creator of php) who said "If Eval is the answer, then most likely you are not asking the right question." There is something bad about using Eval, I don't know what, don't know why, but I am pretty sure if the creator of it himself said something about it, then it's not something that should be used.
  4. strpos would probably be the most accurate, out of the standard mysql functions for trying to see if a needle is present within a haystack.
  5. There are a few rule's to keep in mind with extrapolation. 1. The '' are meant for strings that are NOT going to require extrapolations (variable replacements) or escapes. 2. The "" is meant to be used when Extrapolations are expected. 3. If it's an array do not put the single quotes in. $string = "Hello what is $row['name'] doing."; // wrong $string = "Hello what is {$row[name]} doing."; // right 4. Either way the recommended way (on php.net's website) that the right way to do it in all situations is {$variable} That is the recommended way to run into the least amount of problems. THe only time I ever place variables straight into a string (without using {}) is with queries because I have encountered problems with it before. $sql = "SELECT * FROM users WHERE id = '$id';"; That is the only kind of situation where I don't use {} because it's a query, and it can cause problems.
  6. Exec is never a good idea to use, and it's better to be avoided for security reasons. For your issue, you may want to look around PHP.net and see if there are any bugs related to your specific system. Looking at the code I don't see anything off hand that might be messing it up, it looks fine, maybe there is a type of bug with one of the functions you are using that is only a bug on that specific system, you can check into it over at php.net by going through there list of bug's, or running a few google searches on "php problems on (insert operating system here)" Based on your last post, if you are wanting to do DNS lookups. http://www.google.com/search?source=ig&hl=en&q=DNS+lookup+API+with+php&btnG=Google+Search You will find a lot of stuff there, that will help you find out everything you need, on making it work. Don't use the exec function, I am warning you before it's too late, especially if you are using it with user input, you will end up finding out why I advised you not to if you try and use it.
  7. Well I don't know about all of that. I think planning is very important, I end up trying to plan out everything. When I mentioned that, I didn't mean skip planning. I try to plan for my database structure more than anything because ALL of the programming generally revolves around the structure of the database. However even the best laid out database structure can get bogged down with a lot of hit's. It's bound to happen on any site that get's to a certain point. Look at PHPfreaks.com, they started out great, then just about 6 months ago they started having lot's of problems with there databases. I mean error's all over the place, connection areas, and a lot of other things that were causing problems. Now they don't ever have problems, so they had to have done SOMETHING to stop those errors, the traffic only increased since then, and there is no way they could have gotten away with not doing something. Now there are hardly (if ever) any errors related to the database. It had to of been because of "fixes" they did to allow the database to hold more, I doubt they changed database systems or it would have been down for almost 3-4 day's. That's what I don't get too, you said plan it before you build it. That's pretty much what I meant, but you can plan out how many users you are going to eventually have. Not everyone can jump to oracle first thing, some people have to start with mysql, and for me, for almost all situations it's the best choice. unless I have a site I created that I am in charge of that ends up having mysql errors because there are too many user's coming in than it can handle. Also based on your other question, deleting 30,000 row's from a database will take very little time for mysql if you are just running a delete query.
  8. There is a wealth of knowledge in this post, I am going to bookmark it, I learnt about 3 new things from reading the posts you have put. Thanks for the advice, and explanations.
  9. I think these forums are for helping people not criticizing people. You seem to think what I said was wrong, but that Is what I have been told. Fact - mysql is more reliable with smaller user's, but get's bogged down with lot's of user's. Fact - PostGreSql is not AS reliable as mysql, but can handle large groups of user's better. Fact - Oracle is one of the most reliable with very high numbers, and that's why it's the most expensive. Fact - If you put Mysql on it's on server and "cluster the database", not exactly sure what that entails but I have had that suggested, then you get better performance than mysql on a shared server. Those are all facts, if someone can dispute one of them, please do so with proof. As far as what I said, my general theory is Start with Mysql - CLuster if needed - Go to PostGreSql after that if needed - Oracle if needed. That sounds like something sound, you have to start somewhere and very few will have the money for oracle right off. Based on what I have said no clients would think any differently of me. If someone has something to say about what I mentioned about, please point out what part they think I am wrong on, and tell me in what way's I am wrong. Allow me to learn from my mistakes instead of criticizing me for them.
  10. Normally by what I have read, mysql database' doesn't really matter on the number of fields, it's how often they are called. You could have a million fields, with millions of row's of data, but if the site is rarely visited, then you don't normally have a problem. I think if your site is getting decent traffic, with that many row's. My motto lately when it comes to mysql is. First use it, when you start encountering problems then do some "quick fixes" where needed, like making the number of allowed open connections increased, and debugging the database, and optimizing the database, just basic things like that. When it gets to the point where you can't handle it, and there are problems around all over the place, then get a separate server entirely to handles your database, and allocate all it's resources to just that. This will solve your problems for a long time to come, they call it a "cluster". From here, if you still have problems you can always go to PostGreSQL, which isn't as fast with less user's, but it can handle almost double what mysql can. If you are ever getting where you are still having problems, then you should start looking at oracle, or other big database systems, and see what you can come up with. Based on what you have described, with your current situation then you shouldn't currently have any problems with it acting up.
  11. So when I see someone else's config file, I see a bunch of define() When I do it I do $config['email'] = "whatever"; $root = $_SERVER['DOCUMENT_ROOT']; and so forth, when I see them use define. What is the different in setting the variables like that, and setting constants with the define() function.
  12. Yes, based on the description of your problem, I think thorpe's code will solve your issue. If you have to have a random one, then put the domains in an array, and then randomly pick one of the domains from the array.
  13. $CSS .= "<link href=\"" . URI_CSS_ROOT . "/{$href}." . FILE_EXT_CSS . "\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />"; I have seen that before FILE_EXT_CSS not that same one, but other things like MASTER_EXT what are those variables called, and how do I use them, that's one part of that I didn't understand.
  14. Is there anyway I could "see" that templating class. Not to run off with it specifically and steal it, but to look over it and see if I can learn something from it.
  15. The reason I am even building my own framework is a area for my own personal "style". In a lot of sense when there is something I can cut down a few minutes on development time by making something more automated, then I take the time in my spare time to try and achieve it. For example. <?php echo $config['js']['rico']; ?> I have just included prototype and rico both and they are ready to use on that page. instead of <script type="text/javascript" src="path/to/prototype.js"></script> <script type="text/javascript" src="path/to/rico.js"></script> Seemed a lot shorter the first way. In case I want to load up all my javascript pages, because I want to use a little of this, and a little of that it's <?php echo $config['js']['all']; ?> Instead of including thema ll manually, it's something that when I am working on something quick, it's quicker to include them and get that part done with, the paths are already set, so I won't have to double check to make sure the path's are correct or anything.
  16. <?php //javascript/ajax library folder (path to your javascript files) $config['js']['start'] = '<script type="text/javascript" src="' . $config['modifier'] . '/ppassistant/system/languagelibraries/'; $config['js']['end'] = '"></script>'; // Put javascript below here, as shown in this example. Each javascript file get's attached to it's own variable, making inclusion throughout pages easy (as needed) // example: $config['js']['example'] = $config['js']['start'] . $config['js']['library'] . "example.js" . $config['js']['end']; it would be c // setup for just prototype $config['js']['prototype'] = $config['js']['start'] . $config['js']['library'] . "prototype.js" . $config['js']['end'] . "/n"; // setup for rico (includes prototype (rico's dependent) $config['js']['rico'] = $config['js']['start'] . $config['js']['library'] . "prototype.js" . $config['js']['end'] . "/n" . $config['js']['start'] . $config['js']['library'] . "rico.js" . $config['js']['end'] . "/n"; $config['js']['script'] = $config['js']['start'] . $config['js']['library'] . "prototype.js" . $config['js']['end'] . "/n" . $config['js']['start'] . $config['js']['library'] . "scriptaculous.js" . $config['js']['end'] . "/n"; $config['js']['all'] = $config['js']['start'] . $config['js']['library'] . "prototype.js" . $config['js']['end'] . "/n" . $config['js']['start'] . $config['js']['library'] . "rico.js" . $config['js']['end'] . "/n" . $config['js']['start'] . $config['js']['library'] . "scriptaculous.js" . $config['js']['end'] . "/n"; ?> After playing with it a minute I came up with this. That way I can just do $config['js']['all'] if I want all on one page or just $config['js']['rico'] if I want rico and it's dependent, I think that will make things a lot faster. If anyone has any simpler/quicker way's then let me know, I am always open to suggestions.
  17. I developed a quick system into my personal programmer assistant (my own framework I carry around from project to project), and it works fairly well. However I have certain javascript libraries I use so far. Prototype.js Rico.js (which is dependent on prototype script.alac.us (which is depending on prototype, and automatically loads all it's other files when you include just this one (unit test, slider, effects) and all the other js files it comes with.) I am wanting a quick way to just echo the name of the javascript file i want to use, but I also don't want the config file for my framework getting really messy, still trying to keep everything pretty simple. Right now, with what I currently have, I have the javascript inclusion as 3 different parts. $config['js']['library'] = "/ppassistant/system/languagelibraries/"; $config['js']['start'] = '<script type="text/javascript" src="'; $config['js']['end'] = '"></script>'; within my config.php file. This is fine for awhile back, I didn't mind having to go through the trouble. However everytime I wanted a new js file, I had to put it in the folder (whenever I wanted to play around with other libraries, or needed another library for something specific/temporarily on a project) I always (everytime I add one) have to go and do this in the config file. $config['js']['rico'] = $config['js']['start'] . $config['js']['library'] . "rico.js" . $config['js']['end']; for example, then when I got ready to include it within my files I would have to (since prototype is it's dependent) I would have to go <?php echo $config['js']; echo $config['prototype']; I was hoping I could have a quicker way to do this, I want a quicker way if it's possible. Because I am about to start really getting into ajax more, I am using different frameworks here and there, but on the side when I start learning how the inside of these frameworks work, I will start slowly contructing my own list of functions. CHANCES are though my functions are going to have depents on prototype or something else, so I don't want to have to fight with a gritty inclusion system when the time comes.
  18. I have a few things I am trying to do. So far I have been trying to use prototype, but not sure about parts of it, as well as some of the other stuff. I am not sure if I am going to keep using prototype (it just seems like it's the javascript language rewritten), I don't really see any functions you can just use or anything (stared at it's source for af ew hours, and the API manual. I am also about to look into rico. In the framework I have created, I have classes/functions where I can easily add new one's, but everytime I end up creating/using Java Script functions they are one time arrangements, and not re-usable. I need to figure out how to make the functions where I can reuse them, any advice. Like forms, I tried to create one so I could validate form fields before submittal, but every time the form fields are different so the function ends up being different, just general things like that, any advice?
  19. hehe, thanks for the link, I was going to try and help but you ended up helping me, that is going to be pretty helpful.
  20. Any ideas on why the function isn't working properly
  21. Yes, I Javascript and "Server-Side Javascript" both function a little different. The regular javascript language is only 1 (of 2) browser side languages, and I prefer it over VB tremendously.
  22. <?php // function Advance Time // Parameters // @ timestamp - Timestamp: (timestamp of time you want to advanced // @ String - p1modifier (part 1 modifier) - this is what you want to modify // Possible Values (hours(hours, h, hour), minutes (minutes,min,mins,minute), seconds, months, // days, years) They can be entered in, with multiple variations // @ String - p2modifier (Part 2 modifier) The alteration to the p1 modifier // possible values - (It can be anything with addition or subtraction function advancetime($timestamp, $p1modifier="", $p2modifier="") { // make sure variables where set (they are all required if ($timestamp == "") { return false; } if ($p1modifier == "") { return false; } if ($p2modifier == "") { return false; } if ($p1modifier == "h" || $p1modifier == "hours" || $p1modifer == "hour") { return mktime(date("h", $timestamp) . $p1modifier . $p2modifier, date("i", $timestamp), date("s", $timestamp), date("m", $timestamp), date("d", $timestamp), date("y", $timestamp)); }elseif ($p1modifier == "minutes" || $p1modifier == "mins" || $p1modifier == "min") { return mktime(date("h", $timestamp), date("i", $timestamp) . $p2modifier, date("s", $timestamp), date("m", $timestamp), date("d", $timestamp), date("y", $timestamp)); }elseif ($p1modifier == "seconds" || $p1modifier == "secs" || $p1modifier == "sec") { return mktime(date("h", $timestamp), date("i", $timestamp), date("s", $timestamp) . $p2modifier, date("m", $timestamp), date("d", $timestamp), date("y", $timestamp)); }elseif ($p1modifier == "months" || $p1modifier == "month" || $p1modifier == "mo") { return mktime(date("h", $timestamp), date("i", $timestamp), date("s", $timestamp), date("m", $timestamp) . $p2modifier, date("d", $timestamp), date("y", $timestamp)); }elseif ($p1modifier == "day" || $p1modifier == "days" || $p1modifier == "date") { return mktime(date("h", $timestamp), date("i", $timestamp), date("s", $timestamp), date("m", $timestamp), date("d", $timestamp) . $p2modifier, date("y", $timestamp)); }elseif ($p1modifier == "years" || $p1modifier == "year") { return mktime(date("h", $timestamp), date("i", $timestamp), date("s", $timestamp), date("m", $timestamp), date("d", $timestamp), date("y", $timestamp) . $p2modifier); } }// end function // testing/debugging page $signupdate = date("m/d/Y"); $signupdate = strtotime($signupdate); echo "Date: " . date("m/d/Y", $signupdate); echo "<br />Date Timestamp: " . $signupdate; $currentdueamount = "19.95"; echo "<br />Current Amount Due " . $currentdueamount; $nextbillingdate = advancetime($signupdate, "months", "-1"); echo "<br /> Next Billing Date: " . $nextbillingdate; $nextbillingdate = date("m/d/y", $nextbillingdate); echo "<br /> Next Billing Date(date): " . $nextbillingdate; ?> That function there is what I just came up with but it's not working. I created it, then rewrote a few parts that didn't make sense, and a few mistakes I saw, when it looked right I tested it, and it's not doing any calculations on date. Any advice?
  23. This isn't help, it's more of thanks. I really never realized the poker of mktime and how easy it is to use. $signupdate = date(); $signupdate = strtotime($signupdate); $currentdueamount = "19.95"; $nextbillingdate = mktime(date("h", $signupdate), date("i", $signupdate), date("s", $signupdate), date("m", $signupdate)+1, date("d", $signupdate), date("y", $signupdate)); Yeah, basically if you have a date, and you just pass your format using an existing time stamp you keep your current data but you can do advanced calculations with it. So now it the time when I create a function using this code, over the weekend (DEFINITELY) I am thinking of it having a few variables, so you can set which ones you want to increase/decrease (seconds, hours, months, years), or whatever. This thing can do ANY date calculations very easily. It's a little "repetitive" having to put in the same time stamp over and over again, so when I Create a function I will have it where you can pass the time stamp once and it does the rest. Then you just feed it (like an array or something) of what calculations you want to do (add to month, or year, or subtract from seconds), or something. I can definitely come up with something for this.
×
×
  • 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.