Jump to content

[SOLVED] Can someone tell me what is wrong with my code - its killing me!


ondi

Recommended Posts

I get these two errors with the following code - can anyone help? Thanks

 

 

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/fhlinux222/w/****/user/htdocs/stats/lastmatch.php on line 2

 

Parse error: syntax error, unexpected T_STRING in /home/fhlinux222/w/****/user/htdocs/stats/lastmatch.php on line 2

 

<?php
$host = '****';
$user = '****';
$password = '****;
$txt_db_name = '****';
$connection = mysql_connect("$host","$user","$password")
or die(mysql_error());
mysql_select_db("$txt_db_name",$connection)
or die(mysql_error()); 

range = 3; //how many games

$get_matches = mysql_query("
SELECT
M.MatchOpponent AS opp,
M.MatchPlaceID AS place,
MT.MatchTypeName AS type,
DATE_FORMAT(M.MatchDateTime, '%W %d %b') AS time,
DATE_FORMAT(M.MatchDateTime, '%H %i') AS clock
FROM tplss_matches M, tplss_matchtypes MT
WHERE MatchDateTime > CURRENT_TIMESTAMP AND
MT.MatchTypeID = M.MatchTypeID
ORDER BY M.MatchDateTime
LIMIT $range
", $connection)
or die(mysql_error());

while($data = mysql_fetch_array($get_matches))
{
//Check if it's home or away game
if($data['place'] == 1)
{
echo"
$data[time]<br>
$data[type]<br>
v $data[opp]<br>
HOME<br>
Kickoff $data[clock]<br><br>
";
}
elseif($data['place'] == 2)
{
echo"
$data[time]<br>
$data[type]<br>
v $data[opp]<br>
AWAY<br>
Kickoff $data[clock]<br><br>
";

}
}
?>

forgot a " ' "

<?php
$host = '****';
$user = '****';
$password = '****';
$txt_db_name = '****';
$connection = mysql_connect("$host","$user","$password")
or die(mysql_error());
mysql_select_db("$txt_db_name",$connection)
or die(mysql_error()); 

$range = 3; //how many games

$get_matches = mysql_query("
SELECT
M.MatchOpponent AS opp,
M.MatchPlaceID AS place,
MT.MatchTypeName AS type,
DATE_FORMAT(M.MatchDateTime, '%W %d %b') AS time,
DATE_FORMAT(M.MatchDateTime, '%H %i') AS clock
FROM tplss_matches M, tplss_matchtypes MT
WHERE MatchDateTime > CURRENT_TIMESTAMP AND
MT.MatchTypeID = M.MatchTypeID
ORDER BY M.MatchDateTime
LIMIT $range
", $connection)
or die(mysql_error());

while($data = mysql_fetch_array($get_matches))
{
//Check if it's home or away game
if($data['place'] == 1)
{
echo"
$data[time]<br>
$data[type]<br>
v $data[opp]<br>
HOME<br>
Kickoff $data[clock]<br><br>
";
}
elseif($data['place'] == 2)
{
echo"
$data[time]<br>
$data[type]<br>
v $data[opp]<br>
AWAY<br>
Kickoff $data[clock]<br><br>
";

}
}
?>

2nd go at the same code

Modified it (cleaned up some things, and made it so you have less code)

<?php
$host = '****';
$user = '****';
$password = '****';
$txt_db_name = '****';
$connection = mysql_connect("$host","$user","$password")
or die(mysql_error());
mysql_select_db("$txt_db_name",$connection)
or die(mysql_error()); 

$range = 3; //how many games

$get_matches = mysql_query("
SELECT
M.MatchOpponent AS opp,
M.MatchPlaceID AS place,
MT.MatchTypeName AS type,
DATE_FORMAT(M.MatchDateTime, '%W %d %b') AS time,
DATE_FORMAT(M.MatchDateTime, '%H %i') AS clock
FROM tplss_matches M, tplss_matchtypes MT
WHERE MatchDateTime > CURRENT_TIMESTAMP AND
MT.MatchTypeID = M.MatchTypeID
ORDER BY M.MatchDateTime
LIMIT $range;")
or die(mysql_error());

while($data = mysql_fetch_array($get_matches))
{
$time = $data['time'];
$type = $data['type'];
$opp = $datap['opp'];
$clock = $data['clock'];
//Check if it's home or away game
if($data['place'] == 1)
{
$loc = "HOME";
}
elseif($data['place'] == 2)
{
$loc = "AWAY";
}
echo <<<END
$time<br>
$type<br>
v $opp<br>
$loc<br>
Kickoff $clock<br><br>
END;
}
?>

I opened up a new notepad file and then copied everything into it, without any formatting.

 

Got rid of my errors but now i just get a blank page! I reckon thats more a problem with what i've written rather than the php itself.

 

Thanks for all your help! :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.