I have a remote server. This code works when I'm directly on the server. (username / pass changed..). The URL is myuniversity.edu/myfolder
I think I want to change it to myuniversity.edu/foo/bar
.. but that doesn't work. So how would I translate the name of the database? My research on google isn't turning up anything helpful. My specific folder shouldn't be a factor as many other students connect with the exact some code.
function dbConnect()
{
$serverName = 'foo\bar';
$uName = 'un';
$pWord = '***';
$db = 'RWS';
try
{
//instantiate a PDO object and set connection properties
$conn = new PDO("sqlsrv:Server=$serverName; Database=$db", $uName, $pWord,
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
//return connection object
return $conn;
}
catch (PDOException $e)
{
// if connection fails
die('Connection failed: ' . $e->getMessage());
}
}
change myuniversity.edu/foo/bar to myuniversity.edu/server=foo&name=bar
then change
$serverName = 'foo\\bar'; to
$serverName = $_GET['server']+$_GET['name'];
i seems in your code that folder directing would not give you a variable to be read by php...hope this would give you an idea
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.