-2

I have a PHP file in which I want to convert the user input into uppercase letter , so I used strtoupper() function of PHP but it is not working.Here is my code

$eno =@$_SESSION['eno'];
$eno =strtoupper($eno);

Now on inserting this into database , it is still in lowercase letters.Here is the insert query.

$sql="INSERT INTO `student_info`(`student_no`,`High_School_Name`, `Year_Of_Passing`, `Higher_Secondary_School_Name`, `Year_Of_Passing1`, `Enrollment_Number`, `Roll_Number`, `Current_Course`, `Current_Sem`, `Current_section`, `Enrollment_Year`, `Alternate_Email`)VALUES('$studentno','$High_School_Name','$Year_Of_Passing10','$Higher_Secondary_School_Name','$Year_Of_Passing12','$eno','$Roll_Number','$Current_Course','$Current_Sem','$Current_section','$Enrollment_Year','$Alternate_Email' )";
Rajat Garg
  • 542
  • 2
  • 11
  • 26
  • Can you show us the code you use to insert `$eno` into the database? – Tserkov Dec 20 '14 at 07:40
  • 1
    strtoupper works just fine, the problem is elsewhere – erikvimz Dec 20 '14 at 07:42
  • 1
    Try this, right after you make the string uppercase, do: var_dump($eno); exit; and look at the output. Also could you post the entire code? The query doesn't help us. – erikvimz Dec 20 '14 at 07:46
  • Also your sql query is unsecure, you need to escape your variables, look here: http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – erikvimz Dec 20 '14 at 07:49
  • Actually I have created the sessions so the code is transferred from one page to other. So i am unable to show you the entire code. – Rajat Garg Dec 20 '14 at 07:54

2 Answers2

0
 $eno='vikram';
 echo $eno =strtoupper($eno);

enter image description here

 $sql="INSERT INTO `student_info`(`student_no`,`High_School_Name`, `Year_Of_Passing`, `Higher_Secondary_School_Name`, `Year_Of_Passing1`, `Enrollment_Number`, `Roll_Number`, `Current_Course`, `Current_Sem`, `Current_section`, `Enrollment_Year`, `Alternate_Email`)VALUES('".$studentno."','".$High_School_Name."','".$Year_Of_Passing10."','".$Higher_Secondary_School_Name."','".$Year_Of_Passing12."',ucase('".$eno."'),'".$Roll_Number."','".$Current_Course."','".$Current_Sem."','".$Current_section."','".$Enrollment_Year."','".$Alternate_Email."' )";

use this function in query: select UCASE ('vikram')

enter image description here

Sharma Vikram
  • 2,440
  • 6
  • 23
  • 46
0

There is no problem

echo $eno;

.. and look at the results.

Nate Ritter
  • 2,386
  • 3
  • 20
  • 28