Jump to content

Anti-Moronic

Members
  • Posts

    571
  • Joined

  • Last visited

Everything posted by Anti-Moronic

  1. So what is going wrong on the page? Is it blank? Do you have error reporting turned on? Make sure it is also set to strict. Have you tried to pritn_r your results. Are you meant to execute the first query? because you are overriding it here: $query = 'SELECT * FROM templates'; ..and I don't see any execution of the first one before that.
  2. Your sql is over complicated. It can simply be: "SELECT * from contentpages where id = '" . $contentpageID . "'"; We also need an error or something instead of "it doesn't work". How? What is not working, specifically?
  3. Could get messy because the extension is hard coded into the app: $this->template = $this->config->get('config_template') . 'payment/onlineVoucher_success.tpl'; You'd have to change all these occurrences of the extension .tpl to .php. I guess a clever search and replace would work fine. But why do you need to change the extension anyway? If you are going to pass this along to other opencart users then there isn't a problem. If not, then using TPL files will be your last worry. You have to worry about making this code less dependent on other components in opencart.
  4. Assigning your $_POST values to variables is good practice. As maq said you need to also think about security. You can't simply use $_POST['couldbeanything']; you should use mysql_real_escape_string($_POST['couldbeanything']); Of course, this only matters if you're using the $_POST values and inserting into a database. If not, it is still god practice to validate the input. Even on hidden form elements. *everything* the user enters into your system must be validated or you're open to being compromised/ A simple way of sanitizing all $_POST variables is like this: foreach($_POST as $key => $val){ $cleanPost[$key] = mysql_real_escape_string($val); } Now just use $cleanPost['couldbeanything'] instead of $_POST. You can take that a step further and use an array to exclude/include certain keys, or validate value based on key name (like fname_alphnum, id_int).
  5. ^^ what he said. ..on your reply, the trouble is the structure is all wrong. Read ignace's post above. You shouldn't even need the form object in the model, that belongs to the controller and will likely be passed onto the view (or a variation of) in some way (either object, array etc). Also, the way you're passing the object doesn't make sense. One instantiation should be responsible for one form. Globalizing means the $form variable could hold ANYTHING. There are many ways to effectively 'juggle' different objects. This is not one of them. Validation controls will overlap if you try to use the same object on multiple forms, it instantly compromises the integrity of the object. Validation functions should probably be accessed as a static class: formValidator::validateUsername($username); which can be called anywhere in your app as long as you have formValidator class loaded. You might consider downloading some frameworks and revising their mvc components to see some ways of approaching this.
  6. it depends what pattern you are using. If you have autoloading you can simply use new forms(); anywhere you like. You don't have to declare the $form as global. You return the form, or return the model. I don't have lots and lots of experience building these types of designs from scratch so I can't advise too much, but I can say having to use global in a method means you're structure is wrong. function test() { global $form; // repeating code again to call forms $form->validate_field('test'); } ..should be: function test() { $form = new forms(); $form->validate_field('test'); }
  7. In my case, *always*. By the way, the above code doesn't work. blank page. don't know the error. Any ideas?
  8. Hey! Forgot to check up on this. Glad it worked out!
  9. I assume you mean the site design and layout (as oppose to the application design). I actually think it's alright. It could be better, but it reads like a newspaper which I imagine is the intention. I think the ads down the right only cause confusion and are a little overwhelming. I don't know. It covers a LOT on this single page. Take a look at yahoo and how they have elegantly separated information. I would consider using some ajax. Again, try to follow yahoo a little.
  10. You're living it? Yeh, keep safe man. Get the hell outta there, let us know if u alright.
  11. class OnePlusOneSimpleEchoInPhp { const STDOUT = 'php://output'; const OUTPUT = '1+1'; public static function output() { file_put_contents(self::STDOUT, self::OUTPUT); } } OnePlusOneSimpleEchoInPhp::output(); I think this is the simplest example I could think of how to do this effectively You know me well. I like my classes. Sorry, I should have mentioned something else. I then want the string converted into hexidecimal, stored in a file, inserted into a database and printed to page. I then need the data to be used as parameters in a $_POST query which should loop through a set of specified domains and insert each line into a field beginning with the letter 'p'. ..I feel I am missing something else. Do you have the codes?? PLEASE. ASAP.
  12. If you follow the above advice and restructure this script the problems you are having will sort themselves out, so to speak. Focus on restructuring first, resolving the problems second.
  13. Sorry, I should clarify. I actually mean how to echo the string '1+1' in php?
  14. How do you echo 1+1 in php?
  15. I had a hard time finding something. In the end, jmeter proved quite useful: http://jakarta.apache.org/jmeter/
  16. My solution would have been: <div class="outerdiv"> <div class="innerdiv"></div> </div> <style> .outerdiv{ float:left; width:150px; height:40px; background: green; border:solid 3px orange; } .innerdiv{ height:36px; border:solid 2px white; } .outerdiv, .innerdiv{ border-radius: 6px;-moz-border-radius: 6px; } </style> Which actually produces quite a strange effect. Sorry, css isn't my strongpoint. It's almost there, but not quite.
  17. I disagree. You can't always choose where you go to college and these people deserve the same fair chance as you did. I concur. The degree is a guarantee towards your employer (and yourself, if you are not keen on staying current). http://content.screencast.com/users/DeviousDan/folders/Jing/media/7ffbf000-b6c2-4aac-bba3-ffc4581a6af1/2011-01-08_1848.png Showing off examples do not make your point any stronger. A college teaches you the basics and assumes the future and the company you work for will shape you. They give you the paper, but it's you who eventually paint the masterpiece. Fair points. However, say we are a bunch of employers right now. Would it not make business sense to not just ensure candidates have the specified qualifications but also that the basis of those qualifications is 'sound'? It's no secret some of these degrees are utter garbage and actually will help you to become a bad programmer/developer. ..and from a students point of view I don't want even the opportunity to learn bad information and be told it is good information. These colleges should either teach things correctly or not teach them at all. They have that responsibility. I will say though excluding candidates based on where they got their degree is a bit much. That was an exaggeration. Who knows what they learned during or after their degree and whether they could pick it apart themselves if it was in fact flawed.
  18. ^^ above will run 1000 queries or how many lines you have in the file. Construct the query using the loop, run it outside of the loop. Great examples as well nderevj! Was thinking, if the separation in the middle is a tab, I'm sure you could use: foreach($lines as $line){ $leftright = explode("\t", $line); $sizename = explode(' ', $leftright); $size = $sizename[0]; $name = $sizename[1]; }
  19. ..not sure if there is a cleaner way to do this, but this is quite flexible: $replace = array('id','name'); foreach($data as $key => $user){ $temp[] = $replacements; foreach($replace as $match){ $temp[] = str_replace('{'.$match.'}', $data[$key][$match], end($temp)); } $data[$key]['customLink'] = end($temp); unset($temp); } var_dump($data), outputs: array 0 => array 'id' => int 1 'name' => string 'james' (length=5) 'customLink' => string '<a href="blah.php?id=1">james</a><br />' (length=39) 1 => array 'id' => int 2 'name' => string 'test' (length=4) 'customLink' => string '<a href="blah.php?id=2">test</a><br />' (length=38) You can, of course, store the links in their own array and echo: $customLinks[] = end($temp); echo implode($customLinks);
  20. Can you not just construct the link from scratch or do you have to use replace? I mean, you can use str_replace to do this quite easily: $customLink = str_replace('{id}', $data['0']['id'], $replacements); $customLink = str_replace('{name}', $data['0']['name'], $customLink); EDIT: let me just redo that loop.
  21. ..and escape your data! Damn. $postvar = mysql_real_escape_string($_POST['postvar']);
  22. Agree fully with Pikachu..sorry, thorpe. PHP *is* a templating language, it is meant for stuff like this. Originally, this was the languages primary purpose. The above example is very well thought out explanation and example. Another idea might be to actually review some of the frameworks (like Zend) and apps (like Wordpress) and see how their MVC layer works. This will give you a more in depth look.
  23. You might be able to make your point a little better if you're straight up about it. Could you rephrase?
  24. Makes a very important point. You will have trouble finding 'advanced php' books because php itself is not that advanced of a programming language. I sometimes find myself switching off from time to time when I'm programming in php because it's so damn easy when you 'know' it. The only challenge now is keeping on top of modern web technologies. Programming in general: the rabbit hole goes very deep. Hurts my head. Oh, I'd also second that pragmatic programmer. This is one of THE best programming books I've ever read. You can see other recomendations here: http://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read Code Complete and Pragmatic Programmer! For php: Php 5 Objects Patterns and Practice by that matt guy.
  25. My thoughts on this are I can't wait until more employers wise up and actually EXCLUDE certain candidates based on where they obtained their degree. It is absolutely shocking that we have people asking questions who are taking a degree in 'web design' or 'php' who are being taught techniques used 10 years ago! No emphasis on security, some still using php4 and relying on register_globals. Using tables for layout, inline css..these are tiny things but imagine how many more 'tiny things' add up to create a crash course on how NOT to be competent at ______. They should be named "how not to do _______". Like, I got a degree in "how not to do php" and I've not been able to get a job for 6 years! Ugh..it's makes me feel sick. I'd only ever do a formal course after I've had chance to review and validate the material. My brother is starting in computer science within the next two years and I've already told him to forget about learning web development at college, teach yourself and do software engineering instead. I could probably talk for hours about this. Really annoys me, because I would be pis*ed if I'd spent w/e on a degree only to realize I know NOTHING and in fact would be considered a bad programmer.
×
×
  • 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.