Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert string to uppercase

Status
Not open for further replies.

Chelsea7

Programmer
Aug 25, 2008
69
US
Hi,

I had a question about converting a field that was inputted in a form to all uppercase.

<form name="email_list" method="post" action="emailme.php">

<input type="text" name="companyname" size=20>
</form>

The next file is emailme.php

<?
$companyname=($_POST['companyname']);

mysql_query("INSERT INTO company UCASE(companyname) VALUES ('$_POST[companyname]')");
?>

I'm trying to get the input from the user to convert to all uppercase so that it saves in the database all caps.

I tried to use UCASE(companyname). But it ignores the UCASE and the text is saved however the user inputs in the field.


?>

If this is not clear please let me know. I'm not sure why it's ignoring the syntax.

I can do this,

$Company=strtoupper($company);
echo $company;

I did that to test the string and it displays all uppercase. But I can't get it to store in the database the same way.
 
You can't upper case the column name, you want to upper case the data you are inserting so:


Code:
mysql_query("INSERT INTO company companyname VALUES ([red]UCASE([/red]$_POST[companyname][red])[/red])");


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top