What is wrong with this?
| From: | Miguel Br�s | Date: | Mon, 24 Feb 2003 09:37:49 +0000 |
| Subject: | What is wrong with this? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-136865@lists.php.net to get a copy of this message | ||
Hi, here's the script
*****************************
<body topmargin="0" leftmargin="0" link="#0F057E"
vlink="#0F057E"
alink="#0F057E" bgcolor="#E6E6E6">
<table border="0" cellpadding="0" cellspacing="5"
style="border-collapse:
collapse" bordercolor="#111111" width="100%" id="AutoNumber153"
height="12">
<td width="43%" height="33" style="border-top-style: none;
border-top-width:
medium" bgcolor="#E6E6E6" valign="top">
<table border="0" cellpadding="0" cellspacing="10"
style="border-collapse:
collapse" bordercolor="#111111" width="100%" id="AutoNumber166"
height="52">
<td align="center">
<?
// includes
include("home/conf.php");
//logical request
if ($nome) {
$sql="aviao = '$nome' ";
}
if ($code) {
$sql="code = '$code' ";
}
// form not yet submitted
// display initial form with values pre-filled
$drop_down_list = "<select name=nome><option></option>";
$connection = mysql_connect($host, $user, $pass) or die ("Erro de execução.
Informe-nos sobre a situação!");
mysql_select_db($db) or die ("Erro de execução. Informe-nos sobre a
situação!");
$queryaviao="SELECT * FROM ssr ORDER BY aviao"; // sets up the find
$resultaviao = mysql_query ($queryaviao); // runs the find
$num = mysql_num_rows($resultaviao); //goes thru each row building the
display
for ($i = 0; $i < $num; $i++) {
$aviao = mysql_result($resultaviao, $i, "aviao");
$sk = mysql_result($resultaviao, $i, "sk");
$drop_down_list .= "<option value=$aviao>$aviao</option>";
}
$drop_down_list .= "</select>";
?>
<tr>
<td width="100%" height="42" align="center">
<p align="center">
<font face="Arial" size="4"
color="#527D74">Determinar
a Categoria da Aeronave</font><form method="POST" action="<? echo
$PATH_INFO
?>">
<p align="center">
<b><font face="Arial" color="#527D74"
size="2"><span
style="letter-spacing: 3">Aircraft model</span> </font><font
size="1"
face="Arial" color="#4F547A"><br>
</font></b><? echo "$drop_down_list"; ?>
<br>
<span style="letter-spacing: 3"><b><font
size="2"
face="Arial" color="#527D74">SBox
code</font></b></span><br>
<input type="text" name="code"
size="20"><table
border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse"
bordercolor="#111111" width="100%" id="AutoNumber167"
height="63">
<tr>
<td width="100%" height="63">
<p align="center"><input type="submit" value="search"
name="submit"> <input
type="reset" value="Reset" name="reset"></td>
</tr>
</table>
</form>
</td>
</tr>
<td align="center">
<?
// form submitted
// start processing it
if ($nome or $code)
{
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Erro de
execução. Informe-nos sobre a situação!");
// select database
mysql_select_db($db) or die ("Erro de execução. Informe-nos sobre a
situação!");
// generate and execute query
$query = "SELECT * FROM ssr WHERE";
$query .= $sql;
$resultado = mysql_query($query) or die ("Erro no pedido:
$querybusca. " . mysql_error());
$row = mysql_fetch_array($resultado);
$numrow = mysql_fetch_row($resultado);
$sq = $row["sk"];
$modelo = $row["aviao"];
if ($numrow > 0) {
// print result
?>
<p align="center">
<font size="4" face="Arial" color="#4F547A">The squawk code for
<? echo
"$modelo"; ?> is XXX<b><font color="#FF0000"><? echo
"$sq"; ?></font></b>
<?
}
else {
?>
<p align="center">
<font size="4" face="Arial" color="#4F547A">No aircrafts found
with the
supplied model<font size="2" face="Arial"
color="#4F547A"></font>
<?
}
mysql_close($connection);
}
?>
<body>
********************************
I receive this messages when trying to work with the script:
Erro no pedido: . You have an error in your SQL syntax near '= 'Airbus' ' at
line 1
Erro no pedido: . You have an error in your SQL syntax near '= 'CONC' ' at
line 1
Miguel