ondi Posted June 10, 2008 Share Posted June 10, 2008 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> "; } } ?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 10, 2008 Share Posted June 10, 2008 Well, i dont know if you made the error in replacing your passwords, but you didn't close your quote on line 3. There is also a missing $ sign on line 11. Quote Link to comment Share on other sites More sharing options...
ondi Posted June 10, 2008 Author Share Posted June 10, 2008 Hehe that was indeed an error when changing passwords! I've added a $ but still no luck getting rid of the error codes Quote Link to comment Share on other sites More sharing options...
jonsjava Posted June 10, 2008 Share Posted June 10, 2008 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> "; } } ?> Quote Link to comment Share on other sites More sharing options...
ondi Posted June 10, 2008 Author Share Posted June 10, 2008 Sorry, no luck with that jonsjava Quote Link to comment Share on other sites More sharing options...
revraz Posted June 10, 2008 Share Posted June 10, 2008 Well what data is in line 2? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 10, 2008 Share Posted June 10, 2008 Also, the echo statements towards the bottom will error you out (or should, at least). You need to enclose arrays in { } when echoing them. {$data['time']} Quote Link to comment Share on other sites More sharing options...
ondi Posted June 10, 2008 Author Share Posted June 10, 2008 well, $host = '****'; but to me this looks fine.. Quote Link to comment Share on other sites More sharing options...
revraz Posted June 10, 2008 Share Posted June 10, 2008 *** needs to be your actual host name. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 10, 2008 Share Posted June 10, 2008 What's the ACTUAL value in host? I'm sure that no one here wants to "hack" you just by knowing your host. =/ Quote Link to comment Share on other sites More sharing options...
jonsjava Posted June 10, 2008 Share Posted June 10, 2008 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; } ?> Quote Link to comment Share on other sites More sharing options...
ondi Posted June 10, 2008 Author Share Posted June 10, 2008 This is my line 2: $host = '79.99.43.20'; Quote Link to comment Share on other sites More sharing options...
revraz Posted June 10, 2008 Share Posted June 10, 2008 Narrow it down, remove $host = '****'; $user = '****'; $password = '****'; one at a time and see which is causing it. Quote Link to comment Share on other sites More sharing options...
ondi Posted June 10, 2008 Author Share Posted June 10, 2008 I've tried getting rid of all the connection lines but the error still remains! :| Quote Link to comment Share on other sites More sharing options...
revraz Posted June 10, 2008 Share Posted June 10, 2008 What editor are you using? Open it in Notepad to see if there is a hidden character. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 10, 2008 Share Posted June 10, 2008 It is highly likely there is content or a UTF-8 BOM before the <?php tag that is causing the error. Quote Link to comment Share on other sites More sharing options...
ondi Posted June 10, 2008 Author Share Posted June 10, 2008 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! Quote Link to comment Share on other sites More sharing options...
ondi Posted June 10, 2008 Author Share Posted June 10, 2008 Haha totally my fault! I didnt have any values to input! Ooops! (That had nothing to do with the first errors though!) Thank you everyone, you've been ace! Quote Link to comment Share on other sites More sharing options...
revraz Posted June 10, 2008 Share Posted June 10, 2008 Nice, mark as Solved please. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.