Hi new user here and i've been browsing this forum about a week now,still new to php(learn about 3 weeks).I use 'search' function to find my related problem but couldnt find one so i decided to create a thread and hopefully i create in correct section.
Now,my problem is the chessboard I want to create couldnt display the pieces image(king,queen,horse etc) and I receive this error: "Notice: Undefined variable: square in C:\Apache2\Apache2\htdocs\PHPCHESS\drawboard.php on line 9"
not only line 9 but also line 22,26,30,34,38...etc basically the images of the chessboard pieces.
I already enabling "php_gd2.dll" to display images of gif.
Try to solve the problem and even google'ed with no luck,its been eating inside me for a week now.Any help to find cause of the error would be really appreciated,cheers.
<?php
include("constants.php");
// open connection to the server and selects the database
$link_id = mysql_connect("localhost",$username, $password);
mysql_select_db($dbase, $link_id);
// Create The Query And Specify the name of database to run query on
$query = "select * from chessboard where 'square = $square'";
$result = mysql_query($query);
if ($result){
$numOfRows = mysql_num_rows ($result);
for ($i = 0; $i < $numOfRows; $i++){
$piece = mysql_result ($result, $i, "piece");
}
if ($piece == "wr"){
echo "<img src=\"images/wr.gif\">";
}
if ($piece == "wn"){
echo "<img src=\"images/wn.gif\">";
}
if ($piece == "wb"){
echo "<img src=\"images/wb.gif\">";
}
if ($piece == "wq"){
echo "<img src=\"images/wq.gif\">";
}
if ($piece == "wk"){
echo "<img src=\"images/wk.gif\">";
}
if ($piece == "wp"){
echo "<img src=\"images/wp.gif\">";
}
if ($piece == ""){
echo "<img src=\"images/blank.gif\">";
}
if ($piece == "br"){
echo "<img src=\"images/br.gif\">";
}
if ($piece == "bn"){
echo "<img src=\"images/bn.gif\">";
}
if ($piece == "bb"){
echo "<img src=\"images/bb.gif\">";
}
if ($piece == "bq"){
echo "<img src=\"images/bq.gif\">";
}
if ($piece == "bk"){
echo "<img src=\"images/bk.gif\">";
}
if ($piece == "bp"){
echo "<img src=\"images/bp.gif\">";
}
else{
echo mysql_errno().": ".mysql_error()."<BR>";
}
}
?>