muckv Posted October 31, 2008 Share Posted October 31, 2008 When I pass the variable (string) I can not display it in another .php file In here I pass the var for($i=0;$i<$max;$i++){ echo '<A HREF="http://localhost/IPTC/inhoud.php?var='.$dirs[$i].'">'.$dirs[$i].'</A><br>'; $temp= get_images_in_subdir($dirs[$i]); if($temp!= null){$images[]=$temp;} } here I want to display it but it's a blank page when executed, <html> <head> <title>Inhoud</title> </head> <? echo $var; ?> </html> Can somebody see the error? Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/ Share on other sites More sharing options...
Gulsaes Posted October 31, 2008 Share Posted October 31, 2008 well the first option would be to declare $var as a Global, otherwise i'd say easiest would be to put your "for" code into a function then call that function from the other page where you wish to display it.... Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679153 Share on other sites More sharing options...
muckv Posted October 31, 2008 Author Share Posted October 31, 2008 make $var global? it's a variable I create when passing it the other page where I want to use it? doesn't work Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679157 Share on other sites More sharing options...
blueman378 Posted October 31, 2008 Share Posted October 31, 2008 first question, possibly short open tags creating errors? 2nd: possibly error reporting turned off? Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679159 Share on other sites More sharing options...
muckv Posted October 31, 2008 Author Share Posted October 31, 2008 well if I look at the url after I clicked the link I see http://url/inhoud.php?var=string so I see that $var has gotten it's correct value Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679163 Share on other sites More sharing options...
Gulsaes Posted October 31, 2008 Share Posted October 31, 2008 $var =$_GET['var']; echo $var; Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679166 Share on other sites More sharing options...
muckv Posted October 31, 2008 Author Share Posted October 31, 2008 nope doesn't work either Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679167 Share on other sites More sharing options...
kenrbnsn Posted October 31, 2008 Share Posted October 31, 2008 Please tell us what version of PHP you're running. Upload a file containing <?php phpinfo(); ?> and invoke it. Ken Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679182 Share on other sites More sharing options...
muckv Posted October 31, 2008 Author Share Posted October 31, 2008 PHP Version 5.2.5 Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" Server API CGI/FastCGI Virtual Directory Support enabled Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\Program Files\phpDesigner 2008\PHP\php.ini PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Debug Build no Thread Safety enabled Zend Memory Manager enabled IPv6 Support enabled Registered PHP Streams php, file, data, http, ftp, compress.zlib, zip Registered Stream Socket Transports tcp, udp Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.* Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679185 Share on other sites More sharing options...
muckv Posted October 31, 2008 Author Share Posted October 31, 2008 anyone? Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679221 Share on other sites More sharing options...
samshel Posted October 31, 2008 Share Posted October 31, 2008 1) Please post HTML of the URL from where you are redirecting. 2) put print_r($_REQUEST) in inhoud.php and post the result. Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679223 Share on other sites More sharing options...
muckv Posted October 31, 2008 Author Share Posted October 31, 2008 http://localhost/IPTC/index.php From here I make the url going to http://localhost/IPTC/inhoud.php?var=jan (jan is the correct value) print_r($_REQUEST) in inhoud.php gives me no output I will post all my relevant code <?php include("directory.php"); $rootfolder = new folder('.'); global $dirs; $dirs=$rootfolder->scanfdir(); $max=sizeof($dirs); for($i=0;$i<$max;$i++) { //$dirs[] is full of strings, checked and working echo '<A HREF="http://localhost/IPTC/inhoud.php?var='.$dirs[$i].'">'.$dirs[$i].'</A><br>'; } ?> <html> <head> <title>Inhoud</title> </head> <body> <? $var =$_GET['var']; echo $var; print_r($_REQUEST); $path = './IPTC/'.$var; function check_extension($extensie){ ($extensie == 'jpg' || $extensie == 'jpeg' || $extensie == 'gif')? true : false; } function get_images($path){ $files = scandir($path); for($i = 0;$i < sizeof($files);$i++) { $ext = substr($files[$i], strrpos($files[$i], '.') + 1); if(check_extensie($ext)){ $string .= $files[$i].' '; } } return $string; } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679265 Share on other sites More sharing options...
kenrbnsn Posted October 31, 2008 Share Posted October 31, 2008 Change the "<?" in the file inhoud.php to "<?php". You probably have short tags turned off in the php.ini file. Ken Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679282 Share on other sites More sharing options...
muckv Posted October 31, 2008 Author Share Posted October 31, 2008 geez thanks ken, you really helped me out thanks Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-679284 Share on other sites More sharing options...
blueman378 Posted November 4, 2008 Share Posted November 4, 2008 Change the "<?" in the file inhoud.php to "<?php". You probably have short tags turned off in the php.ini file. Ken lol i said that right at the start... but nobody listens to someone with no rank Link to comment https://forums.phpfreaks.com/topic/130851-solved-passing-on-variable-does-not-go-well/#findComment-681967 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.