How to use mysql query in PHP
In this article I am going to explain about mysql_query function in PHP.
PHP mysql_query() Function
The PHP mysql_query function is used to execute any query statement in MySQL database.
Syntax of mysql_query function
mysql_query(query,connection) |
Parameters in mysql_query function
It have two parameter:
Parameter |
Description |
query |
It specifies sql query. |
connection |
It is optional parameter and it specifies a MySQL connetion. |
Example of mysql_query function
<?php
$con=mysql_connect("localhost","gupta","sharad");
if(!$con)
{
die("Could not connect:".mysql_error());
}
if(mysql_query("CREATE DATABASE testlog",$con))
{
echo "Database is craeted";
}
else
{
echo "Error creating database";
}
mysql_close($con);
?>
|
Output:

You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here