Xyphon Posted December 15, 2007 Share Posted December 15, 2007 <?PHP include('Connect.php'); $userID = $_COOKIE['UserID']; $submit = $_POST['submit']; $pokemonname = $_POST['pokemon_name']; $attack = $_POST['pokemon_attack']; $defence = $_POST['pokemon_defence']; $pokemonimage = $_POST['pokemon_image']; $pokemonimage2 = $_POST['pokemon_icon']; $gender = $_POST['pokemon_gender']; $result="INSERT INTO news_comments (user_id,pokemon_name,pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2')"; if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are not logged in."; include('bottom.php'); exit; } if(!mysql_num_rows(mysql_query($result) == 0)) { echo "Sorry, you already have your starter"; include('bottom.php'); exit; mysql_num_rows(mysql_query($result)or die(mysql_error())); if ($submit) { if($pokemonname=="Turtwig") { $pokemonname="Turtwig"; } elseif($pokemonname=="Piplup") { $pokemonname="Piplup"; } elseif($pokemonname=="Chimchar") { $pokemonname="Chimchar"; } else { $pokemonname="Turtwig"; } if($gender=="Male") { $gender="Male"; } elseif($gender=="Female") { $gender="Female"; } else { $gender="Male"; } if($pokemonname=="Turtwig") { $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } elseif($pokemonname=="Piplup") { $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; } elseif($pokemonname=="Chimchar") { $pokemonimage="http://i10.tinypic.com/6p98rch.png"; } else { $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } if($pokemonname=="Turtwig") { $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } elseif($pokemonname=="Piplup") { $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; } elseif($pokemonname=="Chimchar") { $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; } else { $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } if($pokemonname=="Turtwig") { $attack="15"; } elseif($pokemonname=="Piplup") { $attack="20"; } elseif($pokemonname=="Chimchar") { $attack="18"; } else { $attack="15"; } if($pokemonname=="Turtwig") { $defence="20"; } elseif($pokemon_name=="Piplup") { $defence="15"; } elseif($pokemon_name=="Chimchar") { $defence="17"; } else { $defence="20"; } echo "You have obtained your starter. It is $pokemonname."; } else { echo "<html> <method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <b>Choose your pokemon</b><br /> <select name='pokemon_name'> <option value='Turtwig'>Turtwig</option> <option value='Piplup'>Piplup</option> <option value='Chimchar'>Chimchar</option> </select> <b> Choose it's gender</b> <br /> <select name='pokemon_gender'> <option value='Male'>Male</option> <option value='Female'>Female</option> </select> <input type='submit' name='submit' value='Get starter'> </form> </html>"; } include('bottom.php'); exit; ?> I hate this error. It normally has something to do with brackets, right? I just cant seem to find it. Help? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/ Share on other sites More sharing options...
Zane Posted December 15, 2007 Share Posted December 15, 2007 It normally has something to do with brackets, right? Answer: Yes.. Solution: Go back and Indent. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415671 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 It normally has something to do with brackets, right? Answer: Yes.. Solution: Go back and Indent. Indent? And can you just tell me whats wrong, I just looked through, I see noshing. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415673 Share on other sites More sharing options...
rarebit Posted December 15, 2007 Share Posted December 15, 2007 if you indent then you don't have problems with indentation, because the problem is evident! Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415680 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Whats indent? What are you talking about? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415681 Share on other sites More sharing options...
phpSensei Posted December 15, 2007 Share Posted December 15, 2007 You didnt end the brackets for these two if conditions if(!mysql_num_rows(mysql_query($result) == 0)) { echo "Sorry, you already have your starter"; include('bottom.php'); exit; mysql_num_rows(mysql_query($result)or die(mysql_error())); if ($submit) { Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415683 Share on other sites More sharing options...
PFMaBiSmAd Posted December 15, 2007 Share Posted December 15, 2007 It is not our job to proof read your code for you. You have got 140+ lines of unformatted code. How are we supposed to know where your conditional statements and loops are supposed to end and where the { and } should be around blocks of code? If you follow the advice that zanus gave, it would both make it easier for you to find and you would find that someone in a forum would be willing to look at your code and help. If your conditional statements and loops were properly indented, someone could tell where the blocks of related code started and stopped and could help you. The way your code is formatted now, forget it. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415685 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Add one more "}" in the end. edit: ANd another "}" If I add 2, I get an error because of it, if I add 1, same error I had before. PFMa: Umm.. Whats INDENT? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415686 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 sometimes when you format your script by indenting you can easily tell where you need to close brackets, example: <?php // this is only an example, not a solution to your problem! $variable = $_POST['data']; if(isset($variable)){ function testFunction($variable){ switch($variable){ case 'test': echo 'test'; break; case 'testing': echo 'testing'; break; default: echo 'empty'; break; } } } ?> Now you see how each bracket lined up so that you can easily tell where the command starts and ends? indenting really makes your script easier to read! Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415687 Share on other sites More sharing options...
thebadbad Posted December 15, 2007 Share Posted December 15, 2007 Whats indent? What are you talking about? Common English word, check a dictionary. http://www.google.com/search?hl=en&q=define:indent Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415688 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 OH THATS WHAT YOU MEAN. Ok, I'll get on it. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415691 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Well. I added things <?PHP include('Connect.php'); $userID = $_COOKIE['UserID']; $submit = $_POST['submit']; $pokemonname = $_POST['pokemon_name']; $attack = $_POST['pokemon_attack']; $defence = $_POST['pokemon_defence']; $pokemonimage = $_POST['pokemon_image']; $pokemonimage2 = $_POST['pokemon_icon']; $attack1 = $_POST['attack1']; $attack2 = $_POST['attack2']; $attack3 = $_POST['attack3']; $attack4 = $_POST['attack4']; $gender = $_POST['pokemon_gender']; $result="INSERT INTO pokemon_info (user_id, pokemon_name, pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon, attack1, attack2, attack3, attack4) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2','$attack1','$attack2','$attack3','$attack4')"; if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are not logged in."; include('bottom.php'); exit; } if(!mysql_num_rows(mysql_query($result) == 0)) { echo "Sorry, you already have your starter"; include('bottom.php'); exit; mysql_num_rows(mysql_query($result)or die(mysql_error())); if ($submit) { if($pokemonname=="Turtwig") { $pokemonname="Turtwig"; } elseif($pokemonname=="Piplup") { $pokemonname="Piplup"; } elseif($pokemonname=="Chimchar") { $pokemonname="Chimchar"; } else { $pokemonname="Turtwig"; } if($gender=="Male") { $gender="Male"; } elseif($gender=="Female") { $gender="Female"; } else { $gender="Male"; } if($pokemonname=="Turtwig") { $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } elseif($pokemonname=="Piplup") { $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; } elseif($pokemonname=="Chimchar") { $pokemonimage="http://i10.tinypic.com/6p98rch.png"; } else { $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } if($pokemonname=="Turtwig") { $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } elseif($pokemonname=="Piplup") { $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; } elseif($pokemonname=="Chimchar") { $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; } else { $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } if($pokemonname=="Turtwig") { $attack="15"; } elseif($pokemonname=="Piplup") { $attack="20"; } elseif($pokemonname=="Chimchar") { $attack="18"; } else { $attack="15"; } if($pokemonname=="Turtwig") { $defence="20"; } elseif($pokemon_name=="Piplup") { $defence="15"; } elseif($pokemon_name=="Chimchar") { $defence="17"; } else { $defence="20"; } if($pokemonname=="Turtwig") { $attack1="Flamethrower"; $attack2="Razor Leaf"; $attack3="Hydro Pump"; $attack4="Thunder"; } elseif($pokemon_name=="Piplup") { $attack1="Flamethrower"; $attack2="Razor Leaf"; $attack3="Hydro Pump"; $attack4="Thunder"; } elseif($pokemon_name=="Chimchar") { $attack1="Flamethrower"; $attack2="Razor Leaf"; $attack3="Hydro Pump"; $attack4="Thunder"; } else { $attack1="Flamethrower"; $attack2="Razor Leaf"; $attack3="Hydro Pump"; $attack4="Thunder"; } echo "You have obtained your starter. It is $pokemonname."; } else { echo "<html> <method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <b>Choose your pokemon</b><br /> <select name='pokemon_name'> <option value='Turtwig'>Turtwig</option> <option value='Piplup'>Piplup</option> <option value='Chimchar'>Chimchar</option> </select> <b> Choose it's gender</b> <br /> <select name='pokemon_gender'> <option value='Male'>Male</option> <option value='Female'>Female</option> </select> <input type='submit' name='submit' value='Get starter'> </form> </html>"; } include('bottom.php'); exit; } ?> Now it says Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/ptcrpg.awardspace.com/obtainstarter.php on line 23 It worked before O.O Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415703 Share on other sites More sharing options...
phpSensei Posted December 15, 2007 Share Posted December 15, 2007 How the hell are you going to count the num of rows for a INSERT query? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415710 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 I found your problem, try this: <?php include('Connect.php'); $userID = $_COOKIE['UserID']; $submit = $_POST['submit']; $pokemonname = $_POST['pokemon_name']; $attack = $_POST['pokemon_attack']; $defence = $_POST['pokemon_defence']; $pokemonimage = $_POST['pokemon_image']; $pokemonimage2 = $_POST['pokemon_icon']; $gender = $_POST['pokemon_gender']; $result="INSERT INTO news_comments (user_id,pokemon_name,pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2')"; if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are not logged in."; include('bottom.php'); exit; } if(!mysql_num_rows(mysql_query($result) == 0)) { echo "Sorry, you already have your starter"; include('bottom.php'); exit; mysql_num_rows(mysql_query($result)or die(mysql_error())); if ($submit) { if($pokemonname=="Turtwig"){ $pokemonname="Turtwig"; } elseif($pokemonname=="Piplup"){ $pokemonname="Piplup"; } elseif($pokemonname=="Chimchar"){ $pokemonname="Chimchar"; } else{ $pokemonname="Turtwig"; } } if($gender=="Male"){ $gender="Male"; } elseif($gender=="Female"){ $gender="Female"; } else{ $gender="Male"; } if($pokemonname=="Turtwig"){ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage="http://i10.tinypic.com/6p98rch.png"; } else{ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } if($pokemonname=="Turtwig"){ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; } else{ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } if($pokemonname=="Turtwig"){ $attack="15"; } elseif($pokemonname=="Piplup"){ $attack="20"; } elseif($pokemonname=="Chimchar"){ $attack="18"; } else{ $attack="15"; } if($pokemonname=="Turtwig"){ $defence="20"; } elseif($pokemon_name=="Piplup"){ $defence="15"; } elseif($pokemon_name=="Chimchar"){ $defence="17"; } else{ $defence="20"; } echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> <method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <b>Choose your pokemon</b><br /> <select name='pokemon_name'> <option value='Turtwig'>Turtwig</option> <option value='Piplup'>Piplup</option> <option value='Chimchar'>Chimchar</option> </select> <b> Choose it's gender</b> <br /> <select name='pokemon_gender'> <option value='Male'>Male</option> <option value='Female'>Female</option> </select> <input type='submit' name='submit' value='Get starter'> </form> </html>"; } include('bottom.php'); exit; ?> By the way, I suggest you use a switch() instead of all those elseif statements Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415712 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 oh and by the way, you formatted your form at the very end wrong, you put <method='POST' id='frm'> when it should be <form method='POST' id='frm'> Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415714 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Oh jesus, I totally didnt even put the result in the right place! <?PHP include('Connect.php'); include('top.php'); $userID = $_COOKIE['UserID']; $submit = $_POST['submit']; $pokemonname = $_POST['pokemon_name']; $attack = $_POST['pokemon_attack']; $defence = $_POST['pokemon_defence']; $pokemonimage = $_POST['pokemon_image']; $pokemonimage2 = $_POST['pokemon_icon']; $gender = $_POST['pokemon_gender']; $result="SELECT * FROM pokemon_info WHERE pokemon_name=$pokemonname"; $result2="INSERT INTO pokemon_info (user_id,pokemon_name,pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2')"; if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are not logged in."; include('bottom.php'); exit; } if(!mysql_num_rows(mysql_query($result) == 0)) { echo "Sorry, you already have your starter"; include('bottom.php'); exit; mysql_query($result2)or die(mysql_error()); if ($submit) { if($pokemonname=="Turtwig"){ $pokemonname="Turtwig"; } elseif($pokemonname=="Piplup"){ $pokemonname="Piplup"; } elseif($pokemonname=="Chimchar"){ $pokemonname="Chimchar"; } else{ $pokemonname="Turtwig"; } } if($gender=="Male"){ $gender="Male"; } elseif($gender=="Female"){ $gender="Female"; } else{ $gender="Male"; } if($pokemonname=="Turtwig"){ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage="http://i10.tinypic.com/6p98rch.png"; } else{ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } if($pokemonname=="Turtwig"){ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; } else{ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } if($pokemonname=="Turtwig"){ $attack="15"; } elseif($pokemonname=="Piplup"){ $attack="20"; } elseif($pokemonname=="Chimchar"){ $attack="18"; } else{ $attack="15"; } if($pokemonname=="Turtwig"){ $defence="20"; } elseif($pokemon_name=="Piplup"){ $defence="15"; } elseif($pokemon_name=="Chimchar"){ $defence="17"; } else{ $defence="20"; } echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> <method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <b>Choose your pokemon</b><br /> <select name='pokemon_name'> <option value='Turtwig'>Turtwig</option> <option value='Piplup'>Piplup</option> <option value='Chimchar'>Chimchar</option> </select> <b> Choose it's gender</b> <br /> <select name='pokemon_gender'> <option value='Male'>Male</option> <option value='Female'>Female</option> </select> <input type='submit' name='submit' value='Get starter'> </form> </html>"; } include('bottom.php'); exit; ?> I get error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/www/ptcrpg.awardspace.com/obtainstarter.php on line 21 Sorry, you already have your starter Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415719 Share on other sites More sharing options...
phpSensei Posted December 15, 2007 Share Posted December 15, 2007 Change this line if(!mysql_num_rows(mysql_query($result) == 0)) { to if(mysql_num_rows(mysql_query($result)) != 0) { Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415721 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 I still get same error, except now it shows the form data. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415724 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 Yea i also made a mistake on the script I gave you, try this, i also added the fix that phpSensei provided <?PHP include('Connect.php'); $userID = $_COOKIE['UserID']; $submit = $_POST['submit']; $pokemonname = $_POST['pokemon_name']; $attack = $_POST['pokemon_attack']; $defence = $_POST['pokemon_defence']; $pokemonimage = $_POST['pokemon_image']; $pokemonimage2 = $_POST['pokemon_icon']; $gender = $_POST['pokemon_gender']; $result="INSERT INTO news_comments (user_id,pokemon_name,pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2')"; if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are not logged in."; include('bottom.php'); exit; } if(mysql_num_rows(mysql_query($result)) != 0) { echo "Sorry, you already have your starter"; include('bottom.php'); exit; mysql_num_rows(mysql_query($result)or die(mysql_error())); if ($submit) { if($pokemonname=="Turtwig"){ $pokemonname="Turtwig"; } elseif($pokemonname=="Piplup"){ $pokemonname="Piplup"; } elseif($pokemonname=="Chimchar"){ $pokemonname="Chimchar"; } else{ $pokemonname="Turtwig"; } if($gender=="Male"){ $gender="Male"; } elseif($gender=="Female"){ $gender="Female"; } else{ $gender="Male"; } if($pokemonname=="Turtwig"){ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage="http://i10.tinypic.com/6p98rch.png"; } else{ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } if($pokemonname=="Turtwig"){ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; } else{ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } if($pokemonname=="Turtwig"){ $attack="15"; } elseif($pokemonname=="Piplup"){ $attack="20"; } elseif($pokemonname=="Chimchar"){ $attack="18"; } else{ $attack="15"; } if($pokemonname=="Turtwig"){ $defence="20"; } elseif($pokemon_name=="Piplup"){ $defence="15"; } elseif($pokemon_name=="Chimchar"){ $defence="17"; } else{ $defence="20"; } echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> <method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <b>Choose your pokemon</b><br /> <select name='pokemon_name'> <option value='Turtwig'>Turtwig</option> <option value='Piplup'>Piplup</option> <option value='Chimchar'>Chimchar</option> </select> <b> Choose it's gender</b> <br /> <select name='pokemon_gender'> <option value='Male'>Male</option> <option value='Female'>Female</option> </select> <input type='submit' name='submit' value='Get starter'> </form> </html>"; } } include('bottom.php'); exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415725 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 <?PHP include('Connect.php'); include('top.php'); $userID = $_COOKIE['UserID']; $submit = $_POST['submit']; $pokemonname = $_POST['pokemon_name']; $attack = $_POST['pokemon_attack']; $defence = $_POST['pokemon_defence']; $pokemonimage = $_POST['pokemon_image']; $pokemonimage2 = $_POST['pokemon_icon']; $gender = $_POST['pokemon_gender']; $result="SELECT * FROM pokemon_info WHERE pokemon_name=$pokemonname"; $result2="INSERT INTO news_comments (user_id,pokemon_name,pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2')"; if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are not logged in."; include('bottom.php'); exit; } if(mysql_num_rows(mysql_query($result)) != 0) { echo "Sorry, you already have your starter"; include('bottom.php'); exit; mysql_query($result2)or die(mysql_error()); if ($submit) { if($pokemonname=="Turtwig"){ $pokemonname="Turtwig"; } elseif($pokemonname=="Piplup"){ $pokemonname="Piplup"; } elseif($pokemonname=="Chimchar"){ $pokemonname="Chimchar"; } else{ $pokemonname="Turtwig"; } if($gender=="Male"){ $gender="Male"; } elseif($gender=="Female"){ $gender="Female"; } else{ $gender="Male"; } if($pokemonname=="Turtwig"){ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage="http://i10.tinypic.com/6p98rch.png"; } else{ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } if($pokemonname=="Turtwig"){ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; } else{ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } if($pokemonname=="Turtwig"){ $attack="15"; } elseif($pokemonname=="Piplup"){ $attack="20"; } elseif($pokemonname=="Chimchar"){ $attack="18"; } else{ $attack="15"; } if($pokemonname=="Turtwig"){ $defence="20"; } elseif($pokemon_name=="Piplup"){ $defence="15"; } elseif($pokemon_name=="Chimchar"){ $defence="17"; } else{ $defence="20"; } echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> <form method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <b>Choose your pokemon</b><br /> <select name='pokemon_name'> <option value='Turtwig'>Turtwig</option> <option value='Piplup'>Piplup</option> <option value='Chimchar'>Chimchar</option> </select> <b> Choose it's gender</b> <br /> <select name='pokemon_gender'> <option value='Male'>Male</option> <option value='Female'>Female</option> </select> <input type='submit' name='submit' value='Get starter'> </form> </html>"; } } include('bottom.php'); exit; ?> Is my new code. Northern, if you fix again, could you please dit my new code? You dont have some stuff in the old one/ And now same error, except no form data. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415727 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 Ok i think this will do it <?php include('Connect.php'); include('top.php'); $userID = $_COOKIE['UserID']; $submit = $_POST['submit']; $pokemonname = $_POST['pokemon_name']; $attack = $_POST['pokemon_attack']; $defence = $_POST['pokemon_defence']; $pokemonimage = $_POST['pokemon_image']; $pokemonimage2 = $_POST['pokemon_icon']; $gender = $_POST['pokemon_gender']; $result="SELECT * FROM pokemon_info WHERE pokemon_name=$pokemonname"; $result2="INSERT INTO news_comments (user_id,pokemon_name,pokemon_attack, pokemon_defence, pokemon_image, pokemon_gender, pokemon_icon) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2')"; if (!isset($_COOKIE['UserID'])) { echo "Sorry, you are not logged in."; include('bottom.php'); exit; } if(mysql_num_rows(mysql_query($result)) == 0) { echo "Sorry, you already have your starter"; include('bottom.php'); exit; } else{ mysql_query($result2)or die(mysql_error()); if ($submit) { if($pokemonname=="Turtwig"){ $pokemonname="Turtwig"; } elseif($pokemonname=="Piplup"){ $pokemonname="Piplup"; } elseif($pokemonname=="Chimchar"){ $pokemonname="Chimchar"; } else{ $pokemonname="Turtwig"; } if($gender=="Male"){ $gender="Male"; } elseif($gender=="Female"){ $gender="Female"; } else{ $gender="Male"; } if($pokemonname=="Turtwig"){ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage="http://i10.tinypic.com/6p98rch.png"; } else{ $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; } if($pokemonname=="Turtwig"){ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } elseif($pokemonname=="Piplup"){ $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; } elseif($pokemonname=="Chimchar"){ $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; } else{ $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; } if($pokemonname=="Turtwig"){ $attack="15"; } elseif($pokemonname=="Piplup"){ $attack="20"; } elseif($pokemonname=="Chimchar"){ $attack="18"; } else{ $attack="15"; } if($pokemonname=="Turtwig"){ $defence="20"; } elseif($pokemon_name=="Piplup"){ $defence="15"; } elseif($pokemon_name=="Chimchar"){ $defence="17"; } else{ $defence="20"; } echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> <form method='POST' id='frm'> <input type='hidden' name='submit' value='1'><br> <b>Choose your pokemon</b><br /> <select name='pokemon_name'> <option value='Turtwig'>Turtwig</option> <option value='Piplup'>Piplup</option> <option value='Chimchar'>Chimchar</option> </select> <b> Choose it's gender</b> <br /> <select name='pokemon_gender'> <option value='Male'>Male</option> <option value='Female'>Female</option> </select> <input type='submit' name='submit' value='Get starter'> </form> </html>"; } } include('bottom.php'); exit; ?> Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415729 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Same error Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415730 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Its the mysql 0 thing completely. I took it away and it works.. Except it doesnt add its attacks, its attackm its defence, its image, or its icon. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415734 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 There, fixed that MySQL error. But it wont add pokemon_name pokemon_attack pokemon_defence pokemon_image pokemon_icon attack1 attack2 attack3 attack4 Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415740 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 post your new script with the mysql error fixed Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/#findComment-415749 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.