tags:

views:

76

answers:

2

Is it alright to do this?

$author = strtolower($_SESSION['valid_username']);

I want to enter all authors into the table as lower case.

+3  A: 

Yes, that's fine as long as $_SESSION['valid_username'] is set, otherwise you'll get a notice (if your error reporting is set that low).

You can check if it exists with if (isset($_SESSION['valid_username']))

Greg
Like this?if(isset($_SESSION['valid_username'])) $author = strtolower($_SESSION['valid_username']);
Brad
Yup... then you probably want something like else $author = '';
Greg
or something like else throw new Exception('Error: Username is not set!')
Greg
+2  A: 

yes.

$_SESSION['valid_username']

is a session variable which evaluates to a string so passing it as a parameter to the strtolower function is not a problem.

Vincent Ramdhanie