Hi guys

Our college has a website(php, html, css) that is hosted elsewhere, but now we have a college database (mssql) on a local server and the Director wants me to link the website to the database at the college's server.

Any ideas on how to do that?

thanks in advance

Dani AI

Generated

As described, the job is to let a hosted PHP site talk to a college MS SQL Server. As already hinted, network and server settings matter; as implied, you also need the right driver (note: this is MSSQL, not MySQL — WordPress does not natively use MSSQL unless you use a compatibility project such as Project Nami).

Practical checklist to hand to the college IT person:

  • Enable the SQL Server TCP/IP protocol and assign a static TCP port (named instances often use dynamic ports).
  • Enable either SQL authentication (mixed mode) or arrange a secure domain/VPN so Windows auth works.
  • Open the college firewall for the chosen port (default 1433) and, if behind NAT, forward that port from the router.
  • If you use a named instance without a fixed port, run SQL Server Browser and allow UDP 1434.
  • Create a low‑privilege SQL account restricted to the required database and, if possible, restricted by source IP.

Links with how-to details:

PHP connection options (examples):

$dsn = "sqlsrv:Server=192.0.2.10,1433;Database=CollegeDB";
$db = new PDO($dsn, "webuser", "password", [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);

or

$server = "tcp:192.0.2.10,1433";
$conn = sqlsrv_connect($server, ["Database"=>"CollegeDB","Uid"=>"webuser","PWD"=>"password"]);

Security and ops notes: avoid exposing the DB directly to the public internet if possible. Prefer a site-to-site VPN or host a small HTTPS API on the college LAN that your public site calls. Always use TLS, restrict source IPs, use least-privilege accounts, and verify your web host allows outgoing connections to the DB port.

Recommended Answers

All 3 Replies

The server where the database is needs to allow remote connections. Your router/firewall needs to allow the website host to connect/reroute. Then you can open the database server by ip address or hostname on the host. Check first with your web host, to see that there are no limitations that prevent this.

thanks a lot hey, even if i re do the site in wordpress, i still have to do it the same way u mentioned above huh?

but thanks so much

Can you access the mysql database on the local server? If so, then just adjust the code on the html site to point to that database. Get the server dude at your college to give you / your site the necessary permissions and let you know what they are.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.