Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. since you seem to be using OOP to some extent, storing the hp/atk/def of players and monsters, and retrieving them should be pretty straight forward. A battle loop would be pretty simple (based on how simple your description is), and if its just based on atk and def (not weapons or special status or anything, something as simple as) while($player->health > 0 && $monster->health > 0){ //do battle } could work. you may want to tweak the logic a little if you want extra stuff
  2. yes you will have to send the session data as a get or post in order for paypal to get it, as session information is stored on the server itself
  3. I see nothing horribly wrong, but a lot of stylistic issues. For example, all those else if' s can be compressed into a single switch statement switch($st){ case "montgomery": $url = array(...); break; case "etc..."; break; } edit: or take premiso's advice try adding the following to the top of your page to allow error reporting error_reporting(E_ALL); ini_set("display_errors", 1); and report whatever errors the script spits back. also, make sure you view the source if the page is still blank, malformed html may cause the error to be written inside tags that don't show up
  4. in that function, it looks like $img is the key. I'm assuming the keys are of the format date('Mj'), which, for example, today would be feb9. in that case, doing something like $img = date('Mj'); if (!isset($images[$img])){ $img = array_rand($images); } and replacing the line $img = array_rand($images); should make it work.
  5. you also want to use curly brackets when using arrays in strings, like $arr = array(....);//some array $str = "i have {$arr['key1']} cars, but don't have {$arr[0]} bugs";
  6. depends on your application, but the following link may be of some use to you. what kind of web page do you have? is it user based? what kind of input do you receive? http://forums.mysql.com/read.php?52,227585,227585 another good read http://www.scribd.com/doc/13069480/Web-Security-Threats-and-Counter-Measures
  7. im not quite sure you understand what the array() function does. it creates an array of the elements you pass into the function. perhaps you want to use isset(), something like. Which array holds all the filenames?. assuming $images is the array, and the keys are defined as the days (in the format of Mj, like you have in the date function) something like the following may be what your after. if (isset($images[$day]); if not then try doing echo "<pre>"; printt_r($images); echo "</pre>"; and tell me the structure of the array
  8. in your move file function (whether its move_uploaded_file() or copy(), or whatever) just set the path to reflect the change of folders you will have
  9. JS cookies can read PHP cookies, and vice versa, but PHP url-encodes its cookie data, while Javascript doesn't, so doing this may work sometimes, but not work other times
  10. kind of a vague question. What is this action? How exactly is his action applied to a user? How do you know if a certain user did a certain action to another? some more information would lead to a better answer. Right now, all I can say is you will probably be using the SELECT command at some point
  11. can you post an example? I'm not quite sure what you mean, you don't define functions in the php.ini file, you simple define them in a .php file, and either use them in the same file, or include the file in another.
  12. The first example is the syntax for an array, while the second is for an object. 2 different data structures
  13. assuming the dates are always valid, clever use of the strtotime function would work $date1 = "2010-01-01"; $date2 = "2010-01-25"; $time1 = strtotime($date1); $time2 = strtotime($date2); $diff = abs($time2-$time1); //convert seconds to days $diff /= 60 * 60 * 24;//60 secs a min / 60 mins an hour / 24 hours a day echo ceil($diff); output:
  14. Aeroswat has probably pin pointed your problem. What version of PHP did your old and new server have? If you had an older version, the setting register_globals was probably set on, which would make the code work. This setting has been deprecated as of php 5, removed as of 6. http://php.net/manual/en/ini.core.php (search for the register_globals entry for more info)
  15. You should use a test database to test out what little nuances come along with these commands, but yes, more or less your thoughts are correct
  16. whats the parse error? What line? can you show the code as it stands now something as simple as $sql = "update ... SET selected = $var WHERE ...."; should work
  17. try using \r\n instead of just \n
  18. code would help. It seems to be getting stuck on the error messages
  19. you could just use html entities instead of stripping the tags. that way the tags would still be there, but if printed on a web page, wouldn't execute.
  20. You are going to have to provide a little more information, as I just tried that and it worked perfectly fine. What "exactly" is happening? is there any more code on that page? Where is that echo statement? Version of PHP you have? What browser is this happening on (and have you tested it on multiple browsers?) just saying its not working isn't going to get your problem solved
  21. PHP is written in C, not C++ (i'm nitpicking, I know), and technically, if your object doesn't need a deep copy, there is no need to define a copy constructor (or the other two of the big 3) as the default one that the compiler gives you would work just fine. Since PHP has no real pointer type, deep copy's wouldn't be very useful anyways. I'm not even entirely sure what copy constructors have to do with what OP is doing, but anyways... have you looked into print_r you can pass true into the optional second parameter to have the function return a string instead of printing something out. It seems this would do exactly what you want. $str = print_r($array, true); echo $str; //or just //print_r($array)
  22. you can use $_GET variables for that. you can simply make a link like so <a href="where.php?id=5&name=mike">Clicky</a> in where.php you can access those values in the $_GET array. for example, the value of 5 (sent in the variable "id") can be accessed via $_GEt['id']
  23. Well start out with a mysql tutorial: http://www.tizag.com/mysqlTutorial/ you want to do a select statement though (probably using the LIKE keyword) for the search. something like SELECT columns FROM table WHERE column_to_check_against LIKE 'search term'
  24. you can use the following regex pattern to validate emails $pattern = "#^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$#"; note i use # as a delimiter. an example $email = "bad email"; if (preg_match($pattern, $email)){ echo "good email"; else { echo "bad email"; } output: bad email sorry forgot other part. if you want to test for empty fields, use the empty() function, IE if (empty($field)){ echo "field is empty. Fail!"; exit(); }
×
×
  • 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.