CodeIgniter Forums
Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - 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: Conect to Sql Server 7.0 - Error - Need Help - RESOLVED (/showthread.php?tid=16461)



Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-07-2009

[eluser]ELJusticeiro[/eluser]
Fedora Linux
Apache2
PHP5
freetds



2> [root@webserver config]# tsql -S 200.200.200.50 -U sa -P xyz
3> locale is "pt_BR.UTF-8"
4> locale charset is "UTF-8"
5> 1>

OK

codeigniter


$db['default']['hostname'] = "200.200.200.50";
$db['default']['username'] = "sa";
$db['default']['password'] = "xyz";
$db['default']['database'] = "db_homeshop";
$db['default']['dbdriver'] = "mssql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = TRUE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = 'windows-1252';
$db['default']['dbcollat'] = 'sql_latin1_general_cp1_ci_as';


Error:


A Database Error Occurred

Unable to connect to your database server using the provided settings.


I Need Help.


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-08-2009

[eluser]cwt137[/eluser]
Hello,

Are you sure that you have the mssql extension installed in php? The easiest way to tell is to create a page that executes phpinfo(). phpinfo() lists all the extensions installed. See if mssql is listed.


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-08-2009

[eluser]ELJusticeiro[/eluser]
yes,

my phpinfo();

mssql
MSSQL Support enabled
Active Persistent Links 0
Active Links 0
Library version FreeTDS


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-08-2009

[eluser]cwt137[/eluser]
Two thoughts:
1. Make sure that the user apache runs under can read the freetds.conf file.
2. Create a simple non-CI program to test mssql inside php. Here is an example:

Code:
// Create a link to MSSQL
$link = mssql_connect('200.200.200.50', 'sa', 'xyz');

if(!$link)
{
    die('Something went wrong while connecting to MSSQL');
}

// Select the database 'php'
mssql_select_db('db_homeshop', $link);


// Do a simple query, select the version of
// MSSQL and print it.
$version = mssql_query('SELECT @@VERSION');
$row = mssql_fetch_array($version);

echo $row[0];

// Clean up
mssql_free_result($version);

If your non-CI program works, then it is a problem with CI. If your program doesn't work, then it is something to do with php.


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-09-2009

[eluser]ELJusticeiro[/eluser]
Not Work with nom-Ci program.

and
777
-rwxrwxrwx 1 root root 1088 Mar 7 11:07 freetds.conf


$link = mssql_connect('200.200.200.50', 'sa', 'xyz') or die('Error');

page error.


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-09-2009

[eluser]cwt137[/eluser]
I don't know what could be the problem with PHP. If you didn't use yum to install freetds and the php-mssql rpms, you can try that. You can also try posting your question to the FreeTDS mailing list and see if they can help if no one else in this forum helps out.


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-11-2009

[eluser]ELJusticeiro[/eluser]
RESOLVED
WORK AROUND

nano /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
#SELINUX=enforcing
SELINUX=disabled <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<WORK AROUND
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted

Reboot,

someome Fedora 10


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-11-2009

[eluser]cwt137[/eluser]
Good job finding out the solution. I hate SELinux because of things like this. Things tend to fail silently for when SELinux is on. I always turn it off on my redhat based boxes for that reason.

EDIT: I just found this command if you want to turn back on SELinux.
Code:
/usr/sbin/setsebool -P httpd_can_network_connect=1
This should allow freetds to work with php when SELinux is turned on.


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-16-2009

[eluser]ELJusticeiro[/eluser]
New problem.

Charset problem especials brazilian char.

Need Help


error: ATEN��O CLIENTES

ATENÇÃO CLIENTES


Conect to Sql Server 7.0 - Error - Need Help - RESOLVED - El Forum - 03-16-2009

[eluser]pistolPete[/eluser]
Try setting:
Code:
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";