PHP Database connection
I've trying to get the moodle and sims to work together as detailed by CyberNerd but I've hit a few snags so i need to find out whats working and whats not. What i need to do is to seen if i can write a php script that will connect to the SQL server and retrieve a bit of info to print to screen. Heres what i have so far:
PHP - Connection to Server:
SQL 2005 - SIMS View
$host = "<IPAddy>,1433";
$link = mssql_connect($host,$user,$password);
@mssql_select_db($database) or die( "Unable to select database");
I now need the code to get some data and output it.
/****** Object: View [dbo].[mdl_enrolments] Script Date: 12/05/2007 17:16:34 ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
ALTER VIEW [dbo].[mdl_enrolments]
SELECT DISTINCT class_name AS course, staff_initials AS person, 'editingteacher' AS role
FROM sims.curr_via_classperiods AS p
SELECT DISTINCT p.class_name AS course, m.unique_pupil_no AS person, 'student' AS role
FROM sims.curr_via_classperiods AS p INNER JOIN
sims.stud_via_group_members AS m ON m.base_group_id = p.base_group_id
Does the PHP script connect to the server ?
It doesnt show any errors so I think it does. I want to try pulling some data out to see if its possible.
How about an ODBC connection to the sims database?
Don't know if that is a work round that will work for you :confused:
$link = odbc_connect (DSN/DB, username, password);
$rs = odbc_exec($link,$query);