Hostname47 / PHP-CHAT

66 stars 57 forks source link

Chat are empty #6

Open spcyurie opened 1 year ago

spcyurie commented 1 year ago

image

LeeGoTech commented 1 year ago

Same. I'm experiencing the same issue.

LeeGoTech commented 1 year ago

Please fix @Hostname47

Hostname47 commented 1 year ago

@spcyurie , @DanTech2002 Sorry for late response, Have you checked the database after sending the message, everything is working on my end. I don't know why you get blank, I need to know what you changed in the code and the version of PHP you're using and other stuff. Please try to use the same PHP version and migrate the database and follow every step in the video and everything will be working

LeeGoTech commented 1 year ago

I didn't change any code. If that's the case, may I know the version of PHP and XAMPP you are using?

Untitled untitled1

LeeGoTech commented 1 year ago

I tried on PHP 7.4.33. I got this error, but the database is working fine now. @Hostname47

4

5

Hostname47 commented 1 year ago

The version of PHP used in this project is 7.4, XAMPP version does not matter, as long as the apache server is running, the problem is not from the server software.

Now that the database is filled, you can investigate the layout/chat/ChatComponent and see why the message is not there, It's a long time ago since I realized this project. Try to echo the message and the parent component until you find the error

LeeGoTech commented 1 year ago

I tried echoing it and here's the error "bool(false) boolean". I'm using the code "var_dump($message); echo gettype($message). Can you fix this for me bro? I can't fix this. I'm new on PHP programming language. @Hostname47

6

LeeGoTech commented 1 year ago

I tried also on PHP 8.2.

In PHP 8.2, it shows "object(stdClass)#10 (6) { ["id"]=> int(54) ["message_creator"]=> int(1) ["message"]=> NULL ["create_date"]=> string(19) "2023-05-08 23:41:51" ["is_reply"]=> NULL ["reply_to"]=> NULL } object"

but in PHP 7.4, it shows "bool(false) boolean".

Hostname47 commented 1 year ago

PHP 8 has lot of breaking changes, that's because some things in previous versions are not longer working in newer version. The problem really is not in message variable, If you go to ChatComponent in layout/chat you'll see in the row 101 that the message is passed as argument to generate_current_user_message function.

Think about that as a requirement: Go to chat page (chat.php) and try to figure out what is wrong there. Because in ChatComponent, it wasn't able to get the message and id, because either the parent object is null or undefined.

I'll try to find some time and check what's wrong, because as far as I can remember, The whole project was working on my side when I was working on it