Posted June 7, 2010 I do know how to code. And I'll take down the MM image, don't worry. I just made an ER btw http://dcmm.webege.com/sitebuttons/DCER/DCER.php Rebsingh nice little ER. How does one remove their hatchling after entering it in the ER as an egg? Share this post Link to post
Posted June 7, 2010 Rebsingh nice little ER. How does one remove their hatchling after entering it in the ER as an egg? There is a bug. I need to look into it. Share this post Link to post
Posted June 20, 2010 Well for the last couple of days I've been dabbling into creating a site of my own. I do have some coding experience, although I'm far from an expert, but I have been stuck on what should be an easy problem for much longer than I care to admit. It's finally time for me to ask someone I think. ._. I'm currently trying to code the viewer. I already have my MySQL database up and running just fine, and I have a few of my eggs in there I've been testing with. I can get the correct number of eggs to show up, however, I cannot seem to stop from getting duplicates no matter what I do. The viewer would be rather pointless if it shows the same 50 eggs at once. I have already tried using Distinct, but it seems to make no difference, and I have been scouring the internet for answers with no luck. If anyone can help and wants to take a look at my coding, send me a PM and I'll let you see what I have so far. Share this post Link to post
Posted June 20, 2010 SELECT [B]*[/B] FROM [B]db_table[/B] [U]WHERE code='$blah'[/U] [B]ORDER BY rand()[/B] [B]LIMIT 10[/B] * -- Can also be the fields in the database. db_table -- The name of the table. LIMIT 10 -- The number is how many record you want to show, can be any number. ORDER BY rand() -- Randomly picks entries from the table. WHERE code='$blah' -- optional part of the query. Then run a while loop through it all to display. $sql = mysql_query("SELECT * FROM db_table ORDER BY rand() LIMIT 5"); while($object = mysql_fetch_object($sql)) { $code = $object->field_name; print "<img src=\"http://PLEASE_READ_THE_RULES_BEFORE_ATTEMPTING_TO_POST_YOUR_EGGS$code.gif\">"; } That is from the top of my head, I may have my syntax slightly wrong, but I believe that code to be correct. For some tutorials that I have put together ... check http://www.jaemeia.net/guides.php Share this post Link to post
Posted June 21, 2010 (edited) I'm trying to make a sperate nest and seperate Nursery (Currently, hatchlings and eggs are mixed and all that.). I have been fooling around with a couple of lines of code and it doesn't seem to work... someone please help? $drag1 = $_GET [ 'code' ]; $data = unserialize(file_get_contents('http://www.dragcave.net/api/PRIVATE_KEY/serialize/view/'.$drag1)); $hatch = $data['dragons'][$drag1]['hatch']; if ($hatch == 0) { echo 'It seems like you are trying to add an egg. Please use the Egg Adder.<br><a href="HatchAdd.php">Click to try again.</a>'; return false; } else { Well the HatchAdd.php page keeps on not letting me add ANYTHING. Edited June 21, 2010 by Rebsingh Share this post Link to post
Posted June 21, 2010 Because you have a typo ... if ($hatch = 0) { It should be ... if ($hatch == 0) { Share this post Link to post
Posted June 21, 2010 (edited) In PHP = means an assignment while the comparison is == Short overview: Assignmens: = += (Shortform for a = a + -= (Shortform for a = a - *= (Shortform for a = a * /= (Shortform for a = a / .= (Shortform for a = a . b, this is concatination of strings) |= (Shortform for a = a | b, this is OR) ^= (Shortform for a = a ^ b, this is NOT pow(base, exponent) but XOR) &= (Shortform for a = a & b, this is AND) Comparisons:== <= >= != (<> in SQL, a != b means a is unequal $test = false; if($test = false) { echo "You will NEVER see me."; } $test = false; if($test == false) { echo "But you will see ME."; } This can even cause strange bugs: $test = "abc"; if($test = "def") { echo "BIG Bug"; // You WILL see this } echo $test; // Will display "def", NOT "abc" as intended!!! Do not mix up with MySQL where = is both, comparison AND assignment, based on the context (Either when it's used in the WHERE-clause (comparison) or in the SET-clause (assignment)). EDIT: Damn those emoticons :/ Edited June 21, 2010 by Ext3h Share this post Link to post
Posted June 21, 2010 I already switched it when i noticed my mistake (Check the edit ) and now it won't add eggs or hatchlings. Share this post Link to post
Posted June 22, 2010 Well I've hit another roadblock while trying to create a scroll reader. I currently am able to input a username and display that account's eggs and hatchlings, including the checkboxes to choose which ones to add/remove. For testing purposes, the page is currently set up simply to state one message if it's checked, and another one if it isn't. But this isn't working. Strangely, if I check only one of them, they all say they're unchecked. But if I check two or more, they all say they're checked. It doesn't seem to matter which ones I check to replicate these results. I know PHP does not output anything for unchecked options, and it treats them as though they don't exist, so I will probably have to use javascript as well. But I just don't have any idea where to begin with this. @.@ Here is my bare bones prototype I've been testing with: http://ssu.webuda.com/addtest.php Any help would be greatly appreciated. Share this post Link to post
Posted June 22, 2010 I think I understand what you are trying to say ... I will say it in pseudo code, because I can't be bothered thinking of the proper syntax. Read scroll Display check boxes User checks some boxes Click submit Read scroll into temp array loop through temp array if statement (comparison) ... is item from temp array in the codes array ... if yes then selected, if no then unselected. Display status The other method is the reverse of that ... Read scroll Display check boxes User checks some boxes Click submit Read scroll into temp array loop through codes array remove item from temp array if it exists What is left in temp array is unselected items, what is in codes array is selected items Display status. Share this post Link to post
Posted June 22, 2010 Thank you Soti. That gives me some new ideas on how to approach it. Time to try again to make this work. Share this post Link to post
Posted June 27, 2010 (edited) Can anyone help me so that when eggs hatch, they automaticallay get moved to the nursery? Like Sunny Side Up and all... @Ryukotsusei - On your scroll reader, you want to check if the user exists and if they have dragons. I see you have the user exist code but not the one where it checks if they have no dragons. This can help out: foreach($young['errors'] as $error) { if($error[0] == 4) {echo '<center>Sorry, this user has no dragons.</center>'; return;} } Edited June 27, 2010 by Rebsingh Share this post Link to post
Posted June 27, 2010 Oh thanks Reb. Simple oversight on my part. Will get to it this evening. Share this post Link to post
Posted June 27, 2010 Oh thanks Reb. Simple oversight on my part. Will get to it this evening. No problem! MAy I ask you something? On sunny-side-up, I NEVER see hatchlings in the egg section.... how did you do it so it auto-moves them when they hatch? An API function to check if it is an egg or not of course but how does it check each and every dragon code? I'm so confused but I'd really like to do that Share this post Link to post
Posted July 2, 2010 (edited) Can anyone help me out with a Cron job script please? I can't seem to figure the one that Ryu gave me.... it just won't work. I want to be able to sort the hatchlings and eggs and er dragons into their appropriate spots like SSUHatchery and Silvis lair... help please Edited July 2, 2010 by Rebsingh Share this post Link to post
Posted July 2, 2010 Thats rather simple The easiest way is to have all dragons in the same table, you only save if its an egg or an hatchling and the hoursleft-value as a timestamp (time of death). Then you run every hour a cronjob which performes a massview-request on every dragon which would die within the next 4 days. Either the egg has hatched (then you mark it as hatchling), it has grown up/is fogged/dead (then you remove it) or nothing has changed then you know it's an ER. Share this post Link to post
Posted July 7, 2010 Thats rather simple The easiest way is to have all dragons in the same table, you only save if its an egg or an hatchling and the hoursleft-value as a timestamp (time of death). Then you run every hour a cronjob which performes a massview-request on every dragon which would die within the next 4 days. Either the egg has hatched (then you mark it as hatchling), it has grown up/is fogged/dead (then you remove it) or nothing has changed then you know it's an ER. Thanks for the input, but just a bit confusing :S Share this post Link to post
Posted October 6, 2010 Can anyone help me with something? I'm using a code but it isn't entering the codes into the database. It SAYS they are entered but there is nothing there. Please PM me if you can help and I will send you the code to look at. Thanks Share this post Link to post
Posted October 6, 2010 Hello, did you set your mysql info and add the correct queries so when it submits it actually adds? If you want you can PM me your whole script and I can take a look at what is wrong.. Share this post Link to post
Posted October 9, 2010 (edited) So I have everything working... but it seems only I can add scrolls.... when someone else tries to add theirs it isn't working for them. What could be the problem?? EDIT -- Nevermind (: It's working... Edited October 9, 2010 by SilverDragonTears Share this post Link to post
Posted October 10, 2010 Issue after issue. Can someone tell me what I'm suppose to put in to run a cron job to clean the hatcheries? Share this post Link to post
Posted October 10, 2010 (edited) Fetch all dragons from the database which might be under 4 days (Do not fetch all. Realy. Dont.) and use the massview-action of the API to fetch those dragons. But why explaining when a script could say more than a thousand words? This is a fully functional cleanscript. If you understand what it's doing you may use it: http://pastebin.com/jDcqTjY3 EDIT: UPDATED SCRIPT, OLD ONE WAS INCOMPLETE! Edited October 10, 2010 by Ext3h Share this post Link to post
Posted October 10, 2010 Fetch all dragons from the database which might be under 4 days (Do not fetch all. Realy. Dont.) and use the massview-action of the API to fetch those dragons. But why explaining when a script could say more than a thousand words? This is a fully functional cleanscript. If you understand what it's doing you may use it: http://pastebin.com/jDcqTjY3 EDIT: UPDATED SCRIPT, OLD ONE WAS INCOMPLETE! thank you so much for this and i get the script. i'm new to cron so i'm not so sure what to put into the command line. Share this post Link to post
Recommended Posts