How to execute SQL Query in PHP

To execute SQL Query in PHP, following code snippet can be used:

.......
.......
define("DB_HOST", "localhost");
define("DB_USER", "test");
define("DB_PWD", "test123");
if($conn = @mysql_connect(DB_HOST, DB_USER, DB_PWD))
{
$result = @mysql_query("SELECT port FROM local_servers WHERE canuse = 1");
$row = @mysql_fetch_row($result);
if (@mysql_num_rows($result) > 0)
{
.......
.......
}
.......
.......
}
.......

Hope the information presented here is useful. Please leave your suggestions, feedback or queries in the comments section below…!!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">