Arbitus Posted November 8, 2008 Share Posted November 8, 2008 So I started learning PHP/mysql and had a few stupid questions. If I had a file in /admin and wanted to include something in my home directory, how do I do that? I read somewhere you do something like include("$_SERVER[]/file.php"); but don't know exactly what goes in the brackets. How do I make it when I call something from a database that is in all lowercase letters, it displays it with the first letter being capitalized ex. "house" is in database and "House" is displayed These are the first of probably many questions. Thanks so much! Link to comment https://forums.phpfreaks.com/topic/131866-stupid-question/ Share on other sites More sharing options...
genericnumber1 Posted November 8, 2008 Share Posted November 8, 2008 You could $_SERVER['DOCUMENT_ROOT'] which is what you described, or you can do '../file.php'. ".." goes up one directory. As for capitalizing the first letter? simplest way is ucfirst http://us3.php.net/ucfirst edit: also note you'll need to do include("{$_SERVER['DOCUMENT_ROOT']}/file.php"); to avoid any error messages, if that is the route you decide to choose. Link to comment https://forums.phpfreaks.com/topic/131866-stupid-question/#findComment-685052 Share on other sites More sharing options...
IchBin Posted November 8, 2008 Share Posted November 8, 2008 On your first question include() OR require()/require_once() all take a path. You can use a relative if you'd like, or a full path. So if you're site was structured like this in a folder view. -www --admin ---functions.php --index.php You could put a line like this: include('admin/functions.php'); That would be a path that is relative to the file you are including it in. If you need to use a script that is outside of your relative path its better to use the full path. On Unix/Linux hosts it would something similar to this. include('/home/username/folder/folder/filename'); ucfirst() is for uppercase letter on the first characeter. --edit generidnumber1 beat me to it... Link to comment https://forums.phpfreaks.com/topic/131866-stupid-question/#findComment-685053 Share on other sites More sharing options...
Arbitus Posted November 8, 2008 Author Share Posted November 8, 2008 Thanks so much! Just tried the ucfirst() and worked perfectly! I'll try that too, thanks again. Link to comment https://forums.phpfreaks.com/topic/131866-stupid-question/#findComment-685056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.