Thanks for your quick response! I've licked the 'sql statement on-the-fly' problem (syntax errors, what else!), but now I'm experiencing something really frustrating. Maybe you can help:
I have a table, 'models', with a column, 'modelNo'. I can't seem to do a simple search with the following SELECT statement:
$sql="select * from models where modelNo = $modelNum";
'modelNo' is a column in the table 'models', and '$modelNum' is the variable passed by the html search form. I'm entering a valid, existing 'model number' when testing, but this statement keeps producing the 'Or Die....Bad Search' error.
When I telenet to the server and issue the exact same SELECT statement - substituting an actual Model Number for the variable $modelNum, such as: select * from models where modelNo = "SMC-06"; - mysql produces the correct results with no error.
I'll bet there is a real amateur mistake here, but I just can't seem to catch it. Once again, thanks in advance for any help you can offer!
Here's the (abbreviated) code for the HTML form and the PHP file it calls--
<head>
<title>Search</title>
</head>
<form method="post" action="testSearch.php3" name="searchOne">
<table width="621" border="0" cellspacing="2" cellpadding="2">
<tr bgcolor="#660000">
<td colspan="6">
<div align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF">QUICK
FIND</font></b></div>
</td>
</tr>
<tr bgcolor="#FFFFCC">
<td colspan="2">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="-1"><b>Search
By Model Number:</b></font></div>
</td>
<td width="215"> <font face="Verdana, Arial, Helvetica, sans-serif" size="-1">
<input type="text" name="modelNum" size="30">
</font></td>
<td colspan="3" width="160">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="-1">
</font><font face="Verdana, Arial, Helvetica, sans-serif" size="-1">
<input type="submit" name="FindBut" value="Find Model">
</font></div>
</td>
</tr>
</body>
Here's the testSearch.php3 code called by the above HTML page--
<?php
$session=mysql_connect("localhost","root") or die ("Bad connection");
$db = mysql_select_db("modelsDB", $session) or die ("Bad database");
$sql="select * from models where modelNo = $modelNum";
$sql_result = mysql_query($sql, $session) or die ("Bad search.");
echo "<Table border=1>";
echo "<TR><TH>Model Number</TH><TH>Frequency Low</TH><TH>Frequency High</TH><TH>Gain</TH><TH>Gain Flatness</TH><TH>Noise Figure</TH><TH>VSWR Input</TH><TH>VSWR Output</TH><TH>Output Power</TH><TH>DC Power</TH><TH>Volts</TH><TH>Drawing ID</TH></TR>";
while ($row = mysql_fetch_array($sql_result)) {
$modelNo = $row["modelNo"];
$freqLow = $row["freqLow"];
$freqHigh = $row["freqHigh"];
$gain = $row["gain"];
$gain_flat = $row["gainFlatness"];
$noise_fig = $row["noiseFigure"];
$vswrIn = $row["vswrIn"];
$vswrOut = $row["vswrOut"];
$outputPower = $row["outputPower"];
$DCpower = $row["DCpower"];
$volts = $row["volts"];
$drawingID = $row["drawingID"];
echo "<TR><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-2\"><TD>$modelNo</TD><TD>$freqLow</TD><TD>$freqHigh</TD><TD>$gain</TD><TD>$gain_flat</TD><TD>$noise_fig</TD><TD>$vswrIn</TD><TD>$vswrOut</TD><TD>$outputPower</TD><TD>$DCpower</TD><TD>$volts</TD><TD>$drawingID</TD></font></TR>";
}
echo "</table>";
mysql_free_result($sql_result);
mysql_close($session);
?>