<?php
$host="localhost";
$user="root";
$pass="pwd";
$my_db="test";
$my_tb="test";
$post="60-1000";//假设这是post传送过来的值
$row1=array();
$row1=explode("-",$post);//post分成两段分别是$min=60,$max=1000;
$min=$row1[0];
$max=$row1[1];
//echo "min=".$min." "."max=".$max;exit;
$con=mysql_connect($host,$user,$pass);//临时测验数据库连接
if(!$con){
die('could not connect'.mysql_error());
}
mysql_select_db($my_db,$con);
$sql="select *from test where and num> $min and num< $max";//问题部分
//echo $sql;
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
echo $row['num'];
echo "<br/>";
}
mysql_close($con);?>如果$min和$max的每个位都是1-9之间的话数据库是正常,不会报错
如果掺和了字母就会报错,有什么办法给他验证一下或者,不让他报错此问题测验test名数据库下的test表下的num字段,格式为string