Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. well, if you have the raw html, a simple regular expression (regex) would probably do the trick. Can you give a couple example urls? preg_match() regex function: http://php.net/manual/en/function.preg-match.php site with regex tutorials http://www.regular-expressions.info/ a basic example would be like //get html from page. store in variable $html; $pattern = '#generic/part/of/url/(.+?)#i'; if (preg_match_all($pattern, $html, $matches)){ array_shift($matches);//take out first entry because it is entire match, which we dont need print_r($matches);//show array structure
  2. strtotime() $date = "01/12/2009"; $time = strtotime($date); thats how you can convert dates of most any format into a unix timestamp. as far as the query, yeah it looks fine. I'm not sure what you mean by care to clarify?
  3. im assuming by image from url, you mean you need to get a certain image from a certain page (that certain page residing at the URL in question) There are numerous ways to do it, but using the Curl library, or simply using the file_get_contents() function will get the raw html of the page. From there you could simply use regex or the html DomDocument class to get the image you want
  4. $username = $_POST['nickname']; ?
  5. remove the quotes around the mysql_query code. Instead of calling the function mysql_query, you are just creating a strign with some PHP code. alternatively, you could keep the code like that and use eval(), but just removing the quotes is easier and better
  6. <a href="http://www.mydomain.com/indexOLD.php?lang=eng" target="blank">Link text</a>
  7. you forgot to close the copy() function on the following line copy($_FILES['file']['tmp_name'], 'images/a_video/' . $_FILES['file']['name'] or die("Could not copy file"); should be copy($_FILES['file']['tmp_name'], 'images/a_video/' . $_FILES['file']['name']) or die("Could not copy file");
  8. As long as we are posting alternatives, here is another, using the Curl library. function getRawHtml($webpage){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $webpage); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $stuff = curl_exec($curl); return $stuff; } by the way, you can't get the PHP when doing either of these. You only get the HTML that the PHP (or other server side language) generates. You can't get the PHP, and frankly, thats theft. If people could just steal other sites PHP (basically the stuff that makes the site a good site) dont you think we'd be seeing a lot of facebook /google clones out there?
  9. that doesn't make any sense. are you sure you are getting 2 new rows from that insert code that yoz gave you? doesn't seem possible to me. perhaps you should post the rest of your code
  10. not many sites that list all the information in one place. A google search turned up a few websites that were slightly related. the second link in my first post gives a very indepth look at most security threats though. beyond that, what i said in my previous post should set you on the right path. Also, if you have shared hosting, remember that if one person has a vulnerable site, it can make everyone else that shares that server's site vulnerable also, so if you are really concerned about security, you may also consider not using shared hosting
  11. not quite true. you can use eval if you wanted to, or, probably the better choice, create_function() anonymous functions would probably also work for you
  12. no problem. if your topic is solved you can click the mark solved button at the bottom of the thread
  13. for one, the monster that one player fights isn't the same as another. that simply isn't how objects work. Not to mention that the script running for one player won't be using the information from another. creating a new instance of an object is one line (ex. $monster = new Monster()) I can't really give a concrete answer without seeing the class though. as far as one way being harder than the other, the differences in code is rather negligible. One way isn't any harder from another, semantically, but if you want to do it the OOP way, than you should create a monster with stats from the DB rather than just comparing the amount of damage that a player does to the amount of damage a monster can take. What if you want to update the battle function to take other things into account (like armor value?) . the turns of the battle would be pretty easy. something like while(..){ $monster->health -= $player->atk; //or $plyDmg += $player->atk; $player->health -= $monster->atk; } if you wanted to take advantage of encapsulation and other OOP principles (basically do OOP) then something like $player->fight($monster); may be what your after the way I personally would do it, is after I created the fight method (which does one round of fighting, not the whole battle) have 2 methods called dead (which return whether or not the player/monster has 0 health) and have my loop logic be something like while(!$player->dead() && !$monster->dead())
  14. the simplest way would be to simply have two seperate columns for first name and last name. that will be much more efficient than any algorithm you would have to create to sort it
  15. either your regex became outdated, your urls are wrong, or craigslist banned you. i'd guess that your urls are wrong. when you print_r $urls, try going to one of the links, and see if it exists (Dont forget to add the /muc/ part of the url you seem to be adding in the for loop)
  16. instead of order by, try using group by portfolioItem
  17. are both of them empty? which one is empty? if its $posts, then your regex isn't finding any matches
  18. well, i don't see why simply subtracting from a monster objects health would be bad. monsters are fairly static, but each seperate monster object is just as dynamic as the player (well not quite as dynamic, but their health would go down) If the player wants to fight another monster, you can just instantiate a new monster object. however, what you proposed wouldn't be bad. but displaying the monsters remaining health would involve an extra calculation (which isn't bad, just relatively unnecessary). As far as updating the db table with the players health, I personally would only update the db after a battle is finished, to reduce the amount of queries that are run in a players game session, but that is more of a stylistic choice. it may benefit your server if you do it this way if you get a lot of traffic however.
  19. ok, try doing print_r on yoru $urls and $posts array and see what their structure is
  20. if you use cookies, make sure you always sanitize cookies values. as yozyk said, watch out for remote file inclusions, and of course xss and sql injections. do you use a database? do you hash/salt your passwords? do you verify that your inputs always get the right information (IE not just "safe", but for numeric inputs do you test that the value is a number? stuff like that
  21. last month and next month echo $nextMonth = date("F", strtotime("last month")); echo "<br />"; echo $prevMonth = date("F", strtotime("next month")); outputs: January March if you want years, just do echo $nextMonth = date("Y", strtotime("last year")); echo "<br />"; echo $prevMonth = date("Y", strtotime("next year")); which outputs 2009 2011 check out the manual page for the date for different formats of the date, and strtotime for more info on strtotime function[/code]
  22. im assuming thats the $st = ...... : $_POST['state']; line? that means that $_POST['state'] doesn't exist, so you probably have the name of the key wrong. Can you post your form? have you verified that there is indeed an input named 'state'
  23. No problem, if your topic is solved, you can click the mark solved button at the bottom of the thread
  24. i'm not familiar with the paypal API, so I can't tell you exactly what to do, but the paypal api documentation will surely have the answer
×
×
  • 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.