Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. oh my bad, had to hurry to class so I was a bit rushed... but its just a missing semi colon and an extra $ symbol... its not that bad... everyone makes mistakes dude...
  2. it depends on your situation. if you want the constructor to assign variables that you define, IE class foo{ var $value; public function foo($value){ $this->value = $value; } } However, if whenever you instantiate the class, the variable will always have the same value, then assigning it in the declaration part and the constructor basically do the same thing
  3. if you want to parse what has been submit as php then use eval $code = stripslashes($_POST['code']); $submit = $_POST['submit']; if($code == "") echo ""; else eval($code)";
  4. foreach ($shopping_list as $key_1 => $val) { foreach ($val as $key_2 => $val_2) { echo('<tr> <td class="name">'.$key_2.'</td> <td class="thumbnail"><img width="87" height="87" src='.$val_2.' /></td> </tr>') ; } } try that?
  5. regardless of whether or not the [b] tags are in the actual code or not, gareths solution is correct. You are echoing "include('ads.php')" which will just output it to the screen. if you want to actually run the function, you can't have it in the echo statement. BTW, this is mostly personal preference, but I wouldn't echo out that much HTML. if all you want to do is show it just do <?php //php here ?> <!-- HTML HERE -> <?php //more php ?> <!-- More HTML --> <?php //etc. ?>
  6. for your example, yeah it doesn't really matter. However, that is a tutorial, and it really is just showing you the syntax of how constructors go, and not really trying to convince you that you should always assign variables in your constructor. by the way, you can also make a constructor this way class foo{ //below is the constructor public function foo($msg){ echo $msg; } } now if you were to create the function like so $foo = new foo("Hello World!"); it would output Hello World! kind of off topic, but yeah
  7. well one thing I saw right off the bat was return 'pages/'.$page.'.php' that will return "pages/pages/index.php" because $page already contains "pages/index.php"; I'm not sure if this is intentional or not, but this may be causing the 404 page to pop up
  8. break breaks out of a loop, so you only need to break 1; you can't break out of an if statement
  9. echo the mysql_error() and see what happens
  10. $selects = mysql_query("SELECT * FROM users WHERE username = '$viewuser'"); $is = mysql_fetch_object($selects); if ($is->new text > time()){ $status="Unavailable"; }else{ $status="Available"; } $txt = str_replace("[status]", $status); echo $text; ?
  11. that is called a ternary operator. check out This page on the manual to find out more. Its basically a mini if statement. its probably a good idea to put a trim in front of each statement so you don't have extra whitespace that might cause problems. but as far as needing it, unless you alway want to check that those are not empty and that they may have whitespace, i suppose there isn't a need for it. however I would suggest trimming those values anyways,
  12. $query = "SELECT * FROM active consults WHERE patient_name = '$lname'"; $query .= (!empty(trim($mrn)) ? "AND mrn='$mrn' AND resident ='$resident'" : "AND resident ='$resident'"; $results = mysql_query($query); I added the trim in there so if there were just blanks, IE " " would become "". Hope that helps
  13. echo your session and see whats stored in it. there are better ways of doing permissions tho, check out bitwise operators. check out this page http://www.litfuel.net/tutorials/bitwise.htm and scroll to the bottom to see how the guy set up a permissions system. however if you don't want to overhaul your whole permission system what you have will work, but echo out the session variable to see if what you think is there is there
  14. <?php $quotes = "quotes.txt"; I assume you understand adding value to variables. this is the name of the file $quotes = file($quotes); This opens the file quotes.txt and creates an array of every line. IE if you had 10 lines, the variable $quotes[0] would be the first line, and so on srand((double)microtime() * 1000000); this is called seeding the rand function. basically it tells the rand function where to start I think, or something like that. however, since PHP version 4.2.0 there is no need to do this as it is done automatically when you call the rand function $ranNum = rand(0, count($quotes)-1); this calls the rand function itself. it takes a random number between 0, and the maximum of the quotes array. (IE if there are 27 lines, the max would be 27) However, since arrays are zero based, the first entry starts at 0, so you need to subtract 1 from the count (IE if the file had five lines, array[0] would be first, array[1] is second and so on) echo ($quotes[$ranNum]); ?> this echos a random index of the $quotes array. hope that explained it well enough
  15. change the ors to ands. since it only has 1 value, one of those clauses will run false
  16. it shows that because your div is wrapped around everything not just the quote. You want the div to be wrapped around just the quote, ie echo "<div id='$number'>$quote</div>"; and I dont know why you can only click once. did you remove the function from the loop?
  17. I'm kind of confused. Do you want to verify that their email is valid? like so they can't just put like Email: aifdh8a9fh? this function will do that function verifyEmail($email){ $pattern = "^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]"; return preg_match($pattern, $email); }
  18. try changing this function changeText(number){ document.getElementById('reply').innerHTML = number; } to function changeText(number){ document.getElementById('reply').innerHTML = document.getElementById(number).innerHTML; } btw this is more a javascript problem than a php problem. but stick that function at the top of your page. Don't stick it in the loop because it will be posted a bunch of times and you will run into a same function error
  19. post the relevant code. lets see what you got under the hood.
  20. there should be... its the parameter of the function. when you call the function you are supposed to set the value of that variable
  21. hmm post your code. request_uri should return the page you are currently running code on. I've never seen it post the actual directory you are in
  22. have you tried it? for one surround your strings with quotes, like if $access == admin should be if $access == 'admin' but beyond that you don't know until you try
  23. you can't use php variables in javascript that way. you can use russells way, or my way, but you are going to have to pass the php var into the javascript a different way.
  24. $_SERVER['REQUEST_URI'] give that a try
  25. um.. well you are trying to write php syntax in javascript.. and thats completely wrong. are you trying to pass a php variable into a javascript function? then you want to do something like this <script type='text/javascript'> function changeText(number){ document.getElementById('reply').innerHTML = number; } </script> and when you call the function <img src='http://www.u-stack.com/quote.jpg' alt='Quote!' onclick='changeText("<? echo $number; ?>")' />
×
×
  • 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.