Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. yeah you would simply use on click and have it return true of false
  2. are you sure your img path is right. Try echoing what the img src would be and see if it is correct
  3. The cool thing about classes is data encapsulation, so if you make a class var, named, say, $name, that var is accessible in every member function of the class. so for example class foo { private $word="Hello World!"; function bar(){ echo $this->word; } } $foo = new foo(); $foo->bar(); //output Hello World! This does a few things. Namely, it allows you to access variables in functions without having to pass them. so lets take one of your functions, and see how it would be in a class class foo{ private $item, $links, $name, $global, $catnum; //lets assume these are set before we call the function function replacesym($itemnum=NULL) { $item = str_replace("[#]",$this->global,$this->item); $item = str_replace("[cat#]",$this->catnum,$this->item); $item = str_replace("[item#]",$itemnum,$this->item); $item = str_replace("[url]",$this->links,$this->item); $item = str_replace("[name]",$this->name,$this->item); $item = str_replace("[nl]","\n",$this->item); // return $item; we could do this, or we could set the class variable like so $this->item =$item; } } Since the data is already set, and is already inside the class, that function only really needs one parameter, as opposed to 4-6 which could make it kind of clunky. This explanation is very basic though, and there is a lot more to classes than just this. Hope this helps
  4. this is just a guess, but you probably want this to be <?php echo $lastpicid .".". $ext; ?> otherwise, the source of the image would look like "mypicjpg" (assuming that $lastpicid is the name of the file, and $ext is the file extension
  5. you COULD make this a class if you wanted to, and would probably be a good idea, but does the script as it stands work? it doesn't seem too complicated to me
  6. Be aware that javascript can be disabled by the client. This may not matter to you much, but you may want to take some extra precautions to make sure data doesn't get deleted accidently
  7. echo "<script type='text/javascript'> price['92342258697'] = '".$myvar."';\n </script>"; oh beaten to the punch. oh well
  8. missing the $ array_push($svcIDs, "$staSvcIds") [/php[
  9. yep, its called in_array if (in_array($needle, $haystack)){ //do something } with needle being your variable and haystack being your array
  10. so you DON'T want to use the alert function? Well you can use the window.open function to load a custom error box, but besides that I'm not sure
  11. based on the following with(window.document.choices) shouldn't the name of your forms be "choices" They currently are not
  12. many problems. mainly that you have to escape your single quotes if your entire string is encased in them if ($stuff['type'] == 'Administrator'){ echo '<a href="password_protected.php">Add/Edit/Delete RSS Feeds</a><br/><br/>'; echo '<a href="admin.php">Main Site Admin</a><br/><br/>'; echo '<SCRIPT type=\'text/javascript\' language=\'JavaScript\' src=\'http://xslt.alexa.com/site_stats/js/s/a?url=www.ssa.co.uk\'></SCRIPT>'; echo '<SCRIPT type=\'text/javascript\' language=\'JavaScript\' src=\'http://xslt.alexa.com/site_stats/js/t/a?url=www.ssa.co.uk\'></SCRIPT>'; } conversely, instead of escaping them "\'" you could just use double quotes
  13. elseif ($directory == 'index') { needs to be index.php if ($directory == '/') { doesn't mean anything and will never actually run true. You are only seeing this line because it is also echoed in the else clause. I would set it up like this: <?php $page = array(); $page = explode("/", $PHP_SELF); $directory_no = count($page) - 1; $directory = $page[$directory_no]; if ($directory == 'index.php') { echo 'Plague Infected | Index'; } elseif ($directory == 'contact.php') { echo 'Plague Infected | Contact'; } elseif ($directory == 'portfolio.php') { echo 'Plague Infected | Portfolio'; } else { echo 'Plague Infected Designs | Freelance art and web design and development in Fort Worth TX and Puerto Rico'; } ?>
  14. ok thats good. you can get rid of the echos and stuff. Just change your if statements accordingly, like for that page it should be if ($directory == "head.php"){ echo "whatever"; }
  15. oh didn't notice something in your code above when I said print_r I meant print_r($page); not to do $page = print_r("/", $PHP_SELF); that is messing up your variables. change it back to $page = explode("/", $PHP_SELF); or whatever it was before
  16. if ($_SERVER['PHP_SELF'] == "/index.php"){ //load the correct banner } Will get kind of clunky with more and more pages, but I would suggest putting the info in a database, or storing the relevant data into an array and getting it that way, like //database way $get = $_SERVER['PHP_SELF']; $sql = "SELECT src FROM bannerTable WHERE page='$get'"; $go = mysql_query($sql); $row = mysql_fetch_array($go); echo "<img src='".$row['src']"' id='banner' />";
  17. oh dude my bad. I'm an idiot $page = array(); $page = print_r("/", $_SERVER['SCRIPT_NAME']); $directory_no = count($page) - 1; $directory = $page[$directory_no]; subtracted from the wrong variable. try that, with the echos and see what happens
  18. this is not going to work. $_PHPSELF returns the page your are currently on, sans any paths to the document itself. So if i'm on www.facebook.com/books/awesome.php and I echo $_SERVER['PHP_SELF'] it will echo "/awesome.php" You are trying to test the variable against a full URL and it will never ever match those. none of those will work. And Echo the variable itself. As in change your code to $page = array(); $page = print_r("/", $_SERVER['SCRIPT_NAME']); $directory_no = count($page); $directory = $page[$directory_no] -1; print_r($page); echo $directory; if ($directory == 'http://plagueinfected.com/') { echo 'Plague Infected Designs | Freelance art and web design and development in Fort Worth TX and Puerto Rico'; } elseif ($directory == 'http://plagueinfected.com/?pg=index') { echo 'Plague Infected | Index'; } elseif ($directory == 'http://plagueinfected.com/contact.php') { echo 'Plague Infected | Contact'; } elseif ($directory == 'http://plagueinfected.com/portfolio.php') { echo 'Plague Infected | Portfolio'; } else { echo 'Plague Infected Designs | Freelance art and web design and development in Fort Worth TX and Puerto Rico'; } that will tell you what the actual variable itself looks like, and what you should change your test too
  19. And it doesn't work for any of the pages? When you echoed them what did they say? oh and the URL won't look like this : /?pg=index index.php in that case. But the others should be fine. try also doing a print_r on $page and see what it holds
  20. wait so when you echo the variable it just shows "-1" at the end of the word? what does your code look like now
  21. echo the directory variable (both your constant and the variable itself) and see what happens. Perhaps the variable isn't the value you expect it to be
  22. This is a really round about way of doing this. Why not just have 1 column for the project name and enter like acro_9_prof and whatever else as values in each row? Do projects have multiple of those values checked at a time, or is it usually just 1 project checked? You are getting undefined variable errors because you only define the variable if a certain condition is met. if its not, then the variable won't be set. change your if statements to have an else clause like if ($acro_8_prof == "1") { $p1 = true; } else { $p1=false; } and then when you check it if ($p1) { Hope that helps
  23. $page = array(); $page = explode("/", $_SERVER['PHP_SELF']); $directory_no = count($page) -1; $directory = $page[$directory_no]; this line: $directory_no = count($page) - 2; should be -1, because you want to get the last entry in your exploded array (which would be the page itself) -2 will give you the second to last, and in many cases, that is also the first, and sometimes it will become -1. Hope that helps
  24. But daniel... secret questions love you
  25. When I did this, I stored the question in my database also, and stored the answer as an MD5 hash. As gareth said its pretty much just a simple query to get the information you want. not too hard
×
×
  • 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.