Glen Posted October 21, 2008 Share Posted October 21, 2008 Hello all, I am recieving this error and i dont know how to overcome this situation. I am trying to download data given out by a game website i play. Tribalwars. set_time_limit(300); $dbhost = 'Hidden'; $dbuser = 'Hidden'; $dbpass = 'Hidden'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'tribalwars'; mysql_select_db($dbname) or die('Error selecting database'); $lines = gzfile('http://en7.tribalwars.net/map/village.txt.gz'); if(!is_array($lines)) die("File could not be opened"); foreach($lines as $line) { list($id, $name,$x, $y, $player, $points, $rank) = explode(',', $line); $name = urldecode($name); $name = addslashes($name); $sql = "INSERT INTO village SET id='$id', name='$name', x='$x', y='$y', player='$player', points='$points', rank='$rank'"; mysql_query($sql); ?> I know this error is caused by haveing an open curly bracket but that is the code. The code is located here http://en7.tribalwars.net/help2.php?article=map_data Is there anywhere the curly bracket should go or is there a way to get round this? Thanks all Best Regards -Glen Quote Link to comment https://forums.phpfreaks.com/topic/129421-solved-parse-error-syntax-error-unexpected-end-in-cwampwwwvillagesphp-on-line-5/ Share on other sites More sharing options...
revraz Posted October 21, 2008 Share Posted October 21, 2008 It should go where it's missing. Sift through it and find where it's missing at, which is probably right before the ?> end tag. Is there anywhere the curly bracket should go or is there a way to get round this? Thanks all Best Regards -Glen Quote Link to comment https://forums.phpfreaks.com/topic/129421-solved-parse-error-syntax-error-unexpected-end-in-cwampwwwvillagesphp-on-line-5/#findComment-671000 Share on other sites More sharing options...
php.ajax.coder Posted October 21, 2008 Share Posted October 21, 2008 try removing '$conn =' and add a closing } to the foreach statement on the line $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); Quote Link to comment https://forums.phpfreaks.com/topic/129421-solved-parse-error-syntax-error-unexpected-end-in-cwampwwwvillagesphp-on-line-5/#findComment-671002 Share on other sites More sharing options...
wildteen88 Posted October 21, 2008 Share Posted October 21, 2008 Your foreach statement is missing a closing brace } add one after mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/129421-solved-parse-error-syntax-error-unexpected-end-in-cwampwwwvillagesphp-on-line-5/#findComment-671006 Share on other sites More sharing options...
revraz Posted October 21, 2008 Share Posted October 21, 2008 Why? try removing '$conn =' on the line $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); Quote Link to comment https://forums.phpfreaks.com/topic/129421-solved-parse-error-syntax-error-unexpected-end-in-cwampwwwvillagesphp-on-line-5/#findComment-671007 Share on other sites More sharing options...
Glen Posted October 21, 2008 Author Share Posted October 21, 2008 Thanks for the quick response guys. Thats it problem solved guys. Thanks a million Best Regards -Glen Quote Link to comment https://forums.phpfreaks.com/topic/129421-solved-parse-error-syntax-error-unexpected-end-in-cwampwwwvillagesphp-on-line-5/#findComment-671103 Share on other sites More sharing options...
MadTechie Posted October 21, 2008 Share Posted October 21, 2008 Glen, Can you click Solved please Why? try removing '$conn =' on the line $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); LOL php.ajax.coder post was updated after wildteen88 post and revraz comment Quote Link to comment https://forums.phpfreaks.com/topic/129421-solved-parse-error-syntax-error-unexpected-end-in-cwampwwwvillagesphp-on-line-5/#findComment-671105 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.