Jump to content

Tjk

Members
  • Posts

    27
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Tjk's Achievements

Member

Member (2/5)

0

Reputation

  1. I wanted an opinion on this. I have created a text based game which requires multiple attributes to be used in the scripts. My question is whether or not it would be better just to pull all the data at the top of each page and store it in multi-dimensional arrays for example.... array(name of user array(data of user)) and then access this using array[user][data] or to use mysql queries throughout the script to select specific row data? Opinions appreciated
  2. Out of interest, if I load the script through my web browser should I see a blank page or should I get the error I'm getting which says "Warning: fopen(test.txt): failed to open stream: Permission denied"? Also, I tried it with CRON with no luck.
  3. Yeah. The code itself will work when embedded in HTML code but when trying to use CRON to load the pure PHP code itself to mail it to me it doesn't work.
  4. I've got CRON set up to run this file below every minute... (this is the entire contents of the file) [code=php:0] <?php $to= "myemail@emailprovider.com"; $subject= "cron test"; $message= "if you receive this cron is working!"; mail($to, $subject, $message); ?> [/code] Am I missing something about running PHP scripts using CRON or is it a server configuration problem? Help appreciated as always. -Tjk
  5. :) No it isn't. Basically if the $sum has the value 2.333333444445555 then the script will do something like add so much to another variable. But if the value is only 2 then it will do something like takeaway so much to this other variable. So far I've been unable to find a way of doing it. Thanks for any help you can give me.
  6. Is there a way of counting the number of numbers after the decimal point of a sum? For example... [code=php:0] <? $sum= 100/$a_number; //if $sum has so many numbers after a decimal point then do something else do something different ?> [/code] Help appreciated as always. :)
  7. I can't seem to find true inverse sine. I have tried asin and asinh and both give weird answers. Here's the code: [code] $opposite= 295; $hyp= 375.298547826; $sinx= $opposite/ $hyp; $x= asin($sinx); [/code] This gives me an answer of 1.10573218834 when it should give me an answer of ~51.813 Is there a setting in php.ini i need to change? The script is being run on a linux server and running the latest version of PHP. Any help is appreciated. -Tjk P.S: How do I use the php tags which colour the code. I haven't been able to find them. :) EDIT: I managed to solve my own problem. (For anyone with a similiar problem) the answer is that asin always returns in radians therefore you need to use rad2deg() to convert the angle into degrees.
  8. $campaign= "test";   $query= mysql_query("SELECT * from campaign INNER JOIN campaignd WHERE campaign.campaign='$campaign' campaignd.campaign='$campaign' ORDER BY minit LIMIT='1'")or die(mysql_error());   while($row= mysql_fetch_array($query)){     echo "<option value='".$row['commander']."'>". $row['commander']."</option>";   }    --------- Here I'm trying to select records from 2 tables- campaign and campaignd where the value of the row campaign is equal to the string stored in the variable of the name campaign, then ordering them by the row minit value (an integer) and setting the limit to 1 so it only selects the record with the highest value minit. It then echoes a select option with the value of the row commander. I can't seem to get it to do what I want. When i try loading the page i don't get any errors but instead just get an empty select box. Could anyone show me where I'm going wrong? regards -Tjk
  9. @ Crayon Violent: Earlier in the script the variable $battle is defined. Sorry, the original code I posted was a test script I set up to test if it was something wrong with my code. Everything is identical except in my example I used $var instead of $battle. $battle is definately set within the main script and ready to pass via the query string into the image creation script. I'm using a script called 'map.php' and through the img src I'm calling the script imagecreate2.php to generate the image. @joquius: I need the variable $battle to be set at all times so an else isn't really an option.
  10. I've added the header() function just above imagepng($im) and it doesn't work. Before I added the parameter into the query string for imagecreate2.php when I was just using a mysql statement with no WHERE condition everything was working fine and the map loaded. It was only when I added the parameter and to allow for the WHERE condition that it no longer works. Any ideas? Help appreciated as always.
  11. Sure. Here it is.... [taken from imagecreate2.php] [code] <?   $im= imagecreatefrompng('maptemp.png');      if(isset($_GET['battle'])){     $battle= $_GET['battle'];   }      mysql_connect("localhost", "user", "password")or die(mysql_error());   mysql_select_db("database");      $query= mysql_query("SELECT * from battles WHERE battle='$battle'")or die(mysql_error());   while($row= mysql_fetch_array($query)){     $unit= $row['unit'];     $unitx= $row['xcoord'];     $unity= $row['ycoord'];               $lcoordx= $unitx- 5;     $lcoordy= $unity - 5;        $rcoordx= $unitx + 5;     $rcoordy= $unity + 5;          $color= imagecolorallocate($im, 0xFF, 0xFF, 0xFF);       imagefilledrectangle($im, $lcoordx, $lcoordy, $rcoordx, $rcoordy, $color);   }   imagepng($im); ?> [/code]
  12. Code in main page... [code] <? $var= 1; ?> <form method="POST" action="map.php"> <input type="image" src="imagecreate2.php?var='$var'" height="300" width= "300" /> </form> [/code] Code in image create... [code]   if(isset($_GET['var'])){     $var= $_GET['var'];   }   mysql_query("SELECT * from table WHERE id='$var'") or die(mysql_error()); //does something to an image and outputs it using imagepng($img); [/code] The problem is that the image now doesn't load on the main page. Could anyone point out where I'm going wrong? Regards -Tjk
  13. Thanks for all your help Barand! **SOLVED**
  14. I managed to get that all working barand but here's my final problem in the myimage.php file... [code]   $im= imagecreatefrompng('maptemp.png');      mysql_connect("localhost", "user", "passwprd")or die(mysql_error());   mysql_select_db("simdoma_hermes");      $query= mysql_query("SELECT * from battles WHERE unit='1'")or die(mysql_error());   while($row= mysql_fetch_array($query)){     $unit= $row['unit'];     $unitx= $row['xcoord'];     $unity= $row['ycoord'];   }      $lcoordx= $unitx- 2;   $lcoordy= $unity + 2;      $rcoordx= $unitx + 2;   $rcoordy= $unity - 2;      $color= imagecolorallocate($im, 0xFF, 0xFF, 0xFF);     imagefilledrectangle($im, $lcoordx, $lcoordy, $rcoordx, $rcoordy, $color);      imagepng($im); [/code] I'm looking to take the coordinates of a unit from the DB then create a square 2 pixels each side of the unit's recorded coordinates in the database and draw a red rectangle on the map and then output it. When I try this the map outputs but there is no rectangle on it. Is it something wrong with my maths?
  15. That fixed it! Thanks Barand. One final question.. could I simply incorporate the code from myimage.php into my main page?
×
×
  • 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.