Jump to content

php code run 100% in localhost, but in cpanel no


linuxfreakphp

Recommended Posts

hey guys i have a problem with the next code.

 

i wrote, but i have the same problem in this version as well.

	$path2 = basename($_REQUEST['path']);	
	$number = $_REQUEST['number'];
	// case 1:
	if($_REQUEST['number2']==1)
	{
		$temp = stripos($_REQUEST['path'], '/e/');
		if($temp==true)
		{
			$path='h';
		}
		else
		{
			$path='e';
		}
		echo '../' . $path . '/' . $path2;
	}

now in the localhost-127.0.0.1 it is working great but in the cpanel the real site no why? php version may be?

 

the code build to switching between languages interfaces and again it is working fine under localhost and the problem is only in the cpanel.

 

i tried this one as well (those codes do the same thing) just to test it in the local host and the cpanel and the problem is repeating:
 

    $path2 = basename($_REQUEST['path']);    
    $number = $_REQUEST['number'];
    // case 1:
    if($_REQUEST['number2']==1)
    {
        $temp = stripos($_REQUEST['path'], '/e/');
        if($temp==true)
        {
            $path='h';
        }
        else
        {
            $temp = stripos($_REQUEST['path'], '/h/');
            if($temp==true)
            {
                $path='e';
            }
        }
        echo '../' . $path . '/' . $path2;
    }
Edited by linuxfreakphp
Link to comment
Share on other sites

it would be helpful if you explained what it is supposed to be doing and what it is not doing in less abstract/arbitrary terms. Saying "It works in one place but not another" isn't helpful. Saying "switch languages in interface" means nothing to anybody except you. What is the code physically supposed to be doing, altering a variable? show a "before", expected "after" and reality "after", etc.

Link to comment
Share on other sites

for .josh

hey i gave the php code  but here is the folders and files map.

 

site address folder:

->index.php (redirect into  one of index file "h" or "e when the user enter the site using the user ip address country. this part is working only in the cpanel in real site because localhost have not country ip.)

->e (755)

              ->index.html

              ->page2.html

              ->page3.html

              ->page4.html

->h (755)

              ->index.html

              ->page2.html

              ->page3.html

              ->page4.html

->private (755)

              ->css (755)

              ->php (755)

                       ->index.php (this is the code i have post in the message when the values are getting from index.js with ajax and i need help with him.)

              ->js (755)

                       ->index.js

              ->img (755)

 

now the code i post is switching languages by checking if the current page is found in "e" or "h" by checking the path of the page and redirect it into the same page but in the other language folder.

 

$_REQUEST['path'] is sent from index.js with ajax and command: window.location.pathname (client side) to the php file (server side).

on the local host the code is working great,but on the real site it is not working ok.

$_REQUEST['number'] and $_REQUEST['number2'] send to index.php with $_REQUEST['path'] in the same function.

 

for a sample let just say i'm in "nevermindthesitename/e/index.html" this code must redirect me into "sitename/h/index.html".

sample with "h" if i'm located in "page2.html" inside "h" the code must redirect me into page2.html but in folder "e".

 

for objnoob:

the localhost run with apache and real site that run with apache and cpanel working with linux operating systems.

 

for gristoi:

tried what you have wrote, but it is not helping in this case.

Link to comment
Share on other sites

 


hey i gave the php code  but here is the folders and files map.

 

Yes, you gave the php code. I can read your code just fine. But clearly it's not doing what it's supposed to be doing, seeing as how you are on this forum telling us it doesn't work.  But without explaining what you expect the code to be doing, we can't really do anything beyond pointing out syntax errors, which any monkey can do by paying attention to whatever the php error handler screams about.  And since it's pretty clear that this is only part of your code, there could be any number of other things adversely affecting the code you posted, that we would have no idea about because you didn't post all of your code.  We aren't psychic.  So, the best way to move forward is for you to a) post relevant code (which you presumably did), b) explain what it is the code is supposed to be doing, c) explain what it is doing instead, because we don't know the whole picture.

Link to comment
Share on other sites

the full code with explaining .josh:

 

javascript code:

	function myajaxFunction(str, str2, number, number2)
	{
		try
		{
			var url = new String;
			var url = './../private/php/index.php?number=';
			var url2 = new String;
			var url2 = '&path=';
			var url3 = new String;
			var url3 = '&number2=';
			loadXMLDoc(url, url2, url3, str2, number, number2, function(){
				if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
					try
					{
						document.getElementById(str).innerHTML = xmlhttp.responseText;
					}
					catch(err)
					{
						error_function(err);
					}
				}
			});
		}
		catch(err)
		{
			error_function(err);
		}
	} 
	function trackv(str,number1,number2)
	{// number is number in the php page and number2 is number2 in the php page. 
		try
		{
			var str2= new String;
			str2 = window.location.pathname; // getting the path to the php page with javasript
			myajaxFunction(str, str2, number1, number2);
		}
		catch(err)
		{
			error_function(err);
		}
	}

html code:


<!-- links to the same page but in a second language: -->
<div id='c_language' class='languages' ></div>
<!-- default language  or chosen language by user, but this div is not doing nothing-->
<div id='nc_language' class='languages' onclick='trackv("nc_language", "0","1");' ></div>
<!-- my problem,  sending a command to js that active the php page with ajax to switch
the language, when  "1" is number2 in the php and "0" is number -->

<!-- links into another page in the same language: -->
<div id='title_op1' class='title_op' onclick="trackv('title_op1','1','0');" >index</div>
<div id='title_op2' class='title_op' onclick="trackv('title_op2','2','0');" >page2</div>
<div id='title_op3' class='title_op' onclick="trackv('title_op3','3','0');" >page3</div>
<div id='title_op4' class='title_op' onclick="trackv('title_op4','4','0');" >page4</div>

the full php code:

	if($_REQUEST['number2']==1)  // link to a second language to the same page.
	{
		$temp = strpos($_REQUEST['path'], 'enpath');
		if($temp==true)
		{
			$path='hbpath';
		}
		else
		{
			$path='enpath';
		}
		echo '../' . $path . '/' . $path2;
	}
	else if($_REQUEST['number2']==0) // link another page but in the same language
	{
		$path = dirname($_REQUEST['path']);
		if($number == '1')
		{
			echo 'index.html';
		}
		else if($number == '2')
		{
			echo 'page2.html';
		}
		else if($number == '3')
		{
			echo 'page3.html';
		}
		else
		{
			echo 'page4.html';
		}
	}
/* i have another case and that why i used "else if" and not just else when number2 is telling 
the php code where to go and what to do.*/

now you can see how  this code is working and you can see all the code.

 

explaining about the code and what his doing:

this code allow the user to move between two languages to the same page in the other language and to another page in the same language. let say page3 to page4 in 'enpath' or move to page3 of 'hbpath'.

 

 

--------------------------------------------------------------------------------------------------------

 

i found the problem.

$temp = stripos($_REQUEST['path'], '/e/');

i told it to searched a special character as '/' in the command and it is not working.

i searched in google and checked the if $temp is getting something and his not getting nothing on the site (cpanel), but when i change folder name e into 'enpath' and searched:

$temp = stripos($_REQUEST['path'], 'enpath');

$temp do get value i need and the code is working cpanel real site and the localhost.

 

how can i use special characters in text functions as i did in this case if i need to find this string or someting else with special characters???

'/e/' , '/h/' , '$?/la?/'

this way failed on my server.

Edited by linuxfreakphp
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.