flattened Posted November 5, 2009 Share Posted November 5, 2009 I'm trying to make a plugboard (success) that allows the input of common button sizes (88x31, 100x35, 468x60 [success]) and displays them based on the get variable (FAIL). But my problem is, it's not following the GET, it just prints everything: $myFile is the file (that part works fine) if($_GET[ads]="small"){ $file_handle = fopen($myFile, "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode('|', $line_of_text); if($parts[4] == "0" && $parts[0]== 31){ $alt= $parts[2]; if($parts[2]==""){$alt=$parts[3];} echo " <a href=\"".$parts[3]."\"><img src=\"".$parts[1]."\" alt=\"".$alt."\" target=\"_blank\"></a>"; } } } if($_GET[ads]="medium"){ $file_handle = fopen($myFile, "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode('|', $line_of_text); if($parts[4] == "0" && $parts[0]== 35){ $alt= $parts[2]; if($parts[2]==""){$alt=$parts[3];} echo "<a href=\"".$parts[3]."\"><img src=\"".$parts[1]."\" alt=\"".$alt."\" target=\"_blank\"></a>"; } } } if($_GET[ads]="large"){ $file_handle = fopen($myFile, "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode('|', $line_of_text); if($parts[4] == "0" && $parts[0]== 35){ $alt= $parts[2]; if($parts[2]==""){$alt=$parts[3];} echo "<a href=\"".$parts[3]."\"><img src=\"".$parts[1]."\" alt=\"".$alt."\" target=\"_blank\"></a>"; } } } Does anyone see why this would not work? Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/180475-problem-with-get-variable-and-fopen/ Share on other sites More sharing options...
clay1 Posted November 6, 2009 Share Posted November 6, 2009 1 problem I see is you need single quotes around your get variables inside the brackets like this: if($_GET['ads'] Quote Link to comment https://forums.phpfreaks.com/topic/180475-problem-with-get-variable-and-fopen/#findComment-952209 Share on other sites More sharing options...
rajivgonsalves Posted November 6, 2009 Share Posted November 6, 2009 if($_GET[ads]="small"){ should be if($_GET[ads]=="small"){ its not "=" its "==" for comparison "=" is for assignment Quote Link to comment https://forums.phpfreaks.com/topic/180475-problem-with-get-variable-and-fopen/#findComment-952211 Share on other sites More sharing options...
flattened Posted November 6, 2009 Author Share Posted November 6, 2009 Wow. I didn't even notice that. Been a long day. Thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/180475-problem-with-get-variable-and-fopen/#findComment-952222 Share on other sites More sharing options...
rajivgonsalves Posted November 6, 2009 Share Posted November 6, 2009 Welcome, this happens to most of us Quote Link to comment https://forums.phpfreaks.com/topic/180475-problem-with-get-variable-and-fopen/#findComment-952227 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.