-
Posts
571 -
Joined
-
Last visited
Everything posted by Anti-Moronic
-
"I'm sure you could get somebody to take a close look without spending much money" This is one of those times you have to ask yourself how much your time is worth? Is it worth the amount of time you've spent on it because a compenent developer could probably do it within an hour for $40. I am certainly *not* offering my services here, just saying. Try the freelance section or elance/rentacoder/freelancer. You may never resolve this on your own and you may never resolve this through the help of volunteers or people who don't even have access to your server. It's extremely hard and near impossible considering what we've covered to know what the problem is without access to the environment the app is being run in. That's why nobody is replying. Hope that helps, really do. Sorry I couldn't be of more help.
-
Where is $eps? Should it not be $ep+1 or $ep++ ...
-
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.
-
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?
-
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.
-
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).
-
^^ 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.
-
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'); }
-
Need help urgently, please..immediately!!
Anti-Moronic replied to Anti-Moronic's topic in Miscellaneous
In my case, *always*. By the way, the above code doesn't work. blank page. don't know the error. Any ideas? -
Hey! Forgot to check up on this. Glad it worked out!
-
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.
-
You're living it? Yeh, keep safe man. Get the hell outta there, let us know if u alright.
-
Need help urgently, please..immediately!!
Anti-Moronic replied to Anti-Moronic's topic in Miscellaneous
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. -
Functions, functions and more functions -> timeout!
Anti-Moronic replied to rockinaway's topic in PHP Coding Help
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. -
Need help urgently, please..immediately!!
Anti-Moronic replied to Anti-Moronic's topic in Miscellaneous
Sorry, I should clarify. I actually mean how to echo the string '1+1' in php? -
How do you echo 1+1 in php?
-
I had a hard time finding something. In the end, jmeter proved quite useful: http://jakarta.apache.org/jmeter/
-
The above, and I found this excellent: http://www.survivethedeepend.com/ Which is an online book.
-
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.
-
Would be funny if you now based your life around the fact it is the end of the world in 2 years. Only to discover it isn't, and you will instead be punished for those kids you killed.
-
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.
-
^^ 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]; }
-
I'll reply as a kind of bump and to add some more advice. Sadly, I have absolutely no idea what is going on here. Sometimes it proves very hard to debug problems when you're not working within the same environment as the problem. This is one of those cases. My first point of advice would be to hire somebody to debug this for you in your environment. I'm sure you could get somebody to take a close look without spending much money. That will surely allow you to focus your time on other things in the script... ..err..do you have access logs? Can you turn on some persistent logging? Then request the page, and take a look. See if it is indeed being requested twice.
-
..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);
-
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.