Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. @MrAdam : Yes, using server-side scripting to input the variable would be the easiest thing. You could even get the URL easy enough from php when the user submits the form, without the hidden field at all. But since he's asking for apples, we can only assume he needs an apple, not an orange. He may not have access to the server-side scripting (and it may not even be php!).
  2. Okay so your main problem is that your input field is html and you are trying to put javascript in it. Well you can't mix it like that. You have to use javascript after the fact to grab the element by its id and assign a value to it. However, you will then run into a problem of making sure the element is actually loaded into the DOM before javascript tries to assign a value to it. If you have an existing framework on your page like jquery, you can do something like this (jquery example): <input type="hidden" name="page" id="page" value=""> <script type='text/javascript'> $(document).ready(function() { $('#page').value = window.location; }); </script> If you do not have jquery or similar framework, you can go here to see what kind of coding you have to do to make sure the document is ready for all browsers (lots more code - which is why using jquery or similar is great). A third option that I don't really recommend but it works is to wrap the assignment in a function that checks if it exists. If it does not, keep calling the function until it does: <input type="hidden" name="page" id="page" value=''/> <script type='text/javascript'> function setValue() { if (!document.getElementById('page')) { var t=setTimeout('setValue()',100); return false; } else { document.getElementById('page').value = window.location; return true; } } setValue(); </script> This isn't really advisable though because if for whatever reason it never gets loaded, the function never stops getting called.
  3. If your employer requires it, and they know you don't know it, make them pay for the certification training at Zend. Businesses do that sort of thing all the time.
  4. The only thing that really *counts* right now is traditional college. Take some Computer Science classes at your local college. But if you want to go the certification route, Zend Certification is probably the most *legit* there is right now.
  5. so just cut to the chase, have all your teeth removed and replaced with enamel.
  6. page1.php <?php session_start(); $_SESSION['someVar'] = 'this is a session variable'; $_SESSION['someArray'][] = 'this is a session array (element 0)'; $_SESSION['someArray'][] = 'this is a session array (element 1)'; $_SESSION['someArray'][] = 'this is a session array (element 2)'; echo "<a href = 'page2.php'>click to go to page 2</a>"; ?> page2.php <?php session_start(); echo $_SESSION['someVar'] . "<br/>"; foreach ($_SESSION['someArray'] as $value) { echo $value . "<br/>"; } In most cases, there are basically there are 2 things to note: 1) In order to make use of session variables (or arrays), you have to have session_start() on your page somewhere before actually using the var/array, and it also has to be put BEFORE any output (including any whitespace). 2) All session variables and arrays are contained within the $_SESSION super global array. So session variables/arrays are really just elements of the $_SESSION array. You can see it better by doing on page2.php <?php session_start(); echo "<pre>"; print_r($_SESSION); echo "</pre>"; ?>
  7. $id = $row['id']; or... just use $row['id'] as your variable since you only have 1 returned...
  8. Okay well the only thing I can really see wrong is for your first 2 links, the 2nd argument for window.open() has a space in it ("View rooms" and "Add rooms"). In IE, you can't have a space.
  9. instead of echoing or printing it out, store it in a variable or array and return the variable or array after the while loop.
  10. no, there is no native var dump for js (yeah I don't understand it either...) but a quick search will reveal plenty of functions that loop through and emulate it easy enough.
  11. make a normal link. style it to look like a button. Or wrap a link tag around an image, however you want the "button" to look. Put the javascript call in the onclick of the link.
  12. {...} is a range quantifier. Example: {n} n occurrences exactly {n,} At least n occurrences {,m} At most m occurrences {n,m} Between n and m occurrences What your pattern says is..."match exactly 7 of...." except you aren't actually matching for anything in that pattern. Please explain what it is you are actually trying to match.
  13. oh mjdamato...no jquery?? you are missing out...I resisted for so long but when I finally picked it up...my only bitch about it is why oh why did I not pick it up sooner!
  14. please post the code that actually outputs the images, not just the images themselves (like the echo "...."; or whatever)
  15. look into preg_replace_callback. It can extract data and replace it with something else as it finds it, and you can supply a function to be called (passing the extracted info, returning what to replace) each iteration, so you can perform your calculations in the callback function (or call some other function that does it, w/e).
  16. It seems to be happening whenever I go there. I guess it keeps getting blinded by my pure awesomeness.
  17. ah sorry about that...yeah the mysql (no i) version doesn't require the connection resource as an argument. If you don't supply it, it uses the last connection opened by default
  18. it would help if you showed us HOW you were trying to use it...basically it's just a normal function where you pass the string to it and it returns the escaped string. Main thing about it is that you have to have a db connection open first, in order to use it, because it relies on settings in your db to properly escape stuff. But in general, you would use it as such: // connect to your db somewhere before this... $id = mysqli_real_escape_string($_GET['id']); $posts_by_city_sql = "SELECT id, city_id, title FROM postings WHERE city_id='$id'"; $posts_by_city_results = (mysqli_query($cxn, $posts_by_city_sql)) or die("Was not able to grab the Postings!"); //$title = $_GET['title']; // mysql_real_escape_string($title); while($posts_by_city_row = mysqli_fetch_array($posts_by_city_results)) { echo "<li><a href='posting_details.php?id=$posts_by_city_row[id]'>$posts_by_city_row[title]</a></li>"; }
  19. @JAY6390: I'd probably use \s* instead of \s+? because you don't technically need a space. But even if at least one space was certain, you don't actually need that ? as all it does is make it lazy, not optional, and it's matching something specific, not a wide range (like a dot). Also, your char class only has lowercase a-f. Since capitals are allowed, you either need to throw A-F in there or use i modifier. Also, {3,6} probably won't work either...that would allow for instance 1234 which is not valid...would probably need to instead use alternation like ~\bcolor:\s*#([0-9a-f]{3}|[0-9a-f]{6});~i and one last thing, i'd consider wrapping that whole thing in matching for <...> or style="..." to more specifically put it onto a context where you'd find it.
  20. yeah, was just nitpicking you don't even need to setup a js regexp object if it's a straight pattern, only if you want to throw a variable into the mix as part of the pattern.
  21. @gizmola: preg_match() is a php function, he is asking about javascript. But that does bring up the point of...why are you scraping this page with javascript? There are 100 better ways to get that data.
  22. assuming you actually added the code to the link's onclick correctly, there's another hoop to jump through that GA fails to mention or consider: more often than not, when you click on the link, you wind up getting taken to the download before the GA code has a chance to trigger. See this post for details. Different question, same principle.
  23. Especially to # .37 as only being about a 3rd of a person must make things especially challenging. Thumbs up to you! (If you have thumbs...if not, no offense intended, mr. thumbless person)
  24. post count has always been visible to all. But depending on your rank, it may only show up in the user profile, not on posts.
  25. minor caveat..that would allow someone to enter in "100." (a dollar amount and a decimal but no cents). I don't know how often that would *really* come up but you should be aware that it is possible. You can easily automatically look for and trim it off if it's there instead of making the user jump through that hoop though... Also it would allow for "100.1" (vs. 100.10). Technically the "100.1" is valid and the same according to the computer but most people write it with the 0. Mostly a matter of philosophy but again, just wanted to make sure you are aware that is possible. To fix both of these with the current javascript code, you can change {0,2} to {2} and that will force the user to enter in 2 digits after the decimal. But again, there are ways to fix it where it doesn't involve making the user do it, so yeah...up to you.
×
×
  • 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.