Jump to content

[!!911!!] Most bizarre issue I have ever encountered with php....


this.user

Recommended Posts

I have three files:

 

/index.php

/include/index.php

/include/ajax.php

 

the /index.php page is the landing page, which includes the file /include/index.php

 

once the page loads, I make ajax calls to /include/ajax.php

 

 

here is what the files basically looks like:

 

index.php

<html><body><? include('include/index.php'); ?></body></html>

 

include/index.php

<?
session_start()
unset($_SESSION['team']);
$_SESSION['team'] = '9';

 

 

include/ajax.php

<?
session_start()
$_SESSION['team'] = $_SESSION['team'] . ',9';

 

Pretty simple right?

 

However, here is what is happening, every time I make a call ajax call to /include/ajax.php, the code in /include/index.php also gets executed and team is reset to 9!

 

I am using jquery to make the ajax call:

 

$("input:radio").live('click', function()
	{
		$.ajax(
            {
                    url:'include/ajax.php',
                    success: function (data)
                    {
                      alert('done');                                             
                    }
            });
});

 

and when I view the value after each ajax call, it is set to just 9.

 

This is not any other issue, other than the code in include/index.php being executed each time the ajax function is called.

 

Why in the world is the code in include/index.php being execute?! Under what circumstance would such a thing occur?

Link to comment
Share on other sites

and what is the output? Is it showing:

 

9,9

 

Have you tried to change /include/index.php to something else like /include/main.php

 

The index.php script is run upon request to that particular directory. Whether in your ajax call it is requesting that directory before or after (not just the ajax.php file) could lead to the problem.

 

Try to change the index.php name so there is no index.php in your include folder (which you shouldn't need anyway - it isn't descriptive at all of what the script holds).

Link to comment
Share on other sites

How exactly do you even know it is being executed?

 

The the ajax I posted is stripped down, I am returning a json value, in which I have dumped the session variable.

 

and what is the output? Is it showing:

 

9,9

 

Have you tried to change /include/index.php to something else like /include/main.php

 

The index.php script is run upon request to that particular directory. Whether in your ajax call it is requesting that directory before or after (not just the ajax.php file) could lead to the problem.

 

Try to change the index.php name so there is no index.php in your include folder (which you shouldn't need anyway - it isn't descriptive at all of what the script holds).

 

yes it is showing, '9,9' no matter how many times I call the ajax.

 

 

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.