My site works in Wamp Server localhost but doesn't in InfinityFree

Username: epiz_31498110

Error Message

Actually, nothing happens at al. My code is writed in PHP. I was thinking that is because there is some sintax error. Something that Hosting doesn’t support.

Welcome!
You might want to share your code or website URL to get support …

4 Likes

What does “nothing” mean for you? A blank page? An error? All matter in the universe disappearing all at once?

The only time nothing happens is if you don’t visit your website at all. If you do, then something always happens.

So what does happen if you type the URL in your browser’s address bar and hit Go?

Have you tried confirming this thought by any chance? Checked the HTTP status code? Enabled display_errors on your site? Any other kind of investigation other than concluding that it doesn’t work?

5 Likes

First thing first in my code is to split a .txt file, which is inside a project folder and is a data input. I think this is the problem: nothing happens because the file isn’t beeing read in the first moment. This method is working fine in my local server, but not in Hosting. Do you now how to solve it?

Sharing all of your code is not practical.
Instead of posting code here, sharing your website (if you feel comfortable doing so) will help.
However, it might be better (if you are not comfortable with sharing your website) if you tell us what happens when you visit your site on IF, as admin has gloriously put.

Simply stating that it is “not working” does not really help us determine the problem at all.

1 Like

Index.php

<?php header('location: _html/Index/MainIndex.php'); ?>

MainIndex.php

<?php $txt_file = fopen('../../Outros Arquivos/dadosIndex.txt','r'); 
include '../ProcessamentoArquivo.php'; 
include '../MainPagina.php'; ?>

dadosIndex.txt

Tipo da Página: Tipo 3
Nome da Página: Página Inicial
Arquivo CSS: …/…/_css/MainIndex.php
Arquivo JavaScript: …/…/_javascript/MainIndex.js
Título Principal: Notícias
Conteúdo Específico: Index/ConteudoIndex.php

ProcessamentoArquivo.php

<?php $DadosPagina = array(); 
while ($line = fgets($txt_file)) { 
$DadosPaginaAntes = explode(": ",$line);
$DadosPagina[]=$DadosPaginaAntes[1]; 
unset($DadosPaginaAntes); 
}
fclose($txt_file); ?>

MainPagina.php

<?php if (trim($DadosPagina[0]) == "Tipo 1"){ ?>
<html lang = "pt-br">
		
		<head>
		    <meta charset="UTF-8"/>
			<title> <?php echo $DadosPagina[1]; ?></title>
	   	    <link rel = "stylesheet" type = "text/css" href = <?php echo $DadosPagina[2];?>>
	    </head>
        		 
	    <body>

	        <?php
			// Incluir Cabeçario
 	        include 'Cabecario.php';
		
			// Incluir Menu Lateral
			include 'Menulateral.php';
 	        ?>
		   
		    <section id = "Pagina">
		            
					<!-- Incluir o Título da página -->
		    		<div id = "TituloPagina"><h1><?php echo $DadosPagina[1];?></h1></div>
		
		   		 <!-- Incluir o Conteúdo da página -->
		    		<div id = "ConteudoPagina">
					
		   		        <?php $ConteudoEspecifico = substr($DadosPagina[4], 0, -2); include "$ConteudoEspecifico";?>
							
					</div>
            					
  	        </section>
			
			<!-- Incluir o Rodapé da página -->
		    <?php include 'Rodape.php';?>
					
 	    </body>
 
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
        <?php // Auxiliar na Construção da Pagina
        include 'Pagina.php';?>			
        <script language = "javascript" src = "<?php echo $DadosPagina[3]; ?>"></script>
		
</html>

<?php
}


