What is the usage of the MySQL database?

Hello Everyone,
My name is Magnus. I want to ask about how to put data into the database just like we can receive the replies of interviewees in Google Forms. My aim is when someone completes the form on my website, I can get the results. I have tried to create a MySQL code script, but It does not work. Would you mind to tell me how to use the database for storing data and calling out the data? Thanks for your help!

I think this isn’t categorized as hosting support.

You can learn all of about it from Google.
For example: https://www.jotform.com/help/126-How-to-send-Submissions-to-Your-MySQL-Database-Using-PHP
Or you can ask directly on the right forum like StackOverFlow.

2 Likes

Dear adisp007,
Thanks for your reply and help, I have had a look at the website you gave to me and it is quite useful. However, I am asking about the method of inputting and retrieving the data by using the MySQL database provided by InfinityFree. Are the ones in InfinityFree have the same function as the common MySQL databases? Thanks for your help!
Regards,
Magnus

Yep, it supports PDO, $mysqli->functions() and mysqli_functions()

You mean like selecting data from mysqli database and displaying these? Or getting input data from form that we submit?

2 Likes

Dear BayoDino,
Thanks for your help.

My aim is when someone has finished the form on my website, the form’s information can be sent to the database. Also, when I want to know what the interviewees’ had chosen for the question, I can call out the data from the database for viewing the results.

I have read a book about PHP and MySQL codes and I discovered there is a way to create a chart of the form results. However, this project needs a .sql file and I cannot create that file. Would you mind to teach me the method of having a .sql file? The reason for needing this programming skill is I have to create a file to sore the programs like CREATE DATABASE voting and INSERT INTO voting VALUES can only work in the .sql file. Thanks for your help!
P.S.: ‘voting’ on the above is just an example.

A .sql file is no more than a text file with commands SQL commands to execute on a database. You can create a .sql file with any text editor. Even something simple like Notepad would work for this, or the file editor integrated with our file manager, although there are more advanced database development tools you could use as well.

However, .sql files are not typically used in PHP applications. You can’t feed a .sql file directly into a PHP function, and since these .sql files are typically written (or generated) statically, they kind-of defeat the dynamic part of a dynamic web application.

If you’re just looking to try out some SQL commands, you could also use our phpMyAdmin installation to manage your database. You can execute SQL statements in phpMyAdmin by typing them into the interface, or by loading your .sql file into it. But you can also manage your tables and their contents using the table editors and browsers integrated in phpMyAdmin.

Just one note: the query CREATE DATABASE voting would not work here. Databases have to be created through our control panel, and cannot be created from SQL. You can create tables and table contents from your own code, but due to permissions you have to use our interface to setup the initial database.

1 Like

Thank you very much for your advice!

However, I still have some questions:

Admin:

If you’re just looking to try out some SQL commands, you could also use our phpMyAdmin installation to manage your database. You can execute SQL statements in phpMyAdmin by typing them into the interface, or by loading your .sql file into it. But you can also manage your tables and their contents using the table editors and browsers integrated with phpMyAdmin.

Then, do you mean that I have to install the phpMyAdmin to input data into my database? or I can input data in another way? Like typing MySQL codes into the .php files?
If the way I suggested is workable, then the code will be like this:
<?PHP
$chosen=$_POST["chosen"];

define('DBHOST', 'sql---epizy.com');
define('DBNAME', 'epiz_--------_database');
define('DBUSER', 'epiz_--------');
define('DBPASS', '---------');

$conn = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME);
if(!$conn){
echo "Error connecting to the database: ".mysqli_connect_error();
exit;
}

$v_query="UPDATE poll_results
        SET num_votes=num_votes+1
        WHERE candidate?";`

$v_stmt=$db->prepare($v_query);
$v_stmt->bind_param("s",vote)
$v_stmt->execute();
$v_stmt->free_result();

$r_query="SELECT candidate, num_votes FROM poll_results"

?>`
If my suggestion is impossible to work, would you mind to teach me how to input data into the database? Thanks so much for your help!

Moreover, I cannot just put data into the database and leave them there. I may need to take a look at what is in my database and what knowledge I prefer to gain is the method of retrieving data. Would you mind to use a little bit of your time to teach me how to retrieve data? Can I know what is in my database without using the phpMyAdmin application? Thanks for your help!
Regards,
Magnus

You don’t have to install phpMyAdmin yourself. You can just click the phpMyAdmin buttons in the control panel to use our phpMyAdmin installation, where you can see your tables and their contents, and make changes to them.

Yes, that’s the way MySQL is normally used.

I’m not a particularly good teacher, nor do I have the time to teach you how to code personally.

But there are many tutorials available on the internet, free and paid, and written or in video, for new and experienced programmers. I’m sure you can find a tutorial which works for you too!

2 Likes