Wednesday, 28 December 2016

(Year 3 Sem C ) Week 7 Working on Database Part 1

Today, I decided to start and work on MySQL database again. In this moment, I am still confused about the relationship between MySQL, Cpanel, and PHPadmin.  Therefore, I decided to ask Hui San about them. From her explanation, I get to know that Cpanel is page where create a database while PHPadmin is a database that created to store data. Below is the step that I followed the tutorial on how to create database: 




The database has successfully created and continue to the next stage.


Now I try to apply PHP code in HTML to work on the data storing function. 





I also have tried to keep testing and debugging the code. I have applied  "My first PHP script" in the PHP code. But, the file failed to appear.After that,it is showed after I remove the /public HTML/ function.



Before connected to the database, I will have to make sure the PHP file also connected with  MySQL server (PHPadmin ). By that, I will need to connect to my localhost, username, password and the created database. To make sure the file is connected with the server, I decided to write code as below: 
      
      echo 'connected successfully ';
      
The word is showed and it means the data is connected. Therefore, I started to insert data in the PHP file. 



To make sure the data can be inserted into the database , I have applied code such as below:

 echo  ' data inserted successfully ';

The words is showed but the data failed to inserted in the database. 


Besides, I also feel thankful to Hui San because  she keep teaching me on how to solve the error and how to apply code in the PHP. Thank you Hui San!:) 


Reference:
YouTube. (2016). MySQL Database Tutorial - 3 - Creating a Database. [online] Available at: https://www.youtube.com/watch?v=O4SIpJMH7po&index=3&list=PL32BC9C878BA72085 [Accessed 28 Dec. 2016].

YouTube. (2016). PHP MySQL Contacts Database - Setup - YouTube. [online] Available at: https://www.youtube.com/watch?v=O9HamXxGzls [Accessed 28 Dec. 2016].

YouTube. (2016). create MySQL database, tables and insert data using PHP functions. [online] Available at: https://www.youtube.com/watch?v=5QHBj4brHNM [Accessed 28 Dec. 2016].

YouTube. (2016). Creating and adding data to a database PHPMyAdmin. [online] Available at: https://www.youtube.com/watch?v=eWMTXEZGZTc [Accessed 28 Dec. 2016].

No comments:

Post a Comment