My project does not work here but on another host it does

When uploading the project to infinityfree it does not work correctly, there are errors that the files do not exist, there are places where the same code works and in others it does not and in all the pages you see the CORB error, where supposed content of origin was blocked crossed (everything is loaded in the same domain). Disable the ajax to see if it worked with pure php at least and it skipped error 500. Change the code as much as I could in my understanding. Today I tried another host: 000webhost and everything works, but everything. Not a single error, maybe any due to my poorly optimized code, but everything works and it’s not slow.

What is this about? Should I enter code in .htaccess? I am a newbie, sorry if it is obvious what I propose but I want to learn.

Username (e.g. epiz_XXX) or Website URL

https://feisbuk.rf.gd/

Error Message

1 Like

I think this code works:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET,PUT,POST,DELETE"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"

Put it in your .htaccess file.

1 Like

Can you share some URLs on your site where a certain shared resource does and doesn’t work? If you know where the issue occurs, it would help a lot if you could just tell us instead of having us hunt for the errors ourselves on your site.

The CORS error is normal, because our 404 error page cannot be embedded into other pages. It’s not a CORS issue on your website. Once you fix the 404 errors, that error will disappear too.

What do you mean by this? Can you please provide steps on how we can reproduce this?

My best guess is that it’s a different path through your code which bypasses the bug that causes the page to crash.

I already tried that … among many other things, nothing changes :frowning:

Thanks for the clarification with CORS. It helps me a lot. About ajax, I mean that to check that the request itself was not the error hide the code, letting it work with pure php. When I did this I figured that the file I was looking for did not exist, so I deleted all the code from the php file and added an echo to check: it worked, the echo was displayed. Then I tried with die (json_encode ($ _ POST)) it worked. When I implement a query with try {} catch {} or without it, the error would appear again.
The worst thing is that the same php file works in other internal pages and actions.

Try entering this account:
admin0
123123
On the internal page of your profile in this case: https://feisbuk.rf.gd/perfil.php?usuario=TheGirl
You should be able to see your posts (SELECT), but this does not happen. But if you try to publish if you can do it (INSERT INTO). And the queries come from the same file. I am telling you this to illustrate why it works in one case and not in another. The url of the php file is https://feisbuk.rf.gd/funciones/modelo-publicacion.php

And I still don’t understand why it works on another host with the same code :frowning:

this file returns 404 ( →)

image

and returns 404 because it is looking for a file named

and such does not exist



URL: https://feisbuk.rf.gd/funciones/sesiones.php?i=1
Host: feisbuk.rf.gd
IP: 185.27.134.142
Error/Status Code: 302
Priority: Highest
Protocol: HTTP/2
Initiated By: https://feisbuk.rf.gd/funciones/sesiones.php line 0 column 631



URL: https://feisbuk.rf.gd/funciones/login.php
Host: feisbuk.rf.gd
IP: 185.27.134.142
Error/Status Code: 302
Priority: Highest
Protocol: HTTP/2
Initiated By: https://feisbuk.rf.gd/funciones/sesiones.php line 0 column 631


image



This is probably the reason you get 500 on click on button.

If you have that login.php file then upload it in that DIR :slight_smile:

3 Likes

As you say that file is not in that location … however all the code for sessions works correctly. If there is no session, it will return to login.php and that works.

<?php
function usuario_autentificado(){
    if(!revisar_usuario()){
        header("location:login.php");
        exit();
    }
}
function revisar_usuario(){
    return isset($_SESSION["usuario"]);
}
session_start();
usuario_autentificado();

sesiones.php ↑↑↑

As I said, in another host the same code works without any problem :frowning:
I dont understand that

Where is this file?

Please think before you answer.

2 Likes

I am saying that it is in another location in the same domain. It is the page that contains the entry form. It works I can use the accounts that I create.

I repeat the same code works on another host :confused:

Please clear your cache.

2 Likes

OK, I spent too much time debugging this, and I think I understand what’s going on here.

This issue seems to be caused by a configuration flaw in our PHP setup to talk to MySQL. This results in data corruption if you read and write data both through phpMyAdmin. We would like to fix this but can’t do so without breaking many other sites, which leaves us in a bit of a bind.

To fix this, you need to manually set the MySQL connection charset in your database code. I see you’re using MySQLi, so you can use this function: PHP: mysqli::set_charset - Manual

You’ll probably want to set this to utf8mb4.

If you still get problems after that, please check the relevant records and tables in phpMyAdmin too. If you see any garbled characters there, you’ll need to fix those first.

3 Likes

I did :confused:

Thank you very much, it seemed to me that it was a mistake of this type. Right now I will try to configure it :slight_smile:

3 Likes

I just added the function that you told me and now everything works without errors … thank you very much for your time :smiley: :smiley: :smiley: :smiley:

2 Likes

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