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>
";

}
}
?>

Link to comment
Share on other sites

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>
";

}
}
?>

Link to comment
Share on other sites

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;
}
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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