Found 4381 Articles for MySQL

How can we create a new database by using PHP script?

Nancy Den
Updated on 22-Jun-2020 13:34:56

155 Views

As we know that PHP provides us the function named mysql_query to create a new database.ExampleTo illustrate this we are creating a database named ‘Tutorials’ with the help of PHP script in the following example −           Creating MySQL Database                  

Which PHP function is used to create a new database?

radhakrishna
Updated on 22-Jun-2020 13:22:24

156 Views

PHP uses mysql_query function to create a MySQL database. This function takes two parameters and returns TRUE on success or FALSE on failure. Its syntax is as follows −Syntaxbool mysql_query( sql, connection );ExampleFollowings are the parameters used in this function −S. No.Parameter & DescriptionSqlRequired - SQL query to create a MySQL databaseconnectionOptional - if not specified, then the last opened connection by mysql_connect will be used.

Write an example to establish MySQL database connection using PHP script?

Krantik Chavan
Updated on 22-Jun-2020 13:22:49

169 Views

We can use following PHP script to make a MySQL database connection having user ‘guest’ and password ‘guest123’.           Connecting MySQL Server                  

Which PHP function is used to disconnect from MySQL database connection?

Daniol Thomas
Updated on 22-Jun-2020 13:24:29

291 Views

PHP provides us mysql_close() function with the help of which we can disconnect from the MySQL database anytime. This function takes a single parameter, which is a connection returned by the mysql_connect() function. Its syntax is as follows −Syntaxbool mysql_close ( resource $link_identifier );Here, if a resource is not specified, then the last opened database is closed. This function returns true if it closes the connection successfully otherwise it returns false.

Which PHP function is used to establish MySQL database connection using PHP script?

mkotla
Updated on 22-Jun-2020 13:23:44

223 Views

PHP provides mysql_connect() function to open a database connection. This function takes five parameters and returns a MySQL link identifier on success or FALSE on failure. Its syntax is as follows −Syntaxconnection mysql_connect(server, user, passwd, new_link, client_flag);Following table give us the parameters used in the syntax above −Sr.NoParameter & Description1ServerOptional − The host name running the database server. If not specified, then the default value will be localhost:33062UserOptional − The username accessing the database. If not specified, then the default will be the name of the user that owns the server process3PasswdOptional − The password of the user accessing the ... Read More

How can MySQL work with PHP programming language?

Giri Raju
Updated on 20-Dec-2019 06:25:34

717 Views

MySQL works very well in combination with various programming languages like PERL, C, C++, JAVA, and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities.PHP provides various functions to access the MySQL database and to manipulate the data records inside the MySQL database. You would require calling the PHP functions in the same way you call any other PHP function.The PHP functions for use with MySQL have the following general format –mysql_function(value, value, ...);The second part of the function name is specific to the function, usually a word that describes what ... Read More

How can we see the list of views stored in a particular MySQL database?

Chandu yadav
Updated on 17-Feb-2020 08:54:10

184 Views

With the help of following queries,  we can see the list of views stored in a particular database. We are using the database named ‘query’ here.mysql> SELECT TABLE_NAME FROM information_schema.`TABLES` WHERE TABLE_TYPE LIKE'view' AND TABLE_SCHEMA LIKE 'query'; +-----------------------------+ | TABLE_NAME                  | +-----------------------------+ | customer_view               | | first_view                  | | info                        | | info_less                   | | view_detail   ... Read More

How can we modify the definition of a MySQL view without dropping it?

Kumar Varma
Updated on 22-Jun-2020 13:31:43

188 Views

With the help of ALTER VIEW statement, we can modify the definition of MySQL view. In this case, we do not need to drop it. The syntax would be as follows −SyntaxALTER VIEW view_name AS SELECT column1, column2… FROM table WHERE conditions;ExampleTo illustrate it we are modifying the definition of a view named ‘Info’ which have the following data −mysql> Select * from Info; +------+---------+------------+ | Id   | Name    | Subject    | +------+---------+------------+ | 101  | YashPal | History    | | 105  | Gaurav  | Literature | | 125  | Raman   | Computers  | | ... Read More

After updating any value in a particular view, will MySQL updates the same in the base table and its associated views (if any)?

Moumita
Updated on 22-Jun-2020 13:30:40

89 Views

Yes, MySQL will update the value, if it is updated in a view, in the base table as well as in its associated views. To illustrate it we are taking the example of table Student_info having the following data −mysql> Select * from student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Chandigarh | Literature | | 125  | Raman   | Shimla     | Computers  | | NULL | Ram     | Jhansi   ... Read More

How can we update any value in MySQL view as we can update the values in MySQL table?

karthikeya Boyini
Updated on 22-Jun-2020 13:32:30

478 Views

As we know that with the help of UPDATE statement we can update the values in MySQL table and in the similar way we can update the values in MySQL views. The syntax of UPDATE statement would be the same except at the place of table name we have to provide the name of the view. We are taking the data as follows from a view named ‘Info’ to illustrate the above concept −mysql> Select * from Info; +------+---------+------------+ | Id   | Name    | Subject    | +------+---------+------------+ | 101  | YashPal | History    | | 105 ... Read More

Advertisements