Jump to content

Michdd

Members
  • Posts

    510
  • Joined

  • Last visited

    Never

Everything posted by Michdd

  1. Is there a way I can get the last 3 results of a query in ASC order without running more than one query? I know I can do this way: $query = "SELECT * FROM `table` LIMIT " . (Query to count results) - 3 . ", 3"; But is there a better way?
  2. $split = explode("\n", $string); foreach($split as $part) { $parts = explode('-', $part); $info[$parts[0]] = $parts[1]; } Where $string is the contents of the file.
  3. How would I store mysql connect info gained during an installation? I'm creating a way to install an application but I'm not sure the best way to store mysql connect info so that I can get it later to connect to the database.
  4. I've gone there, and have learned a lot about how it works since making this post. However there are lot of specifics which are unclear to me. They describe it well, but don't give the specifics. Like the parameters of the URL for specific methods, and such. I also have other questions, like using their 'sandbox' am I supposed to create bother a buyer and a seller account to test my scripts? But I've turned to their help forum for these questions.
  5. Yes, file_get_contents() does work outside of the server. And I know that with cURL you can send POST and GET values, but if you're not requiring any of that would be acceptable to use file_get_contents()? I just started studying the paypal API, and most examples use cURL, but since they're just querying a simple url with parameters and getting back the response it seems that it could be done simply with file_get_contents().
  6. Say you're just wanted to get the output a of an external site, what would be the advantages of using cURL over just doing file_get_contents('site url'); ?
  7. Does anyone know where I can find some tutorials for working with the paypal api? I've done some searching without finding anything that has really helped me.
  8. Does anyone know any good websites where people try to recruit people for group projects? Like programmers looking for artists, and artists looking for programmers?
  9. That's really.. weird? I don't see how I could've removed them.. I c&p'd that directly from my file.
  10. The setting in which I'm using it in is actually a bit more complicated, but yea it does work for me: $string = preg_replace_callback("(\[spoiler\](.+?)\[\/spoiler\])", create_function('$matches', 'return getContent("spoiler", Array(str_makerand(32, 32, true, false, true), $matches[1]));'), $string); Similarly I'm using other things like this for other bbcode: $string = preg_replace("(\[b\](.+?)\[\/b])is",'<span class="post-style-bold">$1</span>', $string); $string = preg_replace("(\[i\](.+?)\[\/i\])is",'<span class="post-style-italic">$1</span>', $string); However, what you gave me doesn't work. It matches a lot of things incorrectly.
  11. I currently use this regular expression: (\[spoiler\](.+?)\[\/spoiler\]) which works for , but I want to edit it so it also works for [sp][/sp].
  12. $sig = mysql_real_escape_string($_SESSION['sig']); $boot = mysql_query("SELECT Boot FROM gebruikers WHERE hash='$sig'");
  13. I never knew that, thanks.
  14. I have a simple query and I'm trying to check to see if a board already exists with the same name or abbreviation, excluding the current board. $result = mysql_query("SELECT * FROM `boards` WHERE name!='$board' AND abb='$abb' OR name='$newBoardName'"); $row = mysql_fetch_assoc($result); if(!mysql_num_rows($result)) { } else { echo $board . '-' . $row['name']; } How is it possible that $board is the same as $row['name'] when that's clearly excluded in my query?
  15. Never mind, I solved it. I didn't understand the create_function function well, so that's why I was confused.. I just needed to global a variable.
  16. Using preg_replace_callback I need to be able to access a variable from outside within the create_function parameter, is this possible?
  17. Is it possible to make the height of the div so that it only displays the top line of that div? I'm waiting to create something dynamic using javascript that will only display the first line of the div until the mouse is over it, then it will display the full div.
  18. I need help creating a query to get the most popular topics. I was thinking that I could get the average time/post by getting the time since a topic was posted (timeNow - TimePosted) divided by the amount of posts it has then order by that ASC. But I don't think it's possible to formulate a sql statement like that because you'd have to loop through all the topics to get the amount of posts in the topic. Any ideas on how I can get which are the most popular?
  19. The title says it all pretty much. I want to transform a url from file.php?id=something to file/something . I made something for transforming file.php to file, but I can't figure out a solution for what I want more specifically.
  20. I think the problem might be relating to the fact that highlight_string outputs already, and since I'm preforming that on part of the string, then echoing the whole string over it's causing some conflict. Any ideas on how I can fix, or even just test my theory? Edit: Solution was really simple. Just needed to add the option parameter in the function, and set it to true.
  21. Oh, I probably should've mentioned this: The output of the function ("1") is being displayed in place where the tags are.. I couldn't figure out a way to make the output not display..
  22. That's really it, that one line. The only other thing would be the html. Which is just some html which contains <highlight>some code here</highlight> at the bottom of it all. But after it's output the highlighted text is moved to the top..
  23. I have a variable that contains HTML content, I'm trying to find and replace stuff within <highlight></highlight> tags with the text returned from the highlight_string function. It works pretty well, but for some reason the text is being moved to the topic of the html. I thought it might be an html issue, but looking at the source it is at the top. Here's my source: $html = preg_replace_callback('/<highlight>(.*?)<\/highlight>/s', create_function ( '$matches', 'return highlight_string("<?php" . $matches[1]);'), $html); Any ideas?
  24. Oh, that's awesome. I didn't know that function existed so I just used preg_match, then used that variable in preg_replace. But that's better. Thanks.
×
×
  • 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.