murfitUK Posted July 5, 2006 Share Posted July 5, 2006 I'm sure some kind soul will help.I'm putting the results of a search into a table but I am trying to use the strtolower function without success - getting confused with round brackets, curly brackets, square brackets, single quotes and double quotes etc!This is a line of the code so far:print "\n\t<td>{$row["CODE"]}</td>" . "\n\t<td>{$row["TR"]}</td>" . etcI would like to use strtolower function so that the CODE field is printed in the table in lower case letters but just can't manage it.Could someone please let me know what the syntax should be. Thanks for your help. Link to comment Share on other sites More sharing options...
aspnetguy Posted July 5, 2006 Share Posted July 5, 2006 print "\n\t<td>{strtolower($row["CODE"])}</td>" ."\n\t<td>{$row["TR"]}</td>" . etc Link to comment Share on other sites More sharing options...
murfitUK Posted July 5, 2006 Author Share Posted July 5, 2006 Thanks for the quick response. I have tried your suggestion but it doesn't work. I get this error message:Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Abyss Web Server\htdocs\newweb\results.php on line 91and line 91 is:print "\n\t<td>{strtolower($row["CODE"])}</td>" . (I've copied and pasted to make sure its correct.)The field CODE is type varchar(255).Thanks for your help. Link to comment Share on other sites More sharing options...
aspnetguy Posted July 5, 2006 Share Posted July 5, 2006 Thanks for the quick response. I have tried your suggestion but it doesn't work. I get this error message:Parse error: parse error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Abyss Web Server\htdocs\newweb\results.php on line 91and line 91 is:print "\n\t<td>{strtolower($row["CODE"])}</td>" . (I've copied and pasted to make sure its correct.)The field CODE is type varchar(255).Thanks for your help.<{POST_SNAPBACK}> whoops sorry it should be thisprint "\n\t<td>{strtolower($row['CODE'])}</td>" . You can't use double quotes inside double quotes without escaping htem. in this case iwas just easier to use single quotes around CODE - 'CODE' Link to comment Share on other sites More sharing options...
justsomeguy Posted July 5, 2006 Share Posted July 5, 2006 If you're making a function call, you have to have it outside the string altogether. String interpolation only happens with variables and constants: print "\n\t<td>" . strtolower($row['CODE']) . "</td>" Link to comment Share on other sites More sharing options...
murfitUK Posted July 6, 2006 Author Share Posted July 6, 2006 Ah double quotes and single quotes. I knew it had something to do with.My solution (until I tried your suggestions) was to pull out the field first, modify it and then stick it into the table:$codelc=strtolower{$row["CODE"]};...print "\n\t<td>{$codelc}</td>" ....or something like that anyway. But now I know the correct way I shall go and change it again.Thanks folks. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 6, 2006 Share Posted July 6, 2006 $codelc=strtolower{$row["CODE"]};...print "\n\t<td>{$codelc}</td>" ....That would work fine, but the syntax is incorrect for calling a function. A function's list of parameters is inside parentheses, not curly brackets:$codelc=strtolower($row["CODE"]);...print "\n\t<td>{$codelc}</td>" .... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now