Jump to content

ToonMariner

Members
  • Posts

    3,342
  • Joined

  • Last visited

Everything posted by ToonMariner

  1. if you are thinking of modular approach then definitely OOP. I found that i leaned more writing code and then reviewing it. you soon see where you can improve efficiency and vastly reduce the volume of code you need to perform even complex tasks.... As a side note - I saw a job advertisement just the other day looking for a developer to write complex code... I don't write complex code - I write simple code that combined can perform complex tasks...
  2. would it not be more beneficial to store children as an array under the parent node? something like <?php $a = array( array('title' => 'ROOT 1', 'children' => array( array('title' => 'CHILD 1 OF ROOT 1', 'children' => NULL), array('title' => 'CHILD 2 OF ROOT 1', 'children' => array( array('title' => 'CHILD 1 OF CHILD 2', 'children' => NULL) ) ) array('title' => 'ROOT 2', 'children' => NULL), ); ?> can then use a recursive function to spit out the nested list
  3. you can achieve all this using curl. you will need to find the action of the form that you normally sign-in with - replicate that behaviour by using curl to post your username and password to the page. there is a fair bit of work involved following that. You need to monitor the returned data and see where its re-driecting you to and with what data (cookie, get, post etc.) and monitor that. Its not difficult - just time consuming...
  4. perhaps you might want to cater for a varchar instead?
  5. Not sure why you are doing this... progress bars would normally demand the use of javascript - use that to manipulate the width based on an ajax request. styles soul dbe in external css files - if ypou desperately need to amend some style based on the computations performed by php then look at using the style="width: <?php echo $width; ?>;" attribute.
  6. Dangerous to assume only one . in the file name.... object.class.php is fairly common out there so lets just get the extension... function getExt($file) { return substr($file,(strrchr($file,'.')+1)); } beaten by the kettle
  7. require_once($_SERVER['DOCUMENT_ROOT'] . '/forums/ipbsdk/ipbsdk_class.inc.php');
  8. i always reference includes absolutely so $_SERVER['DOCUMENT_ROOT'] . 'path/to/file.ext' 9obvioulsy check if $_SERVER['DOCUMENT_ROOT'] has the trailing forward slash - if not you'd need '/path...'. In doing so - should you need to move/copy then its straight forward. As you are including a class file - why are you not using the __autoload function?
  9. this would be potentially an ideal case for oop and decorating each object - very extensible for such matters...
  10. Sorry but your explanation isn't very clear... Are you saying that if the user inputs something into the text box then that row will be inserted into the database? Are there multiple merchant IDs? your description is quite poor - sorry...
  11. you don't need to store them in a database - you could store them in a folder behind the root and force download by having a php script read the file and output it to the client.... That is however a moot point here. what ever you do you need a script that forces downloading of files (something like this) which can register which user has selected the file. there are possibly alternatives - like javascript sending an ajax request with the users id and the link they just clicked on - that would allow the browser to handle files as normal (allowing users to open pdf rather than forcing them to download) the ajax request would simply call a script that records the userid and the size of the file they just requested.
  12. tell you what - do the get real thing... write ONE paragraph on what you are trying to achieve. post ALL he code (server and client side) and we will try on see what you are doing.
  13. i don't know - should you have a loop in your code? if you are exploring an array I'd suggest you do (in your current set up). Maybe there are some cross wires here... what ever it is you are doing put print_r($_POST) at the top of your script and you can see what data ou are playing with.
  14. nice try but not quite there... an object is best visualized as a real life object. lets say we have decided that our every day object is a car. we should all know one of them when we see them... class Car { ... } Now a car has some things that are common, and engine, wheels, a method to steer and so on. in terms of writing code for that these are properties of the car. class Car { protected $wheels; protected $engine; protected $steering; protected $colour; .... } Hope that makes sense so far. Now our car can do things. Accelerate, Stop, crash etc etc. these are methods that our car can perform. These methods all relate to a property our car can have - speed. So lets look at our class. class Car { protected $wheels; protected $engine; protected $steering; protected $colour; protected $speed; public function accelerate($rate,$duration) { } public function brake($rate,$duration) { } } Still with us? reaching for razor blades? good. So now lets look at creating a car. We want a Yellow Reliant Robin with a 750cc engine.... class Car { public $wheels; public $engine; public $steering; public $colour; public $speed; public function __construct() { $this->setEngine(); $this->setColour(); $this->setWheels(); $this->speed = 0; } public function accelerate($rate = 0,$duration = 0) { $this->speed *= 1 + ($rate * $duration); } public function brake($rate,$duration) { $this->speed *= 1 - ($rate * $duration); } public function setEngine($capacity = 0) { $this->engine = $capacity; } public function setColour($colour = 'red') { $this->colour = $colour; } public function setWheels($wheels = 4) { $this->wheels = $wheels; } public function __toString() { return 'Colour: ' . $this->colour . ' Wheels: ' . $this->wheels . ' Engine: ' . $this->engine . ' litre Speed: ' . $this->speed; } } OK so we have a template for creating a car and we can feed in our settings. <?php $car = new Car(); echo $car; $car->setColour('yellow'); $car->setWheels(3); $car->setEngine(0.75); $car->acclerate(20,2); echo $car; ?> so we crated a car and by default it set its colour to blue its number of wheels to four its engine to 0 and its speed to 0. But our car then was defined as Yellow, 3 wheeled with 0.75 litre engine and told it to accelerate at 20 metres per second for 2 seconds. the car is now going 40 metres per second.... we now have the code to create different cars and all we have to do is... <?php $robin = new Car(); $robin->setColour('yellow'); $robin->setWheels(3); $robin->setEngine(0.75); $porsche = new Car(); $porsche->setColour('black'); $porsche->setEngine(2.5); echo $robin; echo $porsche; $porsche->acclerate(80,4); $robin->acclerate(20,2); echo $porsche; echo $robin; ?> Now I hope from that you can see that a class is a template for an object that we want to use. Once we create that object (instantiation) then we have one copy of the template that we can manipulate. We can then create another instance for a completely different car using exactly the same code and manipulate them independently. For further reading check out the scope of methods and properties of an object (public, private, protected and static). Hope that was helpful - other feel free to correct typos and what not.
  15. <input type=\"hidden\" value=\"$aff\" name=\"MerchantID\" this line means that you overwrite the previous merchant id in the the post header. you need an array of merchant ids <input type=\"hidden\" value=\"$aff\" name=\"MerchantID[]\" I hope you missed some code off that as I can't see your loop...
  16. don't worry about running on OS... this submission was based on linux servers http://uk.php.net/manual/en/function.exec.php#88704 the principle is exactly the same - all you need do now is formulate the command you need to run your email and pass the relevant arguments. Go step by step and make sure you can run exec on your box as a test then start investigating the path to the script you need to execute - use a test script that just sends you an email that way you won't annoy anyone if you break it.
  17. there used to be a tutorial on phpfreaks on exactly this problem - appears to have disappeared since the refresh...
  18. <?php $textarr = array('AA'=>'Some Text', 'AB'=>'Other text', ..... 'AH'=>'Last Text'); foreach($a4 as $key => $val) { if(strcasecmp($val,'yes'~) == 0) { ?> <font color="#990000"><?php echo $textarr[$key]; ?><font> <?php } } ?> the textarr could be populated from a database but I get the impression that this could be refactored maybe in favour of a switch statement....
  19. yep. fork your script. this will be of use: http://uk.php.net/manual/en/ref.exec.php
  20. need to see your html and all relevant code...
  21. this is a case where you don't need multiple queries when one will do. I don't like to see queries being run inside loops - better to just build your query in the loop and execute afterwards... try this <?php $queries = array(); foreach ($_POST["MerchantID"] as $line => $val) { $queries[] = "('".forSql($_POST["error_text"])."', '".forSql($_POST["correct_id"])."', '".forSql($val)."', 'Gift')"); } $qry = "INSERT INTO errordata (error_text, correct_id, MerchantID, type) VALUES " . implode(',',$queries); $result = $db->sql_query($qry); ?> you may need to amend something for the forSql to work if its out of scope but otherwise thats a more efficient query. This depends of course on the merchantid is an array passed from the form (you need to give the html input fields name="merchantid[]")
  22. why have you used name="add[]" in your form? unless the inputs are check boxes there is little to be gained from this. give your fieldnames a distinguishable value. also make you code a little more efficient - no point in looping twice NOR having multiple queries... using your current code... <?php if (is_array($_POST['add'])) { $qry = NULL; foreach ($_POST['add'] as $key => $value) { $qry .= "UPDATE r_members SET m_".$key."='".mysql_real_escape_string(stripslashes($value))."' WHERE m_id=$m_id; "; } $res = mysql_query($qry); } ?>
  23. when processing forms try printing out the contents of the header. print_r($_GET); and print_r($_POST) will show you the data that has been passed. select boxes will pas the value attribute of the option(s) but NOT those there were not selected. if you need those values then storing all options in a database would allow you to retrieve them or maybe an xml file...
×
×
  • 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.