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 user_id=$userID"; $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; } 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> If you refresh this page before getting a starter, you will not obtain a starter, and it will take up a spot in your party. <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/page/2/#findComment-415804 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 So can you tell me what's wrong? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415824 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 this should do the trick: Â <?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 user_id=$userID"; $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; } else{ 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"; } mysql_query($result2)or die(mysql_error()); echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> If you refresh this page before getting a starter, you will not obtain a starter, and it will take up a spot in your party. <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/page/2/#findComment-415828 Share on other sites More sharing options...
kenrbnsn Posted December 15, 2007 Share Posted December 15, 2007 Your logic doesn't make any sense in this area: <?php } 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."; } ?> Â You set the insert query at the top, before you set the variables. Also the statements like: <?php if($pokemonname=="Turtwig"){ $pokemonname="Turtwig"; } elseif($pokemonname=="Piplup"){ $pokemonname="Piplup"; } elseif($pokemonname=="Chimchar"){ $pokemonname="Chimchar"; } else{ $pokemonname="Turtwig"; } ?> really don't make any sense. You're checking to see if the variable is a certain value and then setting it to that value. Â Ken Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415829 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 HAHAHAHA I know I was thinking the same thing awhile ago but I decided to let him do things the way he wanted to. I also suggested he use a switch when adding the attacks and other attributes but he didnt listen..... Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415830 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 I tried that before. It didnt make a differance, and it STILL deosnt.   And I changed it to a simple  <?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 user_id=$userID"; $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; } else{ if ($submit) { if($pokemonname=="Turtwig"){ $pokemonname="Turtwig";             $pokemonimage="http://i9.tinypic.com/6sapvo1.png";             $pokemonimage2="http://i12.tinypic.com/81i2tkl.png";             $attack="15";             $defence="20"; } elseif($pokemonname=="Piplup"){ $pokemonname="Piplup";             $pokemonimage="http://i13.tinypic.com/6jzrsdv.png";             $pokemonimage2="http://i4.tinypic.com/6uepa2h.png";             $attack="20";             $defence="15"; } elseif($pokemonname=="Chimchar"){ $pokemonname="Chimchar";             $pokemonimage="http://i10.tinypic.com/6p98rch.png";             $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; $attack="18"; $defence="17"; } else{ $pokemonname="Turtwig";             $pokemonimage="http://i9.tinypic.com/6sapvo1.png";             $pokemonimage2="http://i12.tinypic.com/81i2tkl.png";             $attack="15";             $defence="20"; } if($gender=="Male"){ $gender="Male"; } elseif($gender=="Female"){ $gender="Female"; } else{ $gender="Male"; } mysql_query($result2)or die(mysql_error()); echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> If you refresh this page before getting a starter, you will not obtain a starter, and it will take up a spot in your party. <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; ?>  But the same tihng happens. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415832 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 ok give me a minute and ill re-review your coding and try to find the problem Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415835 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Im looking at a tut for switch, and its un-understandable.. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415837 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 try this: Â <?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 user_id=$userID"; 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{ if ($submit) { switch($pokemonname){ case "Piplup": $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; $attack="20"; $defence="15"; break; case "Chimchar": $pokemonimage="http://i10.tinypic.com/6p98rch.png"; $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; $attack="18"; $defence="17"; break; default: $pokemonname="Turtwig"; $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; $attack="15"; $defence="20"; break; } $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')"; mysql_query($result2)or die(mysql_error()); echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> If you refresh this page before getting a starter, you will not obtain a starter, and it will take up a spot in your party. <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/page/2/#findComment-415838 Share on other sites More sharing options...
Northern Flame Posted December 15, 2007 Share Posted December 15, 2007 did it work? Â if so, be sure to hit the "Topic Solved" button! Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415857 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Thanks, that worked. But do you know why ot wont let me use a rand function in switch? Â Mine says $level="(rand(1,10))"; Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $exp="0/(rand(20,50))"; Â And it displays it as 0. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415859 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Also it wont display attacks Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415867 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 This is the code  <?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']; $level = $_POST['pokemon_level']; $exp = $_POST['pokemon_exp']; $attack1 = $_POST['attack1']; $attack2 = $_POST['attack2']; $attack3 = $_POST['attack3']; $attack4 = $_POST['attack4']; $result="SELECT * FROM pokemon_info WHERE user_id=$userID"; 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{ if ($submit) { switch($pokemonname){ case "Piplup": $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; $attack="20"; $defence="15";                 $attack1="Flamethrower";                 $attack2="Hydro Pump";                 $attack3="Razor Leaf";                 $attack4="Thunder";                 $level="(rand(1,10))";                 $exp="0/(rand(20,50))"; break; case "Chimchar": $pokemonimage="http://i10.tinypic.com/6p98rch.png"; $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; $attack="18"; $defence="17";                 $attack1="Flamethrower";                 $attack2="Hydro Pump";                 $attack3="Razor Leaf";                 $attack4="Thunder";                 $level="(rand(1,10))";                 $exp="0/(rand(20,50))"; break; default: $pokemonname="Turtwig"; $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; $attack="15"; $defence="20";                 $attack1="Flamethrower";                 $attack2="Hydro Pump";                 $attack3="Razor Leaf";                 $attack4="Thunder";                 $level="(rand(1,10))";                 $exp="0/(rand(20,50))"; break; } $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')"; mysql_query($result2)or die(mysql_error()); echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> If you refresh this page before getting a starter, you will not obtain a starter, and it will take up a spot in your party. <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/page/2/#findComment-415868 Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 Can someone help? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415878 Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 try it without the quotes around the rand() function  i deleted the quotes for you, try this  <?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']; $level = $_POST['pokemon_level']; $exp = $_POST['pokemon_exp']; $attack1 = $_POST['attack1']; $attack2 = $_POST['attack2']; $attack3 = $_POST['attack3']; $attack4 = $_POST['attack4']; $result="SELECT * FROM pokemon_info WHERE user_id=$userID"; 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{ if ($submit) { switch($pokemonname){ case "Piplup": $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; $attack="20"; $defence="15"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $exp= 0 / rand(20,50); break; case "Chimchar": $pokemonimage="http://i10.tinypic.com/6p98rch.png"; $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; $attack="18"; $defence="17"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $exp= 0 /(rand(20,50)); break; default: $pokemonname="Turtwig"; $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; $attack="15"; $defence="20"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $exp= 0 / rand(20,50); break; } $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')"; mysql_query($result2)or die(mysql_error()); echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> If you refresh this page before getting a starter, you will not obtain a starter, and it will take up a spot in your party. <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/page/2/#findComment-415879 Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 Its still messed, and it doesnt display attacks1, 2, 3, and 4 either. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415883 Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 what do you mean it doesnt display the attacks.... Â you didnt echo anything, or do you mean in your database? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415884 Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 what do you mean it doesnt display the attacks....  you didnt echo anything, or do you mean in your database? In my databases.  Look, this is how everything works  Everyting was displayed, then exp goes like always 0, not 0/blah, just 0. Level is 0. And Attacks show NOTHING Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415885 Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 oh is exp suppose to show this 0 / blah i thought exp was suppose to be a solid number ok, I will re-edit it for you, and the attacks were now shown because you never told the mysql_query() to insert them into it, Â what are the column names for the attacks? is it just attack1 attack2 attack3 and attack4? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415887 Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 ROFL! I fixed it myself. Â But EXP displays as 0, and It's because the 0/ I think. I need it to display 0/500 or something. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415890 Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 replace each $exp variable with this line and that should work  $exp= '0/'.rand(20,50);   and if you want that in a database, be sure to add it in lol Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415892 Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 Its added, but same error. Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415894 Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 I just inserted this on a php page of mine and it worked  <?php $exp= '0/'.rand(20,50); echo $exp; ?>  the output was 0/44 44 being the random number, so I do not see why you are getting 0 Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415896 Share on other sites More sharing options...
Xyphon Posted December 16, 2007 Author Share Posted December 16, 2007 I just did that on my page, too. It just doesnt add it to DB.. Â <?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']; $level = $_POST['pokemon_level']; $exp = $_POST['pokemon_exp']; $attack1 = $_POST['attack1']; $attack2 = $_POST['attack2']; $attack3 = $_POST['attack3']; $attack4 = $_POST['attack4']; $Hi="0/"; $result="SELECT * FROM pokemon_info WHERE user_id=$userID"; 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{ if ($submit) { switch($pokemonname){ case "Piplup": $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; $attack="20"; $defence="15"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $exp= '0/'.rand(20,50); break; case "Chimchar": $pokemonimage="http://i10.tinypic.com/6p98rch.png"; $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; $attack="18"; $defence="17"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $exp= '0/'.rand(20,50); break; default: $pokemonname="Turtwig"; $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; $attack="15"; $defence="20"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $exp= '0/'.rand(20,50); break; } $result2="INSERT INTO pokemon_info (user_id,pokemon_name,pokemon_attack,pokemon_defence,pokemon_image,pokemon_gender,pokemon_icon,pokemon_level,pokemon_exp,attack1,attack2,attack3,attack4) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2','$level','$exp','$attack1','$attack2','$attack3','$attack4')"; mysql_query($result2)or die(mysql_error()); echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> If you refresh this page before getting a starter, you will not obtain a starter, and it will take up a spot in your party. <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; ?> Â Whats wrong? Quote Link to comment https://forums.phpfreaks.com/topic/81821-solved-unexpected-on-last-line/page/2/#findComment-415902 Share on other sites More sharing options...
Northern Flame Posted December 16, 2007 Share Posted December 16, 2007 I'm not sure, but try this: Â <?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']; $level = $_POST['pokemon_level']; $exp = $_POST['pokemon_exp']; $attack1 = $_POST['attack1']; $attack2 = $_POST['attack2']; $attack3 = $_POST['attack3']; $attack4 = $_POST['attack4']; $Hi="0/"; $result="SELECT * FROM pokemon_info WHERE user_id=$userID"; 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{ if ($submit) { switch($pokemonname){ case "Piplup": $pokemonimage="http://i13.tinypic.com/6jzrsdv.png"; $pokemonimage2="http://i4.tinypic.com/6uepa2h.png"; $attack="20"; $defence="15"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $con = rand(20,50); $exp= "0/$con"; break; case "Chimchar": $pokemonimage="http://i10.tinypic.com/6p98rch.png"; $pokemonimage2="http://i15.tinypic.com/717m0oy.png"; $attack="18"; $defence="17"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $con = rand(20,50); $exp= "0/$con"; break; default: $pokemonname="Turtwig"; $pokemonimage="http://i9.tinypic.com/6sapvo1.png"; $pokemonimage2="http://i12.tinypic.com/81i2tkl.png"; $attack="15"; $defence="20"; $attack1="Flamethrower"; $attack2="Hydro Pump"; $attack3="Razor Leaf"; $attack4="Thunder"; $level= rand(1,10); $con = rand(20,50); $exp= "0/$con"; break; } $result2="INSERT INTO pokemon_info (user_id,pokemon_name,pokemon_attack,pokemon_defence,pokemon_image,pokemon_gender,pokemon_icon,pokemon_level,pokemon_exp,attack1,attack2,attack3,attack4) values ('$userID','$pokemonname','$attack','$defence','$pokemonimage','$gender','$pokemonimage2','$level','$exp','$attack1','$attack2','$attack3','$attack4')"; mysql_query($result2)or die(mysql_error()); echo "You have obtained your starter. It is $pokemonname."; } else{ echo "<html> If you refresh this page before getting a starter, you will not obtain a starter, and it will take up a spot in your party. <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/page/2/#findComment-415905 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.