Open main menu

CDOT Wiki β

Changes

OPS335 Lab 5

133 bytes added, 08:15, 21 September 2016
m
Moving the database connection code from an external link to an internal pre tag.
*Re-start the web-server and try to access the page from another machine. Make sure that you can '''not''' do so before you continue.
*Install the '''php-mysql''' module so that the installation of php your web server is using can execute sql statements. You will have to restart the service after installing it.
*Create a page like Modify the one described [http://php.net/manual/en/mysqli.quickstart.connectionsindex.php here] page in your private directory to match the code below. This will test that your web server can connect to the database (replace the user, password, and database with values appropriate for your machine). Note that only the first connection <pre><?php$mysqli = new mysqli(using '''"localhost'''", "user", "password", "database") on that page should be able ;if ($mysqli->connect_errno) { echo "Failed to connectto MySQL: (" . $mysqli->connect_errno .") " . $mysqli->connect_error;}echo $mysqli->host_info . "\n";?></pre>
*Once that page shows a successful connection on your VM ('''Localhost via UNIX socket''') this step is complete.
*You have now established that the web server is able to run code which can interract with the database. This will allow dynamic pages to make use of information stored there when providing resources to your users.
932
edits