Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. where did you put cags code? that is the solution I would have used. Can you post your code? (in code tags)
  2. Yeah, thats what I've been doing because it didn't work. That makes sense anyways, if parents could access child data, things might get screwy. Is there a way to make a data member abstract? so that it has to be defined in the child? if it were abstract would I be able to use it in parent methods? like class master { abstract protected $something; protected function somethingElse(){ echo $this->something; } } class slave extends master { protected $something = "I am something"; public function slave() { $this->somethingElse; } } I tested this, and it doesn't work, which leads me to believe that you can't make attributes abstract. Well, not really believe, its impossible, or at least the error message seems to think so. I know I could put the method def in the child class (right now its an abstract method anyways) and that would be the simplest way, but are there any other solutions? or is what i want to do impossible.
  3. well first of all, you aren't even getting the post variable. But you should send the answer through a hidden field. like do something similar to this <html> <body> <?php if (isset($_POST['answer'])){ $answer = $_POST['answer'];//$_POST['answer'] is how you access post variables. its $_POST['input name'] $oldNum = $_POST['oldnum']; echo $answer . " == " . $oldNum."<br />"; } $x = rand (2, 12); $y = rand (10, 20); $num = $x + $y; print ("$x + $y = "); # print ("$num"); $message = ""; if ( ! isset ($answer) ) $message = "Welcome to my math machine!"; elseif ($answer > $oldNum) $message = "Your answer is too high. Try again."; elseif ($answer < $oldNum) $message = "You answered is too low. You can do this!."; else // correct $message = "Well Done! - Correct Answer -"; ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Randon Number Equation</title> </head> <body> <h4> <?php print $message ?> </h4> <form method="post"> Type your answer here: <input type="text" name="answer" /> <input type="hidden" name="oldnum" value="<?php echo $num; ?>" /> <input name="submit" type="submit" value="SUBMIT"> </form> </body> </html> try that. Tested and works for me
  4. AHHHH I just figured out why I was confused. You are indeed correct, and this is what I originally thought, However, I had child methods that did something like this class parentClass { private $var1, $var2, $var3; protected function do(){ //do stuff } } class child extends parentClass{ public function setVar1($var){ $this->var1 = $var; } } If i were to call setVar1 what I originally thought was happening was that function was setting $var1 in the parent class. However, it appears that it just makes a var1 in the child class. I get it now. However, I have a different question while I have your attention. Originally, I had the set file function in my parent class abstract class MasterConverter { protected $file, $system, $uifile, $format; protected $allowedFiles;//this is an array abstract public function execute(); abstract protected function createCommand(); //Changing stuff. abstract protected function setFile($file); abstract protected function setFormat($format); protected function setuiFile($uifile) { $this->uifile = $uifile; } public function setFile($file) { //echo $file."<br />"; $ext = end(explode('.', $file)); //echo $ext."<br />"; if (!in_array($ext, $this->allowedFiles)){//note I use allowefFIles but it hasn't been defined yet echo "Invalid file type!"; exit(); } $this->file = $file; $newFile = sha1(substr($file, 0, strrpos($file, '.'))); $this->setuiFile($newFile);//seems to be a problem with this } } In my child class I want to use the setFile function, but define my own allowedFiles array. like so class childClass extends MasterConverter { //other stuff $allowedFiles=array("jpg", "txt"/* etc */); } However, when I call the set file function, it doesn't seem to be able to use the childs allowFiles class. Is there a way I can set the parent method to use the child's data?
  5. it seems that you would probably have to change the function (Or create a different one) that will accept an array of tags rather than just 1 tag. Have you tried just putting an array of the tags where the 1 tag is? if that doesn't work than you will have to change the function/make a new one IE $pod = $_GET['pod']; $loc = $_GET['loc']; $act = $_GET['act']; $photos = $f->photos_search(array("user_id"=>$person['id'], "tags"=>array($pod, $loc, $act)));
  6. Oh my bad, learn something new every day i suppose. I thought only python did that. thats pretty cool echo '<strong><a href="', $post['href'], '"</strong>>', '<em>'.$post['subject'], '</a></em>'; you can do that, but that doesn't really make much sense, and isn't remotely close to valid XHTML it would basically look like <strong><a href="somevalue"</strong>><em>somevalue</a></em> you cant have other tags inside some tags. you close tags out of order, and it seems that you are trying to bold the first part of the <a> tag. I'm not sure why you are doing that, but even if that was valid, it wouldn't do anything. What exactly are you trying to get the output to look like?
  7. Wordpress is a very easy to use blogging tool that you can set up yourself clicky if you know nothing about PHP it may be somewhat difficult to customize it, but I think wordpress has support for what you want to do. good luck
  8. echo '<strong><a href="'. $post['href']. '"><em>'. $post['subject']. '</em></a></strong>'; you were concatenating incorrectly. You use periods ('.') not commas to concatenate
  9. I tried that, and I got the same problem. that was my first reaction actually. The thing is that the other private variables ($file, $system, etc) are all set perfectly fine. Perhaps I will try setting just uifile to protected and see what happens. Thanks for the advice
  10. you probably should have read the rest of the posts... Try contacting your host's support and see if you can access and edit the .htaccess file. Some hosts don't let you and if that is the case, you can try asking them to insert the line cags suggested also. if that doesn't work than I'm afraid you will have to make any page you hae PHP on a .php page
  11. Ok, I made a quick function, its not perfect, but it may help you out. function buildBadVariants($arr){ $lets = array('i', 'l', 'e', 'a', 's', 't', 'o'); $replace = array('1', '1', '3', '4', '5', '7', '0'); foreach($arr as $word){ foreach($lets as $key =>$let){ if (substr_count($word, $let) > 0){ $new = str_replace($let, $replace[$key], $word); $arr[] = $new; } } $arr[] = str_replace($lets, $replace, $word); } return array_unique($arr); } function isBad($str, $bad){ $tokens = explode(" ", $str); foreach ($tokens as $word){ if (in_array($word, $bad)){ return "$str: you dirty boy<br />"; } } return "$str: comment is clean<br />"; } $bad = array("fuck", "shit", "bastard", "fucker", "fucking", "bitch", "dick"); $comment = "fuck you!"; $comment2 = "oh sh1t"; $comment3 = "sh1771ng d1ck n1pples"; $comment4 = "I am just a wholesome farm boy"; echo isBad($comment, buildBadVariants($bad)); echo isBad($comment2, buildBadVariants($bad)); echo isBad($comment3, buildBadVariants($bad)); echo isBad($comment4, buildBadVariants($bad)); output: fuck you!: you dirty boy oh sh1t: you dirty boy sh1771ng d1ck n1pples: you dirty boy I am just a wholesome farm boy: comment is clean just to explain a few things, the getbadVariants function will take your array of normal swear words, and add elements replacing certain letters in those swear words with corresponding "1337 speak" numbers. It tries to get most variations (it doesn't get them all) but it tries to prevent hiding bad words by testing for the numbered ones too. just as an example, if i do this line (iusing the same variable $bad as before) print_r(buildBadVariants($bad)); the output is Array ( [0] => fuck [1] => shit [2] => bastard [3] => fucker [4] => fucking [5] => bitch [6] => dick [8] => sh1t [9] => 5hit [10] => shi7 [11] => 5h17 [12] => b4st4rd [13] => ba5tard [14] => bas7ard [15] => b4574rd [16] => fuck3r [18] => fuck1ng [20] => b1tch [21] => bi7ch [22] => b17ch [23] => d1ck ) obviously you can change this to fit your needs. hope this helps
  12. well firstly this snippet foreach($_POST["comments"] as $value) { $comments .= "$value\n"; } is incorrect. you cannot concatenate things onto a string with no value. if you want to concatenate stuff to that string, you need to give it a value first (even an empty value); $comments = ""; foreach($_POST["comments"] as $value) { $comments .= "$value\n"; } the same idea goes for your $traffic and $promo variables
  13. word of advice, put your code in code tags orphp tags, and leave the HTML/CSS or other non important stuff out.
  14. In my code it shows me calling it in the child method, I do know what protected means, and I intended for that method to be protected. Besides, if I was calling it outside the class definition, I would be getting an error message. I have figured out though that the method was indeed being called, but it lies in a different problem. For some reason, the the line $this->uifile = $uifile; isn't working. I know this because I have an if statement like the following if (!isset($this->uifile)){ } this gets called because for some reason $this->uifile isn't set. One thing I noticed, both setuifile and this-> uifile are parent methods and attributes respectively. I access the parent methods other attributes successfully, but using a child method, not a parent method. for example, i do this function setFile($file){ $this->file = $file; } and this works. I am not sure whats going wrong here
  15. Hmm, see I changed the method in the parent class to do this protected function setuiFile($uifile) { echo "YAY THE FUNCTION WAS CALLED<br />"; $this->uifile = $uifile; } and the message wasn't output. That is the only place it is called.
  16. Ok, I have a parent class that looks like this abstract class MasterConverter { private $file, $system, $uifile, $format; abstract public function execute(); abstract protected function createCommand(); //Changing stuff. abstract protected function setFile($file); abstract protected function setFormat($format); protected function setuiFile($uifile) { $this->uifile = $uifile; } } And I access this function in a child class like so public function setFile($file) { //echo $file."<br />"; $ext = end(explode('.', $file)); //echo $ext."<br />"; if (!in_array($ext, $this->allowedFiles)){ echo "Invalid file type!"; exit(); } $this->file = $file; $newFile = sha1(substr($file, 0, strrpos($file, '.'))); $this->setuiFile($newFile);//seems to be a problem with this } that call doesn't seem to be working. Is there a special way I have to call this function //i tried parent::setuiFile() ClassName::setuiFile() any ideas? I'm sure i just have the wrong syntax
  17. you output a call to a function i guess is the correct way of saying it... but who cares...
  18. I gave you the query to do. You obviously know how to do queries from your original code...
  19. #right { margin: 0 165px; padding: 15px; float:right; } try that.
  20. select email from members where id=1...
  21. I don't think Maq's problem was that you were a beginner. Trust me there are hundreds of beginners on this forum. Its more that a lot of beginners tend to try to overreach themselves with projects they try to do. It isn't that we don't expect people to make beginner mistakes, its that when they are making beginner mistakes when trying to do code that is of an intermediate to advanced level. It makes it much harder to explain the mistakes when they don't understand the basics. You may be fired if you told one of your students they were irritating because they couldn't do something basic, but would you get fired if you advised a students to choose to learn the basics before they tried to build a car from scratch (sorry I couldnt think of a better metaphor, don't know anything about cars) however, this may or may not apply to you
  22. if you want to call javascript in PHP, then you have to define the javascript before the PHP, and do something like echo "<script type='text/javascript'>functionToCall()</script> beware though, calling javascript in PHP has unexpected results, since javascript is parsed client side, and php server side.
  23. try urlencode
  24. As a side note, mine would allow single digit hours, like 4:14
  25. you can use HTML marquees too. they are very basic, so if you want more advanced behavior use javascript. <marquee direction="up"> Your text here </marquee> that will make it go up. you can similarly make it go down, left, right, etc. inside the marquee tags can go any valid HTML (idk what happens when you have nested marquee tags though)
×
×
  • 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.