need advise
Posted: Fri Feb 11, 2011 3:43 am
hi, i was working on a map system and it gives me an error on line 31 , i am no expert so i was hoping someone could help me find out whats the issue
Code: Select all
01 <?php
02 require_once ("data_class.php");
03
04
05
06 class World extends Data {
07
08 var $wx = 100; // max world width
09 var $wy = 100; // max world height
10
11 var $qx = 10; // quadrant X
12 var $qy = 10; // quadrant Y
13
14 var $radius = 10; // maybe we'll need this
15
16
17 function ShowMap() {
18
19 if (isset($_POST["q"]) && isset($_POST["Change"]) && $_POST["Change"] == 'Change' && !preg_match("/[^0-9]+/", $_POST["q"]) && $_POST["q"] != '')
20 {
21 $q = mysql_real_escape_string($_POST["q"]);
22 }
23
24 else {
25 $q = 1;
26 }
27
28 $sq = mysql_query("SELECT * FROM strongholds WHERE quadrant = $q");
29
30 $r = 1;
31 while ($r <= mysql_num_rows($sq)) {
32
33 $d[$r] = mysql_fetch_assoc($sq); // as $d = data of that row
34
35 $this->s[$d[$r][xcoo]][$d[$r][ycoo]][pid] = $d[$r][player_creatures_id];
36 $this->s[$d[$r][xcoo]][$d[$r][ycoo]][name] = $d[$r][name];
37
38
39 $r++;
40 }
41 //start of table layout and quadrant selection
42 echo "<table width='410' cellpading='0' celspacing='0' align='center' border='0' style='margin-top:20px;'>
43 <tr><td colspan='10'>
44 <form action='?p=world' method='POST'>
45 Current Region: <input type='text' value='$q' style='width:30px' maxlength='2' name='q' /><input type='submit' value='Change' name='Change' />
46 </form>
47 </td></tr>
48 <tr>";
49
50 $i = 1;
51 $xi = 1;
52 $yi = 1;
53 while ($i <= 100) {
54
55 //echo $this->s[$xi][$yi][pid];
56
57 if ($this->s[$xi][$yi][pid] == $_SESSION["id"]) {
58
59 echo "<td width='36' height='36' align='center' bgcolor='#339933' title='".$this->s[$xi][$yi][name]."'><img src='img/castle.gif' border='0'/></td>";
60
61 }
62
63 if ($this->s[$xi][$yi][pid] != $_SESSION["id"] && $this->s[$xi][$yi][pid] != '') {
64
65 echo "<td width='36' height='36' align='center' bgcolor='#339933' title='".$this->s[$xi][$yi][name]."'><img src='img/castle2.gif' border='0'/></td>";
66
67 }
68
69 else if ($this->s[$xi][$yi][pid] == ''){
70
71 echo "<td width='36' height='36' align='center' bgcolor='#339933' title='[ x:$xi, y:$yi ]'><font color='#000000'></font></td>";
72 }
73
74
75 if ($i % 10 == 0) {echo "</tr><tr>"; $yi = $yi + 1; $xi = $xi - 10;}
76
77 $i++;
78 $xi++;
79 }
80 // end of table layout
81 echo "</tr></table>";
82
83 }
84
85
86
87
88 }
89 ?>