abie Posted October 20, 2009 Share Posted October 20, 2009 I can't find the error: Parse error: syntax error, unexpected T_STRING, expecting ']' in /xx/xx/xx/tap/submit_stats.php on line 4 I've look a lot but cannot find it. Please help? <? $sql = "INSERT INTO tap (p_name, match_r, makes, misses, defensive, mob, lot, g_won, g_lost, dead_balls, 8_break, run, scratch_8, early_8, opp_level, opp_makes, opp_misses, opp_def, team_id) VALUES ('$_POST[p_name]' , '$_POST[match_r]' , '$_POST[makes]' , '$_POST[misses]' , '$_POST[defensive]' , '$_POST[mob]' , '$_POST[lot]' , '$_POST[g_won]' , '$_POST[g_lost]' , '$_POST[dead_balls]' , '$_POST[8_break]' , '$_POST[run]' , '$_POST[scratch_8]' , '$_POST[early_8]' , '$_POST[opp_level]' , '$_POST[opp_makes]' , '$_POST[opp_misses]' , '$_POST[opp_def]' , '$_POST[team_id]'); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } print("Submitted"); ?> Link to comment https://forums.phpfreaks.com/topic/178392-mystery-error/ Share on other sites More sharing options...
Daniel0 Posted October 20, 2009 Share Posted October 20, 2009 Well, you haven't closed the string in $sql. Use an editor with syntax highlighting. It should give away errors like that. Link to comment https://forums.phpfreaks.com/topic/178392-mystery-error/#findComment-940756 Share on other sites More sharing options...
Alex Posted October 20, 2009 Share Posted October 20, 2009 Change all of your values inside of VALUE(), accordingly: '$_POST[p_name]' should be: '{$_POST['p_name']}' Link to comment https://forums.phpfreaks.com/topic/178392-mystery-error/#findComment-940757 Share on other sites More sharing options...
Daniel0 Posted October 20, 2009 Share Posted October 20, 2009 Change all of your values inside of VALUE(), accordingly: '$_POST[p_name]' should be: '{$_POST['p_name']}' Not necessary. The code $array = array('foo' => 'bar'); echo "foo $array[foo]"; is valid and will output foo bar. Link to comment https://forums.phpfreaks.com/topic/178392-mystery-error/#findComment-940758 Share on other sites More sharing options...
Alex Posted October 20, 2009 Share Posted October 20, 2009 Ah, I see: echo "$arr['something']"; // Invalid echo $arr[something]; // Invalid echo "$arr[something]"; //Valid echo "{$arr['something']}"; //Also Valid Seems a bit inconsistent (though I guess PHP is known for being notoriously inconsistent) , so I guess I'll stick with echo "{$arr['something']}" Link to comment https://forums.phpfreaks.com/topic/178392-mystery-error/#findComment-940766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.