brandon99919 Posted June 28, 2009 Share Posted June 28, 2009 here's the full script: <?php //If the user is not logged in if (!isset($_COOKIE['userid'])) { echo "You need to be logged in to view this page.<br /><a href='index.php?page=login'>Click here</a> to login.<br /> <a href='index.php?page=register'>New to PCP?</a>"; } else { ?> <div align="center"> <b>change your party</b> <hr size='1px' width='70%' color='#000000' /> <?php if (isset($_GET['slot'])) { //Set the get variable $slot_c = $_GET['slot']; //Checks to see if the slot exists $check = mysql_query("SELECT * FROM pokemon WHERE p_owner = '$userid' and p_slot = '$slot_c'") or die(mysql_error()); $check2 = mysql_num_rows($check); $check3 = mysql_fetch_array($check); $cp_id = $check3['pid']; //If it doesn't exist if ($check2 == 0) { echo "No Pokémon was found in that slot."; } else { //Update the other pokemon's slot mysql_query("UPDATE pokemon SET p_slot = '$slot_c' WHERE p_owner = '$userid' and p_slot = '1'") or die(mysql_error()); //Update the pokemon's slot to 1 mysql_query("UPDATE pokemon SET p_slot = '1' WHERE p_owner = '$userid' and p_slot = '$slot_c' and pid = '$cp_id'") or die( mysql_error()); } } ?> <?php //First pokemon in the party $slot_1 = mysql_query("SELECT * FROM pokemon WHERE p_owner = '$userid' and p_slot = '1'") or die(mysql_error()); $s_fetch = mysql_fetch_array($slot_1); $pokemon_1 = $s_fetch['p_sprite']; $p_name = $s_fetch['p_name']; $l = $s_fetch['p_level']; if(!$pokemon_1) { echo "<img src=\"pokemonball.gif\">"; } else { echo "<img src='{$pokemon_1}' alt='{$p_name}'><br /> <a href='content/change_party.php?slot=1'>Make starter</a>"; } ?> <?php //Second pokemon in the party $slot_2 = mysql_query("SELECT * FROM pokemon WHERE p_owner = '$userid' and p_slot = '2'") or die(mysql_error()); $s_fetch_2 = mysql_fetch_array($slot_2); $pokemon_2 = $s_fetch_2['p_sprite']; $p_name_2 = $s_fetch_2['p_name']; $l_2 = $s_fetch_2['p_level']; if(!$pokemon_2) { echo "<img src=\"pokemonball.gif\">"; } else { echo "<img src='{$pokemon_2}' alt='{$p_name_2}'><br /> <a href='content/change_party.php?slot=2'>Make starter</a>"; } ?> <?php //Third pokemon in the party $slot_3 = mysql_query("SELECT * FROM pokemon WHERE p_owner = '$userid' and p_slot = '3'") or die(mysql_error()); $s_fetch_3 = mysql_fetch_array($slot_3); $pokemon_3 = $s_fetch_3['p_sprite']; $p_name_3 = $s_fetch_3['p_name']; $l_3 = $s_fetch_3['p_level']; if(!$pokemon_3) { echo "<img src='pokemonball.gif'>"; } else { echo "<img src='{$pokemon_3}' alt='{$p_name_3}'><br /> <a href='change_party.php?slot=3'>Make starter</a>"; } ?> <br /> <?php //Forth pokemon in the party $slot_4 = mysql_query("SELECT * FROM pokemon WHERE p_owner = '$userid' and p_slot = '4'") or die(mysql_error()); $s_fetch_4 = mysql_fetch_array($slot_4); $pokemon_4 = $s_fetch_4['p_sprite']; $p_name_4 = $s_fetch_4['p_name']; $l_4 = $s_fetch_4['p_level']; if(!$pokemon_4) { echo "<img src='pokemonball.gif'>"; } else { echo "<img src='{$pokemon_4}' alt='{$p_name_4}'><br /> <a href='index.php?page=change_party?slot=4'>Make starter</a>"; } ?> <?php //Fifth pokemon in the party $slot_5 = mysql_query("SELECT * FROM pokemon WHERE p_owner = '$userid' and p_slot = '5'") or die(mysql_error()); $s_fetch_5 = mysql_fetch_array($slot_5); $pokemon_5 = $s_fetch_5['p_sprite']; $p_name_5 = $s_fetch_5['p_name']; $l_5 = $s_fetch_5['p_level']; if(!$pokemon_5) { echo "<img src='pokemonball.gif'>"; } else { echo "<img src='{$pokemon_5}' alt='{$p_name_5}'><br /> <a href='index.php?page=change_party?slot=5'>Make starter</a>"; } ?> <?php //Sixth pokemon in the party $slot_6 = mysql_query("SELECT * FROM pokemon WHERE p_owner = '$userid' and p_slot = '6'") or die(mysql_error()); $s_fetch_6 = mysql_fetch_array($slot_6); $pokemon_6 = $s_fetch_6['p_sprite']; $p_name_6 = $s_fetch_6['p_name']; $l_6 = $s_fetch_6['p_level']; if(!$pokemon_6) { echo "<img src='pokemonball.gif'>"; } else { echo "<img src='{$pokemon_6}' alt='{$p_name_6}'><br /> <a href='index.php?page=change_party?slot=6'>Make starter</a>"; } ?> <?php } ?> </div> the problem is with the way the site's structured. if you visit certain pages, the index.php uses the GET method to retrieve the pages from the contents folder: index.php?page=page Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/ Share on other sites More sharing options...
JJ2K Posted June 28, 2009 Share Posted June 28, 2009 Sorry could you explain the problem further when you say: the problem is with the way the site's structured. if you visit certain pages, the index.php uses the GET method to retrieve the pages from the contents folder: index.php?page=page maybe with an example of the problem Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865186 Share on other sites More sharing options...
brandon99919 Posted June 28, 2009 Author Share Posted June 28, 2009 well here's the code for the index.php which is pretty much the site's structure: <?php //Include the header file include("top.php"); ?> <!--content--> <?php //database connection include('includes/basefile.php'); //If the user doesn't have javascript echo "<noscript><div align='center'><img src='sprites/pokemon/d&p/normal_frame1/mewtwo.png'> <p class='error'>This site requires JavaScript.</p></div></noscript>"; $show_page = $_GET['page']; if(!isset($show_page) OR $show_page=="") $show_page = "news"; $inc_page = "content/". $show_page .".php"; if(file_exists($inc_page)){ include($inc_page); }else{ echo "<center> <img src='/sprites/pokemon/d&p/normal_frame1/weavile.png' /><br /> The page you're looking for could not be found.<br /> Please check the URL and try again.</center>"; } ?> <!--end of the content--> <?php //Include the footer file include("bottom.php"); ?> the problem is because of the structure, which gets the pages from the contents folder using the GET method, I can't use the GET method for the pages in the content folder, specifically the above script. it just gives an error saying the page doesn't exist. Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865199 Share on other sites More sharing options...
cunoodle2 Posted June 28, 2009 Share Posted June 28, 2009 If you type this in a browser does it come up? http://www.YourDomainHere.Com/content/news.php Again please replace "YourDomainHere" with the actual name of your website. Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865203 Share on other sites More sharing options...
dzelenika Posted June 28, 2009 Share Posted June 28, 2009 have you tried with: $inc_page = "/content/". $show_page .".php"; instead of: $inc_page = "content/". $show_page .".php"; Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865205 Share on other sites More sharing options...
brandon99919 Posted June 28, 2009 Author Share Posted June 28, 2009 yea I tried that and it doesn't display the page. what I'm confused with is the url. when the user clicks the link it goes straight to the page doesn't exist error. here's what the url looks like: www.pcprpg.com/index.php?page=change_party.php?slot=2 Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865228 Share on other sites More sharing options...
dzelenika Posted June 29, 2009 Share Posted June 29, 2009 yea I tried that and it doesn't display the page. what I'm confused with is the url. when the user clicks the link it goes straight to the page doesn't exist error. here's what the url looks like: www.pcprpg.com/index.php?page=change_party.php?slot=2 that often happens to me: you should not have 2 question marks in url. URL should be: www.pcprpg.com/index.php?page=change_party.php&slot=2 (ampersand instead of question mark) Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865261 Share on other sites More sharing options...
brandon99919 Posted June 29, 2009 Author Share Posted June 29, 2009 it still gives the same "the page doesn't exist" error Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865311 Share on other sites More sharing options...
cunoodle2 Posted June 29, 2009 Share Posted June 29, 2009 it still gives the same "the page doesn't exist" error Well then I have to ask. Does the page exist? If you type it in a browser and it doesn't come up then you either have the wrong directory specified or you haven't uploaded the correct file/filename. Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865337 Share on other sites More sharing options...
brandon99919 Posted June 29, 2009 Author Share Posted June 29, 2009 the change_party.php file does exist, it's just that it gives that error because of the code from the index.php file (which is in the above posts) and the change_party.php file itself uses the GET aswell so I guess it confuses the code in the index.php which also uses GET. hard to explain but yea ??? UPDATE: I found the error, turns out all I needed to do was remove the .php from the links in the change_party script, so it works fine now. thanks for the help and sorry if I didn't explain the problem well Link to comment https://forums.phpfreaks.com/topic/164007-solved-need-help-with-the-_getmethod/#findComment-865647 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.