Page 1 of 1

Im having some problems. Help please :)

Posted: Thu Sep 04, 2003 7:53 pm
by Dane
Hello, Im having some problems with my code.

http://www.clanef.co.uk/caliber/index.php?cmd=results2

It isnt reading from MySQL.


<?
/* ====================
Online Gaming Website Engine
PHP and MySQL Driven
Website Design and Code By
Dane Marshall
http://www.clanef.co.uk
==================== */
?>
<table width="589" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="bg.jpg"><table width="700" border="0" cellpadding="2" cellspacing="2">
<!--DWLayoutTable-->
<tbody>
<tr align="center">
<td height="23" colspan="6" class="row1"><strong>Caliber Match Overview</strong></td>
</tr>
<tr class="comhead">
<td width="110" height="23" valign="top"><strong>Date :</strong></td>
<td width="120" align="center" valign="top"><div align="left"><strong>Opponent :</strong></div></td>
<td width="117" align="center" valign="top"><div align="left"><strong>Outcome :</strong></div></td>
<td width="113" align="center" valign="top"><div align="left"><strong>Map 1 :</strong></div></td>
<td width="114" valign="top"><strong>Map 2 :</strong></td>
<td width="88"><strong>Map 3 :</strong></td>
</tr>
<?
include('settings.php');

$query = "SELECT * FROM caliber_matches ORDER BY 'id' ASC";
$query = stripslashes($query);

$result = mysql_query ($query)
or die (mysql_error());

$taAdv_colors1 = array("#E6E6E6","#CCCCCC");
$taAdv_k1 = 0;
$taAdv_m1 = 0;
$taAdv_change_every1 = 1;


$date = $row["date"];
$opponent = $row["opponent"];
$result2 = $row["result"];
$date = $row["date"];
$map1 = $row["map1"];
$map2 = $row["map2"];
$map3 = $row["map3"];

while ($row = mysql_fetch_array($result)){

?>
<tr bgcolor="<?
if($taAdv_m1%$taAdv_change_every1==0 && $taAdv_m1>0){
$taAdv_k1++;
}
print $taAdv_colors1[$taAdv_k1%count($taAdv_colors1)];
$taAdv_m1++;
?>">
<td align="left" valign="top"><? echo("$date"); ?></td>
<td align="left" valign="top"><? echo("$opponent"); ?></td>
<td align="left" valign="top"><? echo("$result2"); ?></td>
<td align="left" valign="top"><? echo("$map1"); ?></td>
<td align="left" valign="top"><? echo("$map2"); ?></td>
<td align="left" valign="top"><? echo("$map3"); ?></td>
</tr>
</tbody>
</table></td>
</tr>
<?
}
?>
</table>

Posted: Thu Sep 04, 2003 8:09 pm
by volka
replace
$date = $row["date"];
$opponent = $row["opponent"];
$result2 = $row["result"];
$date = $row["date"];
$map1 = $row["map1"];
$map2 = $row["map2"];
$map3 = $row["map3"];

while ($row = mysql_fetch_array($result)){

?>
by

Code: Select all

while ($row = mysql_fetch_array($result)){
	$date = $row["date"];
	$opponent = $row["opponent"];
	$result2 = $row["result"];
	$date = $row["date"];
	$map1 = $row["map1"];
	$map2 = $row["map2"];
	$map3 = $row["map3"];
?>
and try again.
Your code assigns $date, $opponent, $result2, $date, $map1, $map2 and $map3 only once - even before $row is set anyway.
php will generate a warning and set the variables to FALSE, echo will output nothing for FALSE

Posted: Thu Sep 04, 2003 8:13 pm
by Dane
Ah yes, that has worked. Thanks a lot. But there is 1 more slight problem.

http://www.clanef.co.uk/caliber/index.php?cmd=results2

Any ideas.

Thanks again

Dane

Posted: Thu Sep 04, 2003 9:04 pm
by volka
I'm not quite sure it will fix it but try:
replace
<td align="left" valign="top"><? echo("$map3"); ?></td>
</tr>
</tbody>
</table></td>
</tr>
by

Code: Select all

<td align="left" valign="top"><? echo("$map3"); ?></td>
</tr>

Posted: Thu Sep 04, 2003 9:18 pm
by Dane
:D your getting closer mate.

http://www.clanef.co.uk/caliber/index.php?cmd=results2

Really thanks for the help.

Dane

Posted: Thu Sep 04, 2003 9:20 pm
by Dane
<?
/* ====================
Online Gaming Website Engine
PHP and MySQL Driven
Website Design and Code By
Dane Marshall
http://www.clanef.co.uk
==================== */
?>
<table width="589" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="bg.jpg"><table width="700" border="0" cellpadding="2" cellspacing="2">
<!--DWLayoutTable-->
<tbody>
<tr align="center">
<td height="23" colspan="6" class="row1"><strong>Caliber Match Overview</strong></td>
</tr>
<tr class="comhead">
<td width="110" height="23" valign="top"><strong>Date :</strong></td>
<td width="120" align="center" valign="top"><div align="left"><strong>Opponent :</strong></div></td>
<td width="117" align="center" valign="top"><div align="left"><strong>Outcome :</strong></div></td>
<td width="113" align="center" valign="top"><div align="left"><strong>Map 1 :</strong></div></td>
<td width="114" valign="top"><strong>Map 2 :</strong></td>
<td width="88"><strong>Map 3 :</strong></td>
</tr>
<?
include('settings.php');

$query = "SELECT * FROM caliber_matches ORDER BY 'id' ASC";
$query = stripslashes($query);

$result = mysql_query ($query)
or die (mysql_error());

$taAdv_colors1 = array("#E6E6E6","#CCCCCC");
$taAdv_k1 = 0;
$taAdv_m1 = 0;
$taAdv_change_every1 = 1;


while ($row = mysql_fetch_array($result)){
$date = $row["date"];
$opponent = $row["opponent"];
$result2 = $row["result"];
$date = $row["date"];
$map1 = $row["map1"];
$map2 = $row["map2"];
$map3 = $row["map3"];

?>
<tr bgcolor="<?
if($taAdv_m1%$taAdv_change_every1==0 && $taAdv_m1>0){
$taAdv_k1++;
}
print $taAdv_colors1[$taAdv_k1%count($taAdv_colors1)];
$taAdv_m1++;
?>">
<td align="left" valign="top"><? echo("$date"); ?></td>
<td align="left" valign="top"><? echo("$opponent"); ?></td>
<td align="left" valign="top"><? echo("$result2"); ?></td>
<td align="left" valign="top"><? echo("$map1"); ?></td>
<td align="left" valign="top"><? echo("$map2"); ?></td>
<td align="left" valign="top"><? echo("$map3"); ?></td>
</tr>
<?
}
?>
</table>
The New Code

Posted: Thu Sep 04, 2003 9:50 pm
by volka
yes, there's something wrong with the table structure but that's outside the code snippet you've posted.
I've missed a <tbody> in the snippet, just remove it.

As far as I can see the code after the last line of your last code here should be

Code: Select all

</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr bgcolor="#000000"> 
			<td height="29" width="772" colspan="8"valign="top" >
				<img src="http://www.clanef.co.uk/caliber/imgs/title1.jpg" width="772" height="29">
			</td>
		</tr>
	</table>
</div>
</body>
</html>
But make a backup of the current version before trying.

take a look at http://tidy.sourceforge.net/ and use that program to test your pages (i.e. the output , just save the page in your browser and use it as input for tidy)

or use http://validator.w3.org/

Posted: Fri Sep 05, 2003 5:01 am
by Dane
Ive got it working now. That last bit of code needed to be in with some modifcations. Thanks a lot fo your help and time.

Dane