when I select a value on the previous page that is all numeric the page displays fine with the code below, but when I pick something like “testing” or “H70001” I get an error: Unknown column ‘H70001’ in ‘where clause’
The database table should be varchar and H70001 and “testing” are both stored in the table. Any clues what I’m doing wrong?
[php]
search.php <?php $con = mysql_connect("*","*","*"); $search_results=$_POST['ddtest']; $database="tms"; if (!$con) { die('Could not connect: ' . mysql_error()); } @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM tbl_Entry where serial_number=$search_results"; $result=mysql_query($query) or die(mysql_error()); $num=mysql_numrows($result); mysql_close(); ?> Insert New RecordsID | Serial Number | Description | Damage? | Damage Desc | pic_link | creation_date | created_by | last_update_date | last_update_by |
<?php echo $f1; ?> | <?php echo $f2; ?> | <?php echo $f3; ?> | <?php echo $f4; ?> | <?php echo $f5; ?> | <?php echo $f6; ?> | <?php echo $f7; ?> | <?php echo $f8; ?> | <?php echo $f9; ?> | <?php echo $f10; ?> |
<?php $i=0; while ($i < $num) { $ff2=mysql_result($result,$i,"serial_number"); ?> <?php echo $ff2; ?> <?php $i++; } ?> [/php]