Sending SQL Queries to a MySQL Database using the mysql_query () function : Database Query « MySQL Database « PHP






Sending SQL Queries to a MySQL Database using the mysql_query () function

<?php
  $host="mysql153.secureserver.net";
  $uname="java2s";
  $pass="password";
  $database="java2s";
  
  $connection= mysql_connect ($host, $uname, $pass) or die ("Database connection failed!");

  $result=mysql_select_db ($database) or die ("Database could not be selected");
  $query = "drop table if exists mytable";

  $result = mysql_query ($query) or die ("Query failed.");
?>

           
       








Related examples in the same category

1.List Database, Table, and Field
2.Listing All Rows and Fields in a Table
3.Get data from database query
4.Finding the Number of Rows Returned by a SELECT Statement with mysql_num_rows()