How to Capitalize the First Letter in Every Word in Mysql
Hi,
I have been trying to tidy up a massive database where visitors have been sloppy when entering text. The main thing I want to do is to Capitalize The First Letter In Every Word In Mysql.
I have found the code below in PHP but it keeps finding an error on the WHILE line:
<?php ini_set('display_errors', '1'); ?>
<?php require_once('Connections/maison_connection.php'); ?>
<?php
$result = mysql_query ("SELECT column, id FROM table");
while ($row = mysql_fetch_array($result)) {
$id = $row["id"];
$column2 = ucwords($row["column"]);
$query2 = "UPDATE table SET column = '$column2′ WHERE id = '$id'";
mysql_query($query2);
}
?>
My table is called MailingList and the Column is called Name, so I have altered the script to this: but it still shows the same WHILE error:
<?php ini_set('display_errors', '1'); ?>
<?php require_once('Connections/maison_connection.php'); ?>
<?php
$result = mysql_query ("SELECT Name, id FROM MailingList");
while ($row = mysql_fetch_array($result)) {
$id = $row["id"];
$Name2 = ucwords($row["Name"]);
$query2 = "UPDATE MailingList SET Name = '$Name2′ WHERE id = '$id'";
mysql_query($query2);
}
?>
Any ideas??
