<?php
$sn=$_GET['sn'];
$query="SELECT * FROM `banner_ad` WHERE `banner_no`='$sn'";
if($query_run=mysql_query($query))
{
$num=mysql_num_rows($query_run);
if($num == 1)
{
while($rows=mysql_fetch_array($query_run))
{
$banner_name=$rows['banner_name'];
//$banner_site_url=$rows['Banner_website_url'];
$banner_image_url=$rows['banner_image_url'];
}
} else {
echo'<font color="red"> There is two entry for this same serial number.</font>';
}
} else {
echo'<font color="red"> Query does not run.</font>';
}
?>
Can anyone tell me what I am unable to execute this query?
1) It doesn’t appear that you are connecting to any database.
2) You’re using
mysql_functions which are being deprecated and leave you open to SQL injection. You should immediately stop using it to write new code and usemysqli_orPDOfunctions.3) You need to append
mysql_error()to catch any possible errors. Perhaps something like this:4) It is poor practice to
SELECT *. You should always specify a column list.