How do I set up a server that JavaScript can access?

I have a 000webhost account and I have set up a database using the phpmyadmin system. How do I make it so that I can read and write to this database from another website? I don’t even know if this is possible, but if it is I assume I’ll need an API link.

Thanks for any help.

Hi @truccavexx
Well I am not sure but I think it is not possible. You can access your database phpmyadmin from either your cpanel or directly from databases.000webhost.com

There’s (usually) no problem doing this, it just involves a tiny bit of work.

First you’ll have to create a php file on the 000webhost server that connects to the database.
Then you’ll have to make php respond to the input from the JavaScript.

The popular way of doing this, is to make a RESTful API in PHP

You may get some error trying to access the 000webhost, because of some Allow-Origin header on the server, this may or may not create some issues.

However, usually the fix is simple, just head to stackoverflow and get some help (hint, I found it for you)

If all fails, there might be some server settings, that you don’t have access to, that blocks this access.

1 Like