+ Post New Thread
Results 1 to 4 of 4
Coding Thread, PHP Database connection in Coding and Web Development; I've trying to get the moodle and sims to work together as detailed by CyberNerd but I've hit a few ...
  1. #1
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    41

    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:

    Code:
    <?
    $user="sa";
    $password="<Password>";
    $database="sims";
    $host = "<IPAddy>,1433";
    $link = mssql_connect($host,$user,$password);
    
    if(!$link)
    {
        die("Didnt work.");
    }
    else
    {
    	@mssql_select_db($database) or die( "Unable to select database");
    	echo("it works?!");
    }
    mssql_close();
    ?>
    SQL 2005 - SIMS View

    Code:
    USE [sims]
    
    GO
    /****** Object:  View [dbo].[mdl_enrolments]    Script Date: 12/05/2007 17:16:34 ******/
    
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER VIEW [dbo].[mdl_enrolments]
    AS
    SELECT DISTINCT class_name AS course, staff_initials AS person, 'editingteacher' AS role
    FROM         sims.curr_via_classperiods AS p
    UNION
    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
    I now need the code to get some data and output it.

  2. #2
    budgester's Avatar
    Join Date
    Jan 2006
    Location
    Enfield, Middlesex
    Posts
    486
    Thank Post
    4
    Thanked 37 Times in 30 Posts
    Rep Power
    24
    Does the PHP script connect to the server ?

  3. #3
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    41
    It doesnt show any errors so I think it does. I want to try pulling some data out to see if its possible.

  4. #4
    Cravon's Avatar
    Join Date
    Jun 2007
    Location
    Holy Terra
    Posts
    43
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    How about an ODBC connection to the sims database?

    Code:
    $link = odbc_connect (DSN/DB, username, password);
    $rs = odbc_exec($link,$query);
    odbc_close ($link);
    Don't know if that is a work round that will work for you

SHARE:
+ Post New Thread

Similar Threads

  1. Looking for PHP blog script which does not require database
    By ajbritton in forum Web Development
    Replies: 10
    Last Post: 9th December 2010, 07:50 AM
  2. VPN connection with internet connection option
    By FN-GM in forum Wireless Networks
    Replies: 6
    Last Post: 29th December 2007, 07:19 PM
  3. Replies: 4
    Last Post: 28th February 2007, 09:37 AM
  4. Creating a new database in php and mysql
    By StewartKnight in forum Web Development
    Replies: 18
    Last Post: 21st February 2007, 08:53 AM
  5. PHP flat file database script
    By ajbritton in forum Web Development
    Replies: 3
    Last Post: 26th October 2006, 08:51 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •