Jump to content

Glen

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by Glen

  1. Hi, I read up on cURL and inserted it into my code. It worked like a dream. Thanks for your help. best regards, Glen
  2. Hi, That would explain the problem I am having. I think I may be going off topic but is there any special way I should have the cron job set up or is there a work around I could use? Thanks. Best regards, Glen
  3. Hi everyone, I have a problem relating to using the header() function and cron jobs. What it is I play an online game and I am making a tool for it. The game I play has an ingame mailing system and you can use a url to send messages from outside the game. What this tool does is it send mails after passing a certain date. It does it by using the header() and forwarding to the url (the page which is owned by the game) that sends the message. So I use a cron job to constantly check and see if the date has been passed and if it has then send the message but the problem I am experiencing is that in the mails that I get from the cron output it just shows a hyperlink and then I see that no message has been sent. So my question is it possible to use cron jobs and header("Location: "); together? Thanks. Best regards, Glen
  4. This should work I think: <?php session_start(); echo '<form action = "" method = "POST"'; echo'<select name="dropdown"> <option value="store" >Option 1</option> <option value="values" >Option 2</option> <option value="here" >Option 3</option> </select>'; echo '<input type = "submit" name = "submit" value = "Get Value!" </form>'; if(isset($_POST['submit'])) { $value = $_POST['dropdown']; $_SESSION['value'] = $value; echo $_SESSION['value']; } ?> To value is stored in $_SESSION['value'] to call the value in another page remember to use session_start(); at the very top. -Glen
  5. That's the game, working perfectly. Thank You. -Glen
  6. <?php $Name = $_POST["Name"]; $Email = $_POST["Email"]; $Month = $_POST["Month"]; $Day = $_POST["Day"]; $YYYY = $_POST["YYYY"]; $Comment = $_POST["Comment"]; $message = "The name is:$Name <br> The Email adress is: $Email<br> THE D.O.B is:$Day/$Month/$YYYY <br> The Comment is $comment"; mail( "support@ludemanndistributors.net", "Feedback Form Results", $message, "From: $Email" ); ?> Try that.
  7. They are saying $message variable is empty I think you may have missed $message = $_POST['message'];
  8. No that is not what I want. I don't think I have explained it properly. So if I have a target time 18/12/2009 23:00:00 and I have today's time 24/10/09 21:55:00 I want to now how many hours:mins:sec there is in difference. -Glen
  9. Hi everyone, PHP times and date are not my strongest part of php Now I am making a countdown script I know though it want be live though I am not worried about that right now. <?php //view attack page //set the username $user = $_SESSION['username']; //connect to database include("connect_attackplanner.php"); //Query the database $result = mysql_query("SELECT * FROM `" . $user . "_attacks`"); $num_rows = mysql_num_rows($result); //Display message if you have no attacks cheduled if($num_rows == 0) { die ("You have no attacks planned!"); } //start table echo "<table class = \"box\"><tr> <th>Enemy Village</th> <th>Attacking Coords</th> <th>Launch Time</th> <th>Arrival Time</th> <th>Unit</th><th>Countdown to Attack</th></tr>"; //get results while($row = mysql_fetch_array($result)) { $enemycoords = $row['target_village']; $attackcoords = $row['attacking_village']; $launchtime = date("d/m/Y H:i:s",$row['launch_time']); $arrivaltime = date("d/m/Y H:i:s",$row['land_time']); $arrivaltime1 = $row['land_time']; $unit = $row['unit']; echo " <tr><td>$enemycoords</td> <td>$attackcoords</td> <td>$launchtime</td> <td>$arrivaltime</td> <td>$unit</td>"; //create countdown script $today = time () ; $difference =($arrivaltime1-$today) ; //the rest of the code goes in here } //finish table echo "</table>" ?> I need to convert $difference into hh:mm:ss though I have no idea how to go about it. I know that things will have to be multiplied and that date() does not work. If you have any idea's aswell as explaining the code as I need to expand my PHP date/time knowledge Many Thanks -Glen
  10. Hi Keith, That's it it seems to be working correctly now. You're help has been very much appreciated. Thanks again. -Glen
  11. Hi Keith, $unit will be a range from 9 to 35 depending on what the user selects on the previous stage. $distance was the distance between the two villages and is worked out using Pythagoras to give you a decimal value. So say the two villages were 4 fields apart(One from the array and the one selected as enemy coords) and the unit I select travels a 1 field every 9 mins. So $distanceunit would be 4 * 9 = 36mins. Though most of the time it can end as a floating point(I am not sure that is the correct term). An example would be 4.5632657 fields apart. So Say I want to coordinate a strike and I set an arrival time 18/10/09 23:00:00 it would be 18/10/09 23:00:00 minus 36 mins = 18/10/09 22:24:00 and that's when I launch the attack so that it lands at that time. So I want to find launch time from each village in the array to the enemy coord as to do in my head it would take me hours. I use the function to display the duration in hh:mm:ss to the user. Many Thanks -Glen
  12. Thanks keith, still no success yet. Here is the current code... if($stage == 2) { //create form echo '<form action="index.php" method="get"> <input type="hidden" name="page" value="plan_attack" /> <input type="hidden" name="stage" value="3" /> '; //get enemy coords $enemycoords = $_GET['ec']; //get arrival time $arrivaltime = $_GET['arrivaltime']; //get arrival date $arrivaldate = $_GET['arrivaldate']; $groupid = $_GET['groupid']; //get unit $unit = $_GET['unit']; //Display target information echo "Target: $enemycoords<br> Arrival: $arrivaldate $arrivaltime<br>"; //set the user session $user = $_SESSION['username']; //connect to database include("connect_attackplanner.php"); //Select the group name form the database where the id = the drop down id $query = "SELECT * FROM `" . $user . "_group` where id = '$groupid'"; $result = mysql_query($query) or die(mysql_error()); //declare the function that works out the time distance function int2time($time) { $h=floor($time); $m=floor(($time*60)%60); $s=floor(($time*60*60)%60); return sprintf("%02d:%02d:%02d",$h,$m,$s); } //set the varibales $row = mysql_fetch_array($result); $name = $row['group_name']; $villages = $row['villages']; //explode the villages $villages1 = explode(";", $villages); echo '<table border = "1"> <tr><th>Attack From</th><th>Unit</th><th>Distance Unit</th><th>Duration</th><th>Launch at</th><th>EnemyCoords</th></tr>'; //find out the arrival time of each village in the group foreach($villages1 as $attackcoords) { echo "<tr><td>$attackcoords</td><td>$unit</td>"; $ax = substr($attackcoords,0,3); $ay = substr($attackcoords,4,3); $ex = substr($enemycoords,0,3); $ey = substr($enemycoords,4,3); $distance = sqrt((($ex - $ax)*($ex - $ax)) + (($ey - $ay)*($ey - $ay))); $distanceunit = $unit * $distance; echo "<td>$distanceunit</td>"; $Ts = explode('/',"$arrivaldate/$arrivaltime"); $arrival = mktime($Ts[3],$Ts[4],$Ts[5],$Ts[0],$Ts[1],$Ts[2]); //get duration timestamp $duration = int2time($distanceunit/60); $Ts1 = explode(":",$duration); $duration1 = mktime($Ts1[0],$Ts1[1],$Ts1[2]); echo "<td>$duration</td>"; //take duration away from arrival $newtime = $arrival - $duration1; //display launchtime $finaltime = date("d/m/Y H:i:s",$newtime); echo "<td>$finaltime</td><td>$enemycoords</td></tr>"; } echo "</table>"; echo "</form>"; } Many Thanks -Glen
  13. Sorry the arrival time format is hh:mm:ss, my bad. So would you recommend I use dd/mm/yy instead of mm/dd/yy? Many Thanks -Glen
  14. You get a google search engine that displays the result on your site when you sign up for google adsense. I think you may be referring to this.
  15. Hi cags, Thanks for the reply. Yeah it does only select one item so I removed the while loop, force of habit The contents of $attackcoords is xxx|yyy. So an example would be 123|453. Hi keith, I changed the value in the database and it now does not contain a ; and a space, just a ;. Though it never gave me the results I wanted. Having played about even more I have noticed that I the date I insert in the previous stage to carry on to this stage changes the launch time result dramatically. I am inserting the time as hh/mm/ss and inserting the date as mm/dd/yy Does that change anything? Many Thanks -Glen
  16. Hi Everyone, I am having problems with this php script. I have a script that gets a list of villages from a mysql database and all the villages are stored in the one field and separated with a semi-colon. When I export the village list depending on the group the user selects the villages are exploded and a launch time is found out. /////////////////////////////////////// //New stage /////////////////////////////////////// if($stage == 2) { //create form echo '<form action="index.php" method="get"> <input type="hidden" name="page" value="plan_attack" /> <input type="hidden" name="stage" value="3" /> '; //get enemy coords $enemycoords = $_GET['ec']; //get arrival time $arrivaltime = $_GET['arrivaltime']; //get arrival date $arrivaldate = $_GET['arrivaldate']; $groupid = $_GET['groupid']; //get unit $unit = $_GET['unit']; //Display target information echo "Target: $enemycoords<br> Arrival: $arrivaldate $arrivaltime<br>"; //set the user session $user = $_SESSION['username']; //connect to database include("connect_attackplanner.php"); //Select the group name form the database where the id = the drop down id $query = "SELECT * FROM `" . $user . "_group` where id = '$groupid'"; $result = mysql_query($query) or die(mysql_error()); //declare the function that works out the time distance function int2time($time) { $h=floor($time); $m=floor(($time*60)%60); $s=floor(($time*60*60)%60); return sprintf("%02d:%02d:%02d",$h,$m,$s); } //set the varibales while($row = mysql_fetch_array($result)) { $name = $row['group_name']; $villages = $row['villages']; //explode the villages $villages1 = explode(";", $villages); echo '<table border = "1"> <tr><th>Attack From</th><th>Unit</th><th>Distance Unit</th><th>Duration</th><th>Launch at</th><th>EnemyCoords</th></tr>'; } //find out the arrival time of each village in the group foreach($villages1 as $attackcoords) { echo "<tr><td>$attackcoords</td><td>$unit</td>"; $ax = substr($attackcoords,0,3); $ay = substr($attackcoords,4,3); $ex = substr($enemycoords,0,3); $ey = substr($enemycoords,4,3); $distance = sqrt((($ex - $ax)*($ex - $ax)) + (($ey - $ay)*($ey - $ay))); $distanceunit = $unit * $distance; echo "<td>$distanceunit</td>"; //convert date to timestamp $arrivaldate1 = strtotime($arrivaldate); //convert arrival time to timestamp $arrivaltime1 = strtotime($arrivaltime); //add them together to get arrival date timestamp $arrival = $arrivaltime1 + $arrivaldate1; //get duration timestamp $duration = int2time($distanceunit/60); $duartion1 = strtotime($duration); echo "<td>$duration1</td>"; //take duration away from arrival $newtime = $arrival - $duration1; //display launchtime $finaltime = date("m/d/y H:i:s",$newtime); echo "<td>$finaltime</td><td>$enemycoords</td></tr>"; } echo "</table>"; echo "</form>"; } Problems with the script are: 1)So the first village in the array gives me the correct launch time but after that it seems to display the wrong launch time for the rest of the villages. 2)The launch times now display that the attacks should be launched in the year 1913 which is wrong as some villages are only like 100 hours apart not 100 years 3)$duration1 seems to be empty as nothing is displayed when I echo it out. I think if this problem is fixed then problem #2 will be fixed aswell. I don't know if I explained that well Anyway if you know what's up help would be very much appreciated Many Thanks -Glen
  17. No, that is the number of villages the player has. Sorry for not making that clear.
  18. Hello again , I was wondering if it was possible to get results from my results i get from mysql output. For example my script returns the player id's of a certain clan i play in, in a game called tribalwars. Tribalwars offers you the chance to download data to make external sites, statistics ect. I have downloaded all the villages, players and clans world data in to a mysql database. And i am trying to find all the villages belong to a certain clan. There is not a file to download that gives you all the villages of a clan so i will have to make it. It will have to work like this, Each village, player and clan has its own id. So i will have to find all the players in a clan and find all the villages belonging to all those players in that clan, but i am not sure how i would go about that. <?php set_time_limit(300); //Connect to Mysql $dbhost = ''; $dbuser = ''; $dbpass = ''; mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); //Select Database $dbname = ''; mysql_select_db($dbname) or die('Error selecting database'); //Select table $query="SELECT * FROM players WHERE ally = '2463'"; $result=mysql_query($query); //Find the number of rows $num_rows = mysql_num_rows($result) or die(mysql_error()); //Loop $i=0; while ($i < $num_rows) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $ally=mysql_result($result,$i,"ally"); $villages=mysql_result($result,$i,"villages"); $points=mysql_result($result,$i,"points"); $rank=mysql_result($result,$i,"rank"); echo "<br>ID: $id<br>"; $i++; } mysql_close(); ?> This current code displays all the player id's of this clan how can i use those id's to find all of thier villages. Thanks for your time -Glen
  19. Thanks for the quick response guys. Thats it problem solved guys. Thanks a million Best Regards -Glen
  20. Hello all, I am recieving this error and i dont know how to overcome this situation. I am trying to download data given out by a game website i play. Tribalwars. set_time_limit(300); $dbhost = 'Hidden'; $dbuser = 'Hidden'; $dbpass = 'Hidden'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'tribalwars'; mysql_select_db($dbname) or die('Error selecting database'); $lines = gzfile('http://en7.tribalwars.net/map/village.txt.gz'); if(!is_array($lines)) die("File could not be opened"); foreach($lines as $line) { list($id, $name,$x, $y, $player, $points, $rank) = explode(',', $line); $name = urldecode($name); $name = addslashes($name); $sql = "INSERT INTO village SET id='$id', name='$name', x='$x', y='$y', player='$player', points='$points', rank='$rank'"; mysql_query($sql); ?> I know this error is caused by haveing an open curly bracket but that is the code. The code is located here http://en7.tribalwars.net/help2.php?article=map_data Is there anywhere the curly bracket should go or is there a way to get round this? Thanks all Best Regards -Glen
×
×
  • 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.