python01 Posted June 19, 2012 Share Posted June 19, 2012 I am working on mobile workpage which would get variable passed in url and based on that id populate the webpage with information from database. I am also using the $GET['screen_check'] to get devices screen resolution. When I click on the link for example webpage.com/index.php?id=2 the id=2 part gets overwritten with the display resolution info and the information I am looking for does not appear. I have the $id=$GET_['id'] above the screen_check script so I think it should work but it does not What would be the correct way to do them both in the same php file? Thanks. Quote Link to comment Share on other sites More sharing options...
btherl Posted June 19, 2012 Share Posted June 19, 2012 Can you please post your code? Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted June 19, 2012 Share Posted June 19, 2012 $_GET['key'], not $GET Quote Link to comment Share on other sites More sharing options...
Barand Posted June 19, 2012 Share Posted June 19, 2012 He was trying to say not $GET_['id'] but $_GET['id'] Quote Link to comment Share on other sites More sharing options...
python01 Posted June 20, 2012 Author Share Posted June 20, 2012 $_GET['key'], not $GET <?php $PropertyID = $_GET["ID"]; ?> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"/> </head> <?php if(!isset($_GET['screen_check'])) { /* This code will be executed if screen resolution has not been detected.*/ echo "<script language='JavaScript'> <!-- document.location=\"$PHP_SELF?screen_check=done&Width=\"+screen.width+\"&Height=\"+screen.height; //--> </script>"; } else { /* This code will be executed after screen resolution is detected.*/ if(isset($_GET['Width'])){// && isset($_GET['Height'])) // Resolution detected $ScreenWidth=$_GET['Width']; } else { // Resolution not detected $ScreenWidth=235; } } echo "Screen width = ".$ScreenWidth; ?> If I do echo $PropertyID; nothing shows up so it looks that the variable is empty and did not get the value from $_GET. What am I doing wrong here? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted June 20, 2012 Share Posted June 20, 2012 Variables are case sensitive, so $_GET['ID'] and $_GET['id'] are two completely different variables. Quote Link to comment Share on other sites More sharing options...
Mahngiel Posted June 20, 2012 Share Posted June 20, 2012 Like Pikachu just said... When I click on the link for example webpage.com/index.php?id=2 $_GET['id'] would be the matching key selector Quote Link to comment Share on other sites More sharing options...
python01 Posted June 21, 2012 Author Share Posted June 21, 2012 I actually do have ?ID=2 in my url so it is matching, made mistake when I typed up this post. And it still does not work. Any ideas anyone? Thank you. Quote Link to comment Share on other sites More sharing options...
python01 Posted June 21, 2012 Author Share Posted June 21, 2012 not sure if it will help but here is my actual URL being typed in/linked: http://www.lottocomplete.com/textback/mweb/index.php?ID=2 after the enter here is what I have in the URL field: http://www.lottocomplete.com/textback/mweb/index.php?screen_check=done&Width=1366&Height=768 I thought that before the URL gets replaced with the screen_check variables the ID would be saved to variable since it is the first thing in my program but for what ever reason it is not happening. Is there any way to combine these variables being passed? Is my initial URL correct? Is my problem completely something different? If I insert $PropertyID=2; somwhere in my code everything is working fine so I know the reminder of the code is working it is just the passing of the variable that causing my headache right now. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 21, 2012 Share Posted June 21, 2012 Most of the problem is because $PHP_SELF was depreciated over 10 years ago, throws a depreciated error in php5.3 when turned on (where the depreciated error was introduced), and has been completely removed as of php5.4. Also, the current variable to reference php_self - $_SERVER['PHP_SELF'] seems to randomly change without any documentation between having and not having the get parameters as part of it. You need to build the URL in your javascript differently. Since your code has the $_GET['ID'] in $PropertyID, why not deliberately build the URL using that - echo "<script language='JavaScript'> <!-- document.location=\"?ID=$PropertyID&screen_check=done&Width=\"+screen.width+\"&Height=\"+screen.height; //--> </script>"; Quote Link to comment Share on other sites More sharing options...
python01 Posted June 21, 2012 Author Share Posted June 21, 2012 Works great, thank you everyone for helping with this trouble. Quote Link to comment 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.