# Form's script can't conect to database

**URL:** <https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441>\
**Category:** Hosting Support\
**Created:** [December 12, 2023, 3:14pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441 "2023-12-12T15:14:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![surveys](https://forum.infinityfree.com/letter_avatar/surveys/32/6_449c533f586939b6e5f246632a46421f.png) [@surveys](https://forum.infinityfree.com/u/surveys)\
**Post date:** [December 12, 2023, 3:14pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/1 "2023-12-12T15:14:44Z")

</div>

[http://www.free-paid-surveys.info/newsletter\_signup.php](http://www.free-paid-surveys.info/newsletter_signup.php)

The page above is a form used by customers to sign up. The form is backed by a PHP script that stores customer’s data to a MySQL database created in my account at [infinityfree.com](http://infinityfree.com). The script filters customer’s data then connect and stores it to db.  
Script runs well until connection command when a white page shows up without any error mesage, and data get not stored in db.  
Please help me!

---

<div class="post-metadata">

**Author:** ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)\
**Post date:** [December 12, 2023, 4:56pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/2 "2023-12-12T16:56:18Z")

</div>

Hi and welcome to the forum

> [@surveys](#):
>
> a white page shows up without any error mesage

I had entered everything necessary on your form and when I clicked the button I saw error 500 in the browser console

So here are instructions on how to enable error reporting

> [@Http error 500](https://forum.infinityfree.com/t/49352):
>
> When trying to access your website, you may see a page which returns the status code “500”. In Google Chrome, you’ll see a page with the error code HTTP ERROR 500. There are typically two reasons which can cause this error: The PHP code has crashed. The .htaccess file contains invalid rules. Here are some things you can try to debug and fix this. Fixing crashing PHP code A HTTP ERROR 500 simply tells you that the PHP code has crashed, but gives no information as to why it has crashed. Gett…

---

<div class="post-metadata">

**Author:** ![surveys](https://forum.infinityfree.com/letter_avatar/surveys/32/6_449c533f586939b6e5f246632a46421f.png) [@surveys](https://forum.infinityfree.com/u/surveys)\
**Post date:** [December 12, 2023, 7:08pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/3 "2023-12-12T19:08:50Z")

</div>

Thank you for your peply! I will try your suggestions and will report the results.

---

<div class="post-metadata">

**Author:** ![surveys](https://forum.infinityfree.com/letter_avatar/surveys/32/6_449c533f586939b6e5f246632a46421f.png) [@surveys](https://forum.infinityfree.com/u/surveys)\
**Post date:** [December 14, 2023, 3:40pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/4 "2023-12-14T15:40:16Z")

</div>

I am back as I promised!

After all as a user of [infinityfree.com](http://infinityfree.com) hosting service I have no permissions to php.ini and server configuration files that may help. But there is a rule of hosting service that states:  
“… please note that it’s NOT possible to connect to the free hosting databases from outside the hosting platform. This means you cannot access the database from desktop or mobile applications directly, or use them in applications hosted elsewhere.”  
Now I am asking can it be the cause ?

---

<div class="post-metadata">

**Author:** ![Greenreader9](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/greenreader9/32/22847_2.png) [@Greenreader9](https://forum.infinityfree.com/u/Greenreader9)\
**Post date:** [December 14, 2023, 3:49pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/5 "2023-12-14T15:49:33Z")

</div>

If you are trying to connect to the database from outside of your domain name, then yes, that would be the cause.

---

<div class="post-metadata">

**Author:** ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)\
**Post date:** [December 14, 2023, 9:19pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/6 "2023-12-14T21:19:13Z")

</div>

By the way, review the code you have on this file  
because I don’t see closed `</body> </html>` anywhere

 ![Screenshot 2023-12-14 221134](https://forum-cdn.infinityfree.net/original/3X/f/1/f126ae2604961e84f382bcfade29d0611e7fc20b.jpeg)  
 ![Screenshot 2023-12-14 221325](https://forum-cdn.infinityfree.net/original/3X/5/0/50fc1defe7725e464fbd234ef8aec438f395030b.jpeg)

---

<div class="post-metadata">

**Author:** ![surveys](https://forum.infinityfree.com/letter_avatar/surveys/32/6_449c533f586939b6e5f246632a46421f.png) [@surveys](https://forum.infinityfree.com/u/surveys)\
**Post date:** [December 15, 2023, 1:32pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/7 "2023-12-15T13:32:59Z")

</div>

Thank your for your prompt and deep analyzing reply!  
Code elements you was lookingfor are in place, I tried to attache a screenshot but the system denies me.  
So the question remain, the database connection via the link above, is in or out of my domain? This can make an explanation ! Please help decide

---

<div class="post-metadata">

**Author:** ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)\
**Post date:** [December 15, 2023, 2:31pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/8 "2023-12-15T14:31:23Z")

</div>

> [@surveys](#):
>
> the database connection via the link above, is in or out of my domain

I can’t tell you which DB your PHP code is trying to connect to  
and it probably doesn’t succeed, that’s why you have error 500

in one of the posts above I gave you [instructions for error 500](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/2)

Did you do that ? and what did you see as an error after you enabled error reporting?

> [@How to connect with MySQL](https://forum.infinityfree.com/docs?topic=49340):
>
> Both the popular PDO and MySQLi libraries are available on all accounts and PHP versions, which are the libraries all (modern) scripts use to connect to a MySQL database. However, to use a database, you need to configure a few things first. Before you can use a database, you need to create the database first. You can create a database through your control panel in the section called MySQL Databases. Simply enter a desired name in the text box and click Create Database. To use the database with…

> [@Common MySQL Connection Errors](https://forum.infinityfree.com/docs?topic=49338):
>
> Many websites use MySQL databases to store information and settings. However, there are some reasons why the connection to the database may fail. This article describes some commonly seen error messages when connecting to a database, as well as some general tips to keep in mind when setting up a database connection. Common Error Messages Using MySQL is great, but the error message returned if there is an issue logging in to your database can be quite confusing. Here are some commonly seen error…

> [@Connecting to MySQL from an external application](https://forum.infinityfree.com/docs?topic=49339):
>
> Sometimes, you may want to connect to your MySQL database on your free hosting account using external software, like a desktop database manager (like MySQL Workbench) or an external program you wrote yourself (like an Android or iOS app). You cannot connect to a free hosting MySQL database from outside your hosting account. You can only interact with your free hosting database through PHP scripts uploaded to your free hosting account, or through our phpMyAdmin installation. The ability to con…

> [@How to setup a new MySQL Database](https://forum.infinityfree.com/docs?topic=49342):
>
> Many scripts require a MySQL database to work, and you will need to create a new database to use with your script. This article describes how to create a database and get the necessary settings for your script. Create a new database Before you can use a database, you need to create it first. Login to your client area and go to the Accounts list. Find your hosting account in the list and click Manage. Click the Control Panel button in the account overview page. Go to MySQL Databases. In the fi…

---

<div class="post-metadata">

**Author:** ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)\
**Post date:** [December 22, 2023, 2:31pm UTC](https://forum.infinityfree.com/t/forms-script-cant-conect-to-database/87441/9 "2023-12-22T14:31:52Z")

</div>

Closed on December 22, 2023, 2:31pm UTC

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