// Construção do Modelo de Página 2
elseif(trim($DadosPagina[0]) == 'Tipo 2'){
?>

<html lang = "pt-br">

	<head>
	    <meta charset="UTF-8"/>
	    <title><?php echo $DadosPagina[1]; ?></title>
	    <link rel = "stylesheet" type = "text/css" href = "<?php echo $DadosPagina[2]; ?>">
	</head>

	<body>
        <?php 
		// Construção do Cabeçario
		include 'Cabecario.php';
       	?>
		
		<section id = "Pagina">
		
		    <!-- Incluir o Título da página -->
		    <div id = "TituloPagina"><h1><?php echo $DadosPagina[1]; ?></h1></div>
		
		    <!-- Incluir o Conteúdo da página -->
		    <div id = "ConteudoPagina">
		    <?php include "$DadosPagina[4]"; ?>				
			</div>
		
		</section>
		
		                		
		<!-- Incluir o Rodapé da página -->
        <?php include 'Rodape.php';?>
		
	</body>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
	<?php // Auxiliar na Construção da Pagina
	include 'Pagina.php';?>
	<script type="text/javascript" src="<?php echo $DadosPagina[3]; ?>"></script>
	
</html>
	
<?php
}	

// Construção do Modelo de Página 3
elseif(trim($DadosPagina[0]) == 'Tipo 3'){
?>

<html lang = "pt-br">

	<head>
	    <meta charset="UTF-8"/>
	    <title><?php echo $DadosPagina[1]; ?></title>
	    <link rel = "stylesheet" type = "text/css" href = "<?php echo $DadosPagina[2]; ?>">
	</head>

	<body>
        <?php 
		// Construção do Cabeçario
		include 'Cabecario.php';
		
		// Construção do SlideShow
		include 'SlideShow.php';
       	?>
		
		<section id = "Pagina">
		    
			<!-- Incluir o Título da página -->
		    <div id = "TituloPagina"><h1><?php echo $DadosPagina[4]; ?></h1></div>
			
			<!-- Incluir o Conteúdo da página -->
			<div id = "ConteudoPagina">
		    <?php include "$DadosPagina[5]"; ?>				
			</div>
		    			
		</section>
		
		<!-- Incluir o Rodapé da página -->
		<?php include 'Rodape.php';?>
			
	</body>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
	<?php // Auxiliar na Construção do Página
	include 'Pagina.php';?>
	<script type="text/javascript" src="<?php echo $DadosPagina[3]; ?>"></script>
	
	
</html>
	
<?php
}
?>
1 Like

http://renanzuba.lovestoblog.com/

I think some of your files were not uploaded. Can you verify that they’re all there?

2 Likes

Even if all the codes aren’t there, at least the homepage (index) should work. I carried out some investigations and the problem is that the text file is not being read.

First thing first in my code is to split a .txt file, which is inside a project folder and is a data input. I think this is the problem: nothing happens because the file isn’t beeing read in the first moment. This method is working fine in my local server, but not in Hosting. This is the code:

ProcessamentoArquivo.php

<?php $DadosPagina = array(); 
while ($line = fgets($txt_file)) { 
$DadosPaginaAntes = explode(": ",$line);
$DadosPagina[]=$DadosPaginaAntes[1]; 
unset($DadosPaginaAntes); 
}
fclose($txt_file); ?>

Is this path available (on server)?
What is the full path name?
If this path is referring to localhost, it will not work on this webhosting

2 Likes

This folder does not exist (green), and then neither does the txt file

In addition, do not name folders with space !
Even if the server serves folders with space in the name (without %20) some other code could break because of that, for example .htaccess .

How to Name Files/folders

For best results, you should only use the letters a-z, A-Z, the numbers 0-9, hyphens (-), underscores (_) and periods (.). Any other character could get you in trouble, causing the file not to load or the page to load incorrectly.
it is best to use lowercase letters, also Do Not Use Any Spaces.

P.S. delete all .bak files so that no one would look at your code

7 Likes

Thanks! The problem was the blank space! :grin:

I was curious that even with the white space it works on the local server. But ok, thanks again.

1 Like

Your local server is a development environment. So a lot of the restrictions and security settings that are applied to real servers are not applied to your environment. This is to make testing easier while using certain technology without having to install SSL or configure other things.

7 Likes

@WhiteTiger12323

Now create a .htaccess file at root (in htdocs)

and put this content in:

#Disable Directory Listings in this Directory and Subdirectories
Options -Indexes

so no one can view the contents of your folders.

It is recommended to do it via file manager from CA (monstaFTP)
because some other txt editors may add BOM or wrong charset (not UTF-8)



9 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.