0
我既MySQL和PHP的一個初學者,我嘗試使用下面的代碼似乎沒有被任何有效果清理凌亂的桌子:如何在整個mysql數據庫上使用ucwords()php函數?
<html>
<head>
<title> Upper Case Words </title>
</head>
<body>
<?php
$con = mysql_connect("localhost", "root", "");
if (!$con)
{
die("Cannot Connect: " . mysql_error());
}
$sql = ("UPDATE customerstable
SET firstname = ucwords(strtolower(firstname));
UPDATE customerstable
SET lastname = ucwords(strtolower(lastname));
UPDATE customerstable
SET gender = ucwords(strtolower(gender));
UPDATE customerstable
SET reg_type = ucwords(strtolower(reg_type));
UPDATE customerstable
SET job_title = ucwords(strtolower(job_title));
UPDATE customerstable
SET address_type = ucwords(strtolower(address_type);
UPDATE customerstable
SET address1 = ucwords(strtolower(address1));
UPDATE customerstable
SET address2 = ucwords(strtolower(address2));
UPDATE customerstable
SET town = ucwords(strtolower(town));
UPDATE customerstable
SET county = ucwords(strtolower(county))");
$retval = mysql_query($sql, $con);
if (!$retval)
{
die("Could not update:" . mysql_error());
}
echo "Updated Successfully\n";
mysql_close($con);
?>
</body>
</html>
我已經花了几几小時試圖找出我在這裏做錯了什麼,我很欣賞我可能犯了基本錯誤......基本上我需要正確處理表中的所有單詞。任何幫助將不勝感激。
你不能在這樣 – kero
伴侶SQL語句中使用PHP函數,你的代碼是開發有危險開放。你應該真的考慮使用MySQLi,或者至少加強一點。 – ggdx
好的,謝謝你們......我猜我應該放棄這條路線,因爲我太離譜了。感謝指針@kingkero ... theres在MySQL中該線程中的有用鏈接。 – columb47