yakoup46 Posted April 16, 2010 Share Posted April 16, 2010 Here is my code I cannot find the fu**ing unexpected ')' Maybe I have just been looking at code to much today but I really don't see it. HELP! <?php $mysql_host = "mysql6.000webhost.com"; $mysql_database = "a1091112_values"; $mysql_user = "a1091112_values"; $mysql_password = "yakoup46"; $con = mysql_connect($mysql_host, $mysql_user, $mysql_password) or die ('Error connecting to mysql'); mysql_select_db($mysql_database); if(isset($_POST['buttonsumofodds']) || $_POST['inputbox1'])) { $sql="INSERT INTO Sumofodds VALUES ('$_POST[inputbox1]')"; if($_POST[inputbox1] != -144) echo "Sorry Wrong!"; else echo "Correct!"; } if(isset($_POST['buttonsumofchain']) || $_POST['inputbox3'])) { $sql="INSERT INTO Sumofchain VALUES ('$_POST[inputbox3]')"; if($_POST[inputbox3] != 820) echo "Sorry Wrong!"; else echo "Correct!"; } if(isset($_POST['buttonsumofsquares']) || $_POST['inputbox2'])) { $sql="INSERT INTO Sumofsquares VALUES ('$_POST[inputbox2]')"; if($_POST[inputbox2] != 2870) echo "Sorry Wrong!"; else echo "Correct!"; } if(isset($_POST['buttonsumofprimes']) || $_POST['inputbox5'])) { $sql="INSERT INTO Sumofprimes VALUES ('$_POST[inputbox5]')"; if($_POST[inputbox5] != 1060) echo "Sorry Wrong!"; else echo "Correct!"; } if(isset($_POST['buttonsumofdifference']) || $_POST['inputbox4'])) { $sql="INSERT INTO Diffofsums VALUES ('$_POST[inputbox4]')"; if($_POST[inputbox4] != -144) echo "Sorry Wrong!"; else echo "Correct!"; } echo '<br>Redirecting...'; echo '<META HTTP-EQUIV="Refresh" Content="1; URL=http://luta.comuv.com/Easy/easy.html">'; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con) ?> Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/ Share on other sites More sharing options...
Deoctor Posted April 16, 2010 Share Posted April 16, 2010 dude u have a typo error.. if(isset($_POST['buttonsumofodds']) || $_POST['inputbox1'])) change this to if(isset($_POST['buttonsumofodds']) || $_POST['inputbox1']) and also if(isset($_POST['buttonsumofchain']) || $_POST['inputbox3'])) this too if(isset($_POST['buttonsumofchain']) || $_POST['inputbox3']) as well as if(isset($_POST['buttonsumofsquares']) || $_POST['inputbox2'])) these too if(isset($_POST['buttonsumofsquares']) || $_POST['inputbox2']) from if(isset($_POST['buttonsumofprimes']) || $_POST['inputbox5'])) to if(isset($_POST['buttonsumofprimes']) || $_POST['inputbox5']) from if(isset($_POST['buttonsumofdifference']) || $_POST['inputbox4'])) to if(isset($_POST['buttonsumofdifference']) || $_POST['inputbox4']) Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1042836 Share on other sites More sharing options...
andrewgauger Posted April 16, 2010 Share Posted April 16, 2010 You probably wont believe this, but it is on line 10, the last ) Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1042837 Share on other sites More sharing options...
yakoup46 Posted April 16, 2010 Author Share Posted April 16, 2010 I did as you said ym_chaitu but now I am getting... Error: Column count doesn't match value count at row 1 Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043028 Share on other sites More sharing options...
TeddyKiller Posted April 16, 2010 Share Posted April 16, 2010 dude u have a typo error.. Nice spotting, that made me laugh with all them Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043029 Share on other sites More sharing options...
yakoup46 Posted April 16, 2010 Author Share Posted April 16, 2010 I'm not sure I get it? :-\ Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043033 Share on other sites More sharing options...
TeddyKiller Posted April 16, 2010 Share Posted April 16, 2010 It was a bit of humour about ym_chaitu's response. As for your problem.. are you able to identify the query thats offending? It seems hard as they all nearly look the same. Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043034 Share on other sites More sharing options...
TeddyKiller Posted April 16, 2010 Share Posted April 16, 2010 Although I just noticed. $sql="INSERT INTO Sumofodds VALUES ('$_POST[inputbox1]')"; These aren't qurys, these are strings. Maybe try a format like.. $sql = mysql_query(" blah blah here "); Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043037 Share on other sites More sharing options...
Deoctor Posted April 16, 2010 Share Posted April 16, 2010 I'm not sure I get it? :-\ as per ur errors it looks like the tables columns into which u are entering are not matching. check ur database and see whether u have all the tables with these columns in which u are inserting.. Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043038 Share on other sites More sharing options...
Deoctor Posted April 16, 2010 Share Posted April 16, 2010 Although I just noticed. $sql="INSERT INTO Sumofodds VALUES ('$_POST[inputbox1]')"; These aren't qurys, these are strings. Maybe try a format like.. $sql = mysql_query(" blah blah here "); he is running the query at the end.. if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043040 Share on other sites More sharing options...
yakoup46 Posted April 16, 2010 Author Share Posted April 16, 2010 Tried that and now I am getting a Query is Empty Error! LOL $sql = mysql_query(" blah blah here "); Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043042 Share on other sites More sharing options...
yakoup46 Posted April 16, 2010 Author Share Posted April 16, 2010 GOT IT! $sql="INSERT INTO Sumofodds (Column) VALUES ('$_POST[inputbox1]')"; I only had one column in my database so I figured I didn't have to include the column name but I do. Thank you for all the help. Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043047 Share on other sites More sharing options...
TeddyKiller Posted April 16, 2010 Share Posted April 16, 2010 he is running the query at the end.. if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } Yeah I saw that.. I thought that only checks if the query didn't succeed. Link to comment https://forums.phpfreaks.com/topic/198714-php-parse-error-syntax-error-unexpected-on-line-10/#findComment-1043051 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.