Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. Okay so you posted an example text, and what it's doing, can you post what you expect it to look like?
  2. hmm...the only flaw I outright see in it is you should be using a + instead of * towards the end there, as it will allow for tutorials/123/12// But other than that...here is what I get as results, using a list of both your good and bad examples: Array ( [0] => Array ( [0] => tutorials/123/ [1] => tutorials/123/12 [2] => tutorials/123/example-string/ ) [1] => Array ( [0] => 123 [1] => 123 [2] => 123 ) [2] => Array ( [0] => [1] => /12 [2] => ) [3] => Array ( [0] => [1] => 12 [2] => ) [4] => Array ( [0] => / [1] => [2] => /example-string/ ) [5] => Array ( [0] => [1] => [2] => example-string ) ) IOW I'm thinking your problem isn't really with the regex but somewhere else in your mod_rewrite
  3. not 100% sure without seeing more code (like the relevant html this stuff affects) but if I had to take a guess, I'd say that when you make the AJAX request and new content is returned (probably specifically this: $("#pagination").empty().append(ms.pagination); ) you aren't applying the original .click() to the links that make the pagination script execute. If this is the case, you need to actually put that .click(..) stuff in a function and then you can call the function initially on document.ready and then you'd also have to call the function again after the new content is loaded to reapply the event listener to the new links. IOW when you execute an event listener like that, it only applies to what is currently in the DOM, not new stuff generated.
  4. hmm looks more like you are trying to mix php with javascript...You cannot call javascript functions server-side. PHP is parsed by the the PHP interpreter on the server. Javascript is just arbitrary text to the server. Javascript is parsed client-side by your browser.
  5. Your welcome! And to those who are wondering what this is all about... We at PHP Freaks have been hard at work creating a system that can parse posts you make and attempt to automatically solve them. Some key features and points: No need to worry about posting in perfect English! Our advanced natural language parser can handle even the leetist of leetspeak, lolspeak, lrn2readspeak, etc... No need to worry about correctly using bbcode tags, like wrapping code in code tags! They will automatically be detected! Cutting edge heuristic methods give us a 98% level of confidence of answering your question! We are so confident in this new system that if it cannot automatically solve your problem, the server immediately notifies a team of experts on standby who's sole purpose in life is to answer your question! Where is this magic button, you ask? It's right next to the post button! Just start a new thread like normal, post your question in the text area, and down by the "Post" and "Preview" buttons, you will now see a third button "Auto Solve!" Click it and marvel at its awesomeness! Still not convinced? Point in fact, this post was generated automatically!
  6. wow..your laptop runs without a battery and power-cord? where do I get one of those?
  7. yeah...I always had the impression those netbooks were primarily targeted towards teens as being something a bit more than what you can do with a cell phone but don't wanna justify buying a full laptop.
  8. I've heard rumors of netbooks getting pretty hot...
  9. To expand...(translation: salathe beat me but dammit i made a long post so I'm posting anyway!) Ultimately, in javascript a regex pattern is actually an object. So you can use the pattern directly in the .replace() like that because it will ultimately evaluate to a regex object. However, you can setup a regex pattern, putting it in a "string" by creating a RegExp object...though in the end you are still creating an object. So for example, you could alternatively do: var str = 'sentence test&new'; // 2 arguments: "pattern", "modifiers" var pattern = new RegExp("(.*)&","g"); str = str.replace(pattern,''); In this example, you are putting putting the pattern in quotes - as a string. But again, ultimately this creates an object. The main benefit of doing it this way over using the pattern directly as an object (no quotes, directly in .replace()) is if you want to make part of the pattern a variable. Example: var subject = 'bargain'; var foo = 'bar'; // works : use a variable and the pattern is the value of the variable var pattern = new RegExp(foo,"g"); str1 = subject.replace(pattern,''); alert(str1); // output : 'gain' // does not work : it looks for the literal string 'foo' str2 = subject.replace(/foo/g,''); alert(str2); // output : 'bargain'
  10. technically you need a g modifier on there. By default, preg_replace() replaces all. By default, .replace() does not. ...though based on context of the subject...it probably doesn't matter...
  11. okay well even if you wanna disregard what gizmola is saying, at the very least you should use (.*?) instead of (.*) What you have now is a greedy match and you will get unexpected results! It's probably "working" for you right now because you have something like this: <input type='hidden' name='something1' value='blah1'> <input type='hidden' name='something2 value='blah2'> where inputs have linebreaks in them and you aren't using s modifier in your pattern. But if you run up against content where there is no line break between it... <input type='hidden' name='something1' value='blah1'><input type='hidden' name='something2 value='blah2'> run it on a string like that and see what happens!
  12. No. echo doesn't work that way. You can't put if statements inside an echo like that. This is your code with the changes. $i = 1; echo "<table border='1' align='center'><tr>"; $result = mysql_query( "SELECT * FROM membership order by L_ID asc" ); while ( $row = mysql_fetch_assoc( $result ) ) { echo "<td align='center' bgcolor='#DDDEFF'><a href='profile_view.php?L_ID=".$row["L_ID"] ."'>"; $pic = 'images/avatar/'. $row["L_ID"] .'s.jpg'; if (file_exists($pic)) { echo '<img src=http://www.thefriendzconnection.co.uk/images/avatar/'.$row["L_ID"] ."s.jpg>"; } else { echo "<img src=http://www.thefriendzconnection.co.uk/images/0s.jpg border='0'>"; } echo "</a><br><font size='1' face='Arial, Helvetica, sans-serif'>".$row["name"] ."</font><br><font size='1' face='Arial, Helvetica, sans-serif'>ID:".$row["L_ID"] ."</font><br> </td>"; if ( $i % 6 == 0 ) { echo "</tr><tr>"; } $i++; } mysql_free_result( $result ); echo "</tr></table>";
  13. missing echo "</a> <br><font size='1' face='Arial, Helvetica, sans-serif'>".$row["name"] ."</font> <br><font size='1' face='Arial, Helvetica, sans-serif'>ID: ".$row["L_ID"] ."</font> <br> </td>"; should be echo "</a><br><font size='1' face='Arial, Helvetica, sans-serif'>".$row["name"] ."</font><br><font size='1' face='Arial, Helvetica, sans-serif'>ID: ".$row["L_ID"] ."</font><br> </td>";
  14. missing semicolon: echo "<td align='center' bgcolor='#DDDEFF'><a href='profile_view.php?L_ID=".$row["L_ID"] ."'>" should be echo "<td align='center' bgcolor='#DDDEFF'><a href='profile_view.php?L_ID=".$row["L_ID"] ."'>";
  15. improper use of quotes. echo '<img src=http://www.thefriendzconnection.co.uk/images/0s.jpg border='0'>' should be echo "<img src=http://www.thefriendzconnection.co.uk/images/0s.jpg border='0'>";
  16. so what happens if the value has a " in it?
  17. If you are using firefox, then stf should work for you. Since you want to save to a single file, you will have to change some of the option settings (by default it saves each time to a separate file). With this addon I can highlight something on my page and rightclick and it shows in the menu "Append to [filename]" and I click on that and it appends to that file. Example of file: The highlighted red is the actual text I highlighted and saved. And my settings also have it save some info about where I highlighted (page title, timestamp, url) - you can have it not show any of that if you just want the words themselves, though IMO this info might also be useful to you as a reference.
  18. I do not recommend using regex for this. As Maq suggested, use xml. If that is something you can't do, then can you explain what you are ultimately doing with these values, how you are parsing and using them later? Another option is to store as serialized array or a JSON object string. But again, it depends on what you are doing with it later on. But if you are able to parse with regex later on, I really don't see why you can't do one of these other solutions.
  19. $result * 20
  20. some of your conditions are using = (assignment operator) instead of == (equality operator)
  21. script.php <?php // start a session session_start(); // do query stuff if (query is false) { // create a session variable $_SESSION['errorMsg'] = 'error message here'; // kick user back to previous page (the page that requested this script) header('Location: ' . $_SERVER['HTTP_REFERER']); exit(); } pageone.php <?php // start session session_start(); // if variable exists, echo it out if ($_SESSION['errorMsg']) echo $_SESSION['errorMsg']; ?> <!-- form stuff here -->
  22. This isn't really a javascript question specifically...but anyways, the basic principle is that you can pass information in a parameter1=value1&parameter2=value2[etc...] to the target page - IOW pass arbitrary data. Many times this is the only way to pass data to a target page, due to security or other code restrictions, for instance, passing data from one page to another where the pages are on different domains (cross-site scripting or XSS). As to why people do this...well there are virtually an unlimited number of reasons why you would want to pass data to a target page, though here are the most common reasons: Pass information to help determine output For example, lets say you have a website with 3 pages: home, about, contact us. Now you can have 3 separate files with 3 separate URLs to link to in your site navigation bar, but instead of that, you can have a single URL that outputs the relevant content, based on a parameter you pass in the link. So for example, instead of <a href='home.html'>home</a> <a href='about.html'>about</a> <a href='contact.html'>contact</a> You can do <a href='index.php?page=home'>home</a> <a href='index.php?page=about'>about</a> <a href='index.php?page=contact'>contact us</a> Then in index.php you would have something like this (simplified for purpose of example): <?php $page = $_GET['page']; include($page); ?> Now based on this example, this doesn't seem like it's really worth doing...seems like it's just unnecessarily complicating things. But let's put this into perspective. Lets say that you have your 3 pages and you have opted to make them each their own individual page. On all 3 of your pages, you have a lot of the same exact code being used. For the top of your page you have the same code for your site logo, links to your pages (nav bar), etc... You also have the same css/js output on all the pages (inline or as tags pointing to other files). Maybe you also have the same code being put on all 3 of your pages for a footer area. Maybe even the general structure of the actual body of your pages are the same, and the only thing really changing is some text in the body. The point here is that for all 3 of these pages, you have a lot of the same code being put on all pages. So what happens if you need to do something like change the url of your logo? You would have to go and make a change to all 3 of your pages individually. Not so bad with 3 pages. But let's say you have 10 pages. Or 100. Or 1000. Now it sounds bad. So the idea of having a single page is that you make a single "template" page with all the common stuff in it, and then you have separate files for each of your pages, but those files have content unique to that page (in reality you will more than likely actually store the unique page content as entries in a database). Marketing Efforts After you've spent the time and money and effort making your website, you want to advertise. On the internet, this usually involves placing ads on other peoples' websites. This can be in the form of paying to have your link show up on search engine search result pages, banner ads, etc... Since you are more than likely making an investment in getting people to display your links, you will usually want to be able to keep track of them, find out how many people are clicking on them and if they ultimately do whatever it is you want them to do (signup for something, register, purchase, etc...). This is called campaign tracking, and this is where web analytic tools come into play. Tools like Google Analytics, Yahoo Web Analytics, Omniture SiteCatalyst, WebTrends, and many others that ultimately do the same thing in principle. So the principle is this: Lets say you want to pay people to post a link to your site. You pay for some keywords or ppc ad space on the major search engines and banner ad companies, to get some advertisement out there. And lets say you have the link to your site displaying in 5 different places. At each place, you are probably paying a different amount of money to have your link appear. You're paying good money for that ad space and you don't want to keep investing in some place if it's not making you money or getting people to your site etc.. So on each link you would have a unique code like http://www.yoursite.com/landingpage.html?source=google http://www.yoursite.com/landingpage.html?source=bing etc... Then on all of the pages of your website, you will have tracking code in place. And you have it look for that url parameter and report the value to the tracking tool. And then you can go to the reports in your tracking tool and see how many people came to your site on each campaign code. Also, you can setup your tracking tool's code to track actions on your site, like triggering other codes whenever the user does something, like complete a form or make a purchase. Then the tracking tool can show you reports linking all these things together, so you can see for instance not only how many people came to your site from google, but how many of those people did certain things on your site (like actually purchase something). With this information you can then figure out which place to spend more money advertising on. For example, if you see that 1000 people came to your site from one of your 5 campaign codes, but 800 of them were from one of them...that might be an indication to stop investing advertisement in the other 4 places. I say "might" because you have to look at more than just how many people made it to your site. If you keep digging and see you have 100 sales from those 1000 people, but all 95 of them came from those other 4 links (not the one that brought in the 800 people), then you can see that those other 4 links are actually a lot more valuable to you, because they produce higher conversion rates (people who complete whatever goal you want them to complete, like registering, purchasing, etc..). Campaign codes and campaign tracking is a bit more complex than this, but this is the core principle, extending to an entire ppc/seo/web analytics industry (and even then, each of those things are industries in their own right).
  23. no biggie...was just confused, thought maybe I was missing something, like you had js code querying some php file and it was returning that or something idk.
  24. get_browser() is a php function...why are you posting this in javascript forum? As to your error: http://stackoverflow.com/questions/2036956/browscap-ini-directive-not-set
  25. I see all kinds of things either straight up wrong or don't make sense in your function...but it's hard to help when you don't explain what it is you are actually trying to do. If I had to take a guess...I "guess" you are trying to grab a value from a form element and based on the value, either return that value or else redirect to some other page? Also, post the relevant html that this javascript is supposed to work with. And use code tags for code you post. [ code]your code here[ /code] (but without the spaces)
×
×
  • 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.