mssql connection works procedurally but not with database class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: mssql connection works procedurally but not with database class (/showthread.php?tid=22743) |
mssql connection works procedurally but not with database class - El Forum - 09-18-2009 [eluser]getSurreal[/eluser] I'm able to successfully connect procedurally to my MS SQL database, but when I try to use the database class I have problems. The first thing I noticed is that mssql.php is coded incorrectly to use port which was recently added for mssql. Code: function db_connect() After I updated mssql.php with that change I no longer got the error about being unable to connect to my database. But I'm still getting an error that I can't resolve. This code fails Code: $this->load->database('mssqldb'); with this error Code: A PHP Error was encountered here are my settings in database.php Code: $db['mssqldb']['hostname'] = "myserver"; Procedurally I can connect and return data with this code. Code: $sqlconnect=mssql_connect('myserver:931', 'myuser', 'mypass'); mssql connection works procedurally but not with database class - El Forum - 09-25-2009 [eluser]getSurreal[/eluser] Bump.... I hope someone can help me with this. mssql connection works procedurally but not with database class - El Forum - 09-25-2009 [eluser]bgreene[/eluser] well if "$this->db->query('select * from mytable);" is really what you have and not just a mistype then you're missing the closing apostrophe after mytable mssql connection works procedurally but not with database class - El Forum - 09-25-2009 [eluser]getSurreal[/eluser] Just a typo. I just double checked my code and corrected the post. mssql connection works procedurally but not with database class - El Forum - 09-25-2009 [eluser]bgreene[/eluser] $this->load->database('mssqldb'); $qry = $this->db->query('select * from mytable'); foreach ($qry->result() as $row) { echo $row->Hosts; } mssql connection works procedurally but not with database class - El Forum - 09-25-2009 [eluser]getSurreal[/eluser] bgreene, that worked! Thank you very much. The CI example does not show it that way. |