Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. Okay so your overall goal here is to come up with a random set of numbers that add up to 100. So, you don't need to necessarily calculate or use all of the permutations, you just need one of them? If that is the case, you can do this: <?php $num = 100; while ($num >= 1) { $rN = rand(1,$num - 1); $d[] = $rN; $num -= $rN; } echo "<pre>"; print_r($d); echo array_sum($d);
  2. .josh

    Help

    If you created/control the stuff that displays this info, why not just write a script that specifically grabs what you need? For instance, have it insert the data into a table or flatfile when it is generated.
  3. And it's going to remain a problem not solved until you start posting some relevant code. If you aren't going to make an effort to fix the code, you can at least make an effort to explain the problem properly and post relevant code. We don't have some magic crystal ball that tells us what your code is or what it's supposed to be doing.
  4. okay so that's the code that displays your stats. That's not the code that figures out what they should be. And you still haven't explained what you mean by it being "stuck". Or is that what you mean by "it's not going up"? what's not going up? One in particular? All of them? Show the code that actually figures out what they should be.
  5. throwing error message is a matter of personal taste, I guess. For instance, here on the smf boards, if you forget the closing tag or else forget to put the / in the closing tag, it simply writes in an extra one, no prompting.
  6. Okay, in the shoutbox code that displays the actual shouts, you have these 2 lines: while($r=mysql_fetch_array($select_shouts)) { if($color == 'dark') { ?> change that to while($r=mysql_fetch_array($select_shouts)) { $r['message'] = str_replace("", "<img src='images/smilies/smile.gif'/>", $r['message']); if($color == 'dark') { ?>
  7. brilliant! Haha why did I never think of that before.. as far as missing a closing one, one way to handle that is to do a quick preg_match_all count on both. If they don't add up, throw an extra one one the end, or else remove one. It will of course cause it to either not render one of them or else render too many, but I think that's the lesser of the two evils, as far as either that or having one left open...
  8. $string = preg_replace('~<div class=rescat>Category:.*?Write a review</a></span></div>~is','',$string);
  9. dude you're making this harder than it needs to be. Where in left-nav.php is the part that displays the shouts?
  10. okay so if left-nav.php is what displays the shoutbox entries, you're going to have to integrate the str_replace in that bit of code.
  11. Right. You need.... What part of it are you having trouble with?
  12. im just a beginer in php can u help me on any?plss sure but if it is an assignement you should do it yourself. What I don't understand is if you are only a beginner and your prof wants you to create this in 3 hours with no experience? Sure your prof didn't tell you this a few months ago but you just waited with it until now, with only 3 hours left? Agreed. I really do not see why a prof would give a completely new student 3 hours to do something like this. Sounds more like you've been slacking off and procrastinating and only have 3 hours left, out of however long he really gave you.
  13. Dude, common sense? How are we supposed to have any idea why it's "stuck" without you posting any code or telling us what you mean by it being "stuck"?
  14. I could use it to portray what I want to do to my landlord, for example. It doesn't have to be against another forum member, any more than any of the other smileys that could be used in a negative fashion. If we are going to give merit to a smiley based on what it could be used for, then we need to nix most of the smileys.
  15. I'm not seeing anything for that in the code you posted. I just assumed that you were wanting to replace that line of : ) with images in that td tag. Perhaps it is in one of your includes?
  16. You can't do it like that. Once the content is output, you can't go back and change it. At least, not with php. I suppose you could use some client-side scripting to do it, but I don't think that's what you're really looking to do. I have to ask...if you have a page hardcoded like that, why not just put the image tags in there in the first place?
  17. How about a smiley that comes up and smacks another smiley upside the head
  18. by replacing "could" with the image tag... echo str_replace(" is", "<img src='...' ... />", $string); that will replace " is" with "<img src='...' ... />" (no outer double quotes)
  19. Your situation involves assigning it to a variable. echo was just an example to portray how php parses things. The reason echo " '$dbuser' = $dbuser"; did not work is because you are still wrapping it in double quotes, overall. so that would output 'value' = value So the idea is to get the first $dbuser to be interpreted literally, while the 2nd one should be parsed. So you can escape the dollar sign as rhodesa did, or any other combo such as $info = '$dbuser' . " = '$dbuser'"; $info = '$dbuser' . " = '" . $dbuser . "'"; // etc...
  20. So that you understand what is going on.. echo $variable; // no quotes: $variable is parsed. Value is echoed echo "$variable"; // double quotes: $variable is parsed. Value is echoed echo '$variable'; // single quotes: $variable is not parsed. Literal $variable output.
  21. At best, it is difficult to handle nested tagging with regex. But anyways, your solution is going to involve more than a simple preg_replace. You will first need to go through and preg_match_all or strripos to find the last occurrence of the opening tag, then replace starting on that position. Wash rinse and repeat for every other opening tag, going backwards to forwards (working your way inside-out).
  22. Nice. So what about the crystal ball? Any luck on the cracked/exploding ball version? I think it's okay as-is; just thinking it would be a lot cooler if it cracked or exploded.
  23. "uno" "dos" etc... are coming from the response from convert.php right? Can't really help you out on that count w/out you posting code from that.
  24. If you're need is really that great, I suggest you hire someone to do it. There is no generic script when it comes to scraping pages, as each page is unique. Learn the art of regex or open up your wallet to someone who has. If you want to learn it yourself, as mentioned by previous poster, look into cURL for getting the initial page content. You can then possibly use DOM to get what you're looking for. If not, you're going to have to get your hands dirty with regex, using preg_match or preg_match_all. I'm moving this thread to the regex forum. In that forum you can see stickies detailing resources for learning regex. As far as storing it in a text file, you'd use something like fwrite (with its supporting functions, like fopen and fclose) or file_put_contents. As far as making it "nicely laid out" well that's up to you to decide how it should be displayed. In general, you would write a script to read the contents of the text file, using fread or file, loop through it, marking it up with html or css.
×
×
  • 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.