How to connect PHP Telegram bot to mysql database?

Hi all. Did the bot guides on pure PHP API.
All hooked up via github and heroku, everything works on the webhook.
The only problem I can not connect to the database.
Is this process from conventional to connect web page to database?
Please tell me how to do it?
Thank you in advance!
59d268390e174576563095.png
June 14th 19 at 20:16
3 answers
June 14th 19 at 20:18
and the link to the guides)? also teach pihu.
https://core.telegram.org/bots/api
Working with the api - just making http requests, json processing and all. Next comes the logic of your bot. - jaunita_Yun commented on June 14th 19 at 20:21
June 14th 19 at 20:20
Is this process from conventional to connect web page to database?

Of course, no different. Bot this is just the app/program.
Do as well as when developing, for example, sites.
And why then here is the script connects my site to the database, but the bot telegram that the screenshot above does not connect?
$connection = mysqli_connect('localhost','id3120188_dbtelega_user','PASS','id3120188_dbtelega_baza');

if($connection == false)
{
 echo 'failed to connect to database';
 echo mysqli_connect_error();
exit();
}
- jaunita_Yun commented on June 14th 19 at 20:23
June 14th 19 at 20:22
Is this process from conventional to connect web page to database?

And what makes you think that it is not "page"? That's exactly it - webhook for messages from the Telegram is treated the same as any other queries.
If interested, you can see an example of the implementation of the bot I have here. However, it uses Symfony and wrapper for Telegram Bot API rather than raw queries.
I just rollpak most likely, doing something wrong :) - jaunita_Yun commented on June 14th 19 at 20:25
Yes, most likely. Use the debugger (xdebug). - madeline_Conn commented on June 14th 19 at 20:28
And why then here is the script connects my site to the database, but the bot telegram that the screenshot above does not connect?
$connection = mysqli_connect('localhost','id3120188_dbtelega_user','PASS','id3120188_dbtelega_baza');

if($connection == false)
{
exit();
}
- madeline_Conn commented on June 14th 19 at 20:31
I do not know. I'm not a mind reader. Look at the error. - Justice.Nienow commented on June 14th 19 at 20:34

Find more questions by tags MySQLPHPTelegram