Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在为电子商务网站构建一个管理套件。
但是,当使用相同的产品 ID 时,会显示以下消息:
错误:键“PRIMARY”的重复条目“14777”
有没有办法将此消息编辑为“此 ID 已在使用中,请尝试另一个 ID?
提前感谢
试试看:
$sql = "SELECT * FROM tbale_name WHERE ID='$id'"; $result = mysql_query($sql); $numRows = mysql_num_rows($result); if($numRows>0) { echo "This ID is already in use, please try another ID?"; } else { //Insert query here }