Jump to content

PHP url in Javascript gives 404 not found


facarroll

Recommended Posts

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
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.