On 11 April 2011 20:28, Ethan Rosenberg <eth...@earthlink.net> wrote: > Dear list - > > I an writing a script that will simulate a chess board. On a move from e2 > to e6 [see below] the variable in e2 is never assigned to e6. Here are some > code snippets: > > <?php > session_start(); > session_name("Chess"); > error_reporting(1); > if ($_SESSION['flag'] != 1) > { > $flag = 1; > echo "<br />starting<br />"; > $results = array(array("Br", "Bn", "Bb", "Bq", "Bk", "Bb", "Bn", > "Br"),array("Bp", "Bp", "Bp", "Bp", "Bp", "Bp", "Bp", "Bp"), > array("", "", "", "", "", "", "", ""),array("", "", > "", "", "", "", "", ""),array("", "", "", "", "", "", "", ""), > array("", "", "", "", "", "", "", ""),array("Wp", > "Wp", "Wp", "Wp", "Wp", "Wp", "Wp", "Wp"), > array("Wr", "Wn", "Wb", "Wq", "Wk", "Wb", "Wn", > "Wr")); > > $_SESSION['results'] = $results; > for($i = 0; $i <8; $i++) > { > for ($j = 0; $j < 8; $j++) > printf("%s ", $results[$i][$j]); > printf("<br />"); > } > > $_SESSION[flag] = $flag; > > <snip> > > $board = array //Correlation of input array [chessboard] with internal > array [results] > ( > "a8" => $results[0][0], > "b8" => $results[0][1], > "c8" => $results[0][2], > "d8" => $results[0][3], > "e8" => $results[0][4], > "f8" => $results[0][5], > "g8" => $results[0][6], > "h8" => $results[0][7], > "a7" => $results[1][0], > "b7" => $results[1][1], > "c7" => $results[1][2], > "d7" => $results[1][3], > "e7" => $results[1][4], > "f7" => $results[1][5], > "g7" => $results[1][6], > "h7" => $results[1][7], > "a6" => $results[2][0], > "b6" => $results[2][1], > "c6" => $results[2][2], > "d6" => $results[2][3], > "e6" => $results[2][4], > "f6" => $results[2][5], > "g6" => $results[2][6], > "h6" => $results[2][7], > "a5" => $results[3][0], > "b5" => $results[3][1], > "c5" => $results[3][2], > "d5" => $results[3][3], > "e5" => $results[3][4], > "f5" => $results[3][5], > "g5" => $results[3][6], > "h5" => $results[3][7], > "a4" => $results[4][0], > "b4" => $results[4][1], > "c4" => $results[4][2], > "d4" => $results[4][3], > "e4" => $results[4][4], > "f4" => $results[4][5], > "g4" => $results[4][6], > "h4" => $results[4][7], > "a3" => $results[5][0], > "b3" => $results[5][1], > "c3" => $results[5][2], > "d3" => $results[5][3], > "e3" => $results[5][4], > "f3" => $results[5][5], > "g3" => $results[5][6], > "h3" => $results[5][7], > "a2" => $results[6][0], > "b2" => $results[6][1], > "c2" => $results[6][2], > "d2" => $results[6][3], > "e2" => $results[6][4], > "f2" => $results[6][5], > "g2" => $results[6][6], > "h2" => $results[6][7], > "a1" => $results[7][0], > "b1" => $results[7][1], > "c1" => $results[7][2], > "d1" => $results[7][3], > "e1" => $results[7][4], > "f1" => $results[7][5], > "g1" => $results[7][6], > "h1" => $results[7][7], > ); > > > $board2 = array //Correlation of input array [chessboard] with internal > array [results] > ( > "a8" => "[0][0]", > "b8" => "[0][1]", > "c8" => "[0][2]", > "d8" => "[0][3]", > "e8" => "[0][4]", > "f8" => "[0][5]", > "g8" => "[0][6]", > "h8" => "[0][7]", > "a7" => "[1][0]", > "b7" => "[1][1]", > "c7" => "[1][2]", > "d7" => "[1][3]", > "e7" => "[1][4]", > "f7" => "[1][5]", > "g7" => "[1][6]", > "h7" => "[1][7]", > "a6" => "[2][0]", > "b6" => "[2][1]", > "c6" => "[2][2]", > "d6" => "[2][3]", > "e6" => "[2][4]", > "f6" => "[2][5]", > "g6" => "[2][6]", > "h6" => "[2][7]", > "a5" => "[3][0]", > "b5" => "[3][1]", > "c5" => "[3][2]", > "d5" => "[3][3]", > "e5" => "[3][4]", > "f5" => "[3][5]", > "g5" => "[3][6]", > "h5" => "[3][7]", > "a4" => "[4][0]", > "b4" => "[4][1]", > "c4" => "[4][2]", > "d4" => "[4][3]", > "e4" => "[4][4]", > "f4" => "[4][5]", > "g4" => "[4][6]", > "h4" => "[4][7]", > "a3" => "[5][0]", > "b3" => "[5][1]", > "c3" => "[5][2]", > "d3" => "[5][3]", > "e3" => "[5][4]", > "f3" => "[5][5]", > "g3" => "[5][6]", > "h3" => "[5][7]", > "a2" => "[6][0]", > "b2" => "[6][1]", > "c2" => "[6][2]", > "d2" => "[6][3]", > "e2" => "[6][4]", > "f2" => "[6][5]", > "g2" => "[6][6]", > "h2" => "[6][7]", > "a1" => "[7][0]", > "b1" => "[7][1]", > "c1" => "[7][2]", > "d1" => "[7][3]", > "e1" => "[7][4]", > "f1" => "[7][5]", > "g1" => "[7][6]", > "h1" => "[7][7]", > ); > $results = $_SESSION['results']; > > $a = "$"; > $a .="results"; > $a .= "$board2[$value_from]"; > > $b = "$"; > $b .="results"; > $b .= "$board2[$value_to]"; > > $bb = $board[$value_to]; > $aa = $board[$value_from]; > > $b = $aa; > $a = ''; > ======== > I am not able to assign the value Wp to $b which is $results[2][4]. $a, > which is $results[6][4] should be empty. > > Help and advice, please. > > Ethan > > MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)] > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
You are suppressing errors (at least based upon the code you've supplied). Change ... error_reporting(1); // Will only report E_ERROR - Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted. to error_reporting(-1); // Shows everything. The code you've supplied is missing the values for the $value_from and $value_to.