facarroll Posted February 19, 2012 Share Posted February 19, 2012 I think this is a PHP topic rather than Javascript. Can anyone tell me why this code cannot find the page (404 Not Found) <?php if ("{$row['passState']}" == 0) { ?> <script language="javascript" type="text/javascript" > <-- var newwindow; function popupgo() { newwindow = window.open('check.php?quizTitle=<?php ".urlencode($quizTitle)."; ?>','_blank', 'scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> <?php echo "<form><input type='button' onClick='popupgo()' value='Popup'></form>"; } ?> when this test code works fine? Both files are PHP. <?php ?> <head> <script language="javascript" type="text/javascript" > <-- var newwindow; function popupgo() { newwindow = window.open('check/check.php?quizTitle=<?php '.urlencode($quizTitle).'; ?>','_blank', 'scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); if (window.focus) {newwindow.focus()} } //--> </script> </head> <body> <form> <input type="button" onClick="popupgo()" value="Popup"> </form> </body> <?php ?> Quote Link to comment https://forums.phpfreaks.com/topic/257282-php-url-in-javascript-gives-404-not-found/ Share on other sites More sharing options...
PaulRyan Posted February 19, 2012 Share Posted February 19, 2012 You aren't actually display the $quizTitle variable, you need to echo it out. Change this: <?php ".urlencode($quizTitle)."; ?> To this: <?php echo urlencode($quizTitle); ?> Also note the path change: (File 1) 'check.php?quizTitle=<?php '.urlencode($quizTitle).'; ?>' Compared to: (File 2) 'check/check.php?quizTitle=<?php ".urlencode($quizTitle)."; ?>' Regards, PaulRyan. Quote Link to comment https://forums.phpfreaks.com/topic/257282-php-url-in-javascript-gives-404-not-found/#findComment-1318776 Share on other sites More sharing options...
MMDE Posted February 19, 2012 Share Posted February 19, 2012 If you compare this line: newwindow = window.open('check.php?quizTitle=<?php ".urlencode($quizTitle)."; ?>','_blank', 'scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); and this line: newwindow = window.open('check/check.php?quizTitle=<?php '.urlencode($quizTitle).'; ?>','_blank', 'scrollbars=yes,top=0,left=0,width='+screen.width+',height='+screen.height); Are there not several differences? Quote Link to comment https://forums.phpfreaks.com/topic/257282-php-url-in-javascript-gives-404-not-found/#findComment-1318779 Share on other sites More sharing options...
facarroll Posted February 19, 2012 Author Share Posted February 19, 2012 Thanks for the help both friends. The path difference is intentional, because the files are held in different tsting folders. The suggested change did not alter anything. I'll keep trying a few things. Quote Link to comment https://forums.phpfreaks.com/topic/257282-php-url-in-javascript-gives-404-not-found/#findComment-1318785 Share on other sites More sharing options...
MMDE Posted February 19, 2012 Share Posted February 19, 2012 Thanks for the help both friends. The path difference is intentional, because the files are held in different tsting folders. The suggested change did not alter anything. I'll keep trying a few things. There are still more differences than just the path. Try to copy/paste the one working, and just change the path, because I tell you there are more than just that difference. Quote Link to comment https://forums.phpfreaks.com/topic/257282-php-url-in-javascript-gives-404-not-found/#findComment-1318788 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.