hii all..i有一些代码使得输入到DB的所有字符串字符都变为大写字母..这是我的代码:
function newinputdata($modelnm,$serialno)
$Model=mysql_real_escape_string($modelnm);
$Serial_number=mysql_real_escape_string($serialno);
$str=strtoupper($str)
echo $str;
$sql="INSERT INTO.........";
是真的吗?
答案 0 :(得分:1)
嗯,这不起作用,因为你没有定义$str
改为:
$Model = mysql_real_escape_string($modelnm);
$Serial_number = mysql_real_escape_string($serialno);
$Model = strtoupper($Model)
$Serial_number = strtoupper($Serial_number);
当然,这假设$Serial_number
包含字符,否则将其大写(并使用mysql_real_escape_string
转义它,将其转换为int
)
答案 1 :(得分:0)
是,
$str=strtoupper($str);
答案 2 :(得分:0)
您的代码没有意义,但假设您想要将放入数据库的所有内容更改为大写,您可以这样做:
function insert_data($model_number, $serial_number) {
$model_number = strtoupper($model_number);
$serial_number = strtoupper($serial_number);
$values = "'" . mysql_real_escape_string($model_number) . "',"
. "'" . mysql_real_escape_string($serial_number). "'";
$q = "INSERT INTO dataTable `modelColumn`, `serialColumn` values ($values);"
echo "I would run the query $q";
}
当然要替换表名和列名来尝试:)