Jump to content
vpess

Ligação SQL Server via PHP

Recommended Posts

vpess

Boa noite,

Estou com um problema, num pequeno projecto que estou a desenvolver, necessito de me ligar a uma BD em SQL Server 2005.

Até ai tudo bem, ja configurei, as portas na firewall e no router e configurei um dns, visto nao ter IP fixo.

Acontece que localmente está a funcionar com o seguinte codigo:

<?php 
        $connection_string = 'Driver={SQL Native Client};Server=xxxxxx.dyndns.org\CLEVER;Database=CLEVER; Trusted_Connection=yes;'; 
        $user = 'sa'; 
        $pass = 'xxxxxx'; 
        //$conn = odbc_connect( $connection_string, $user, $pass ); 

if(!$conn = odbc_connect( $connection_string, $user, $pass )){
echo 'Erro na ligação!';	
}

?>

Mas quando mando isto para o servidor de alojamento ja nao se consegue ligar.

Será que falta algum parametro?????

Cumps.

Share this post


Link to post
Share on other sites
vpess

Também nao me consegui ligar assim!!

<?php
$server = 'xxxxxxx.dyndns.org:8080\CLEVER';
$link = mssql_connect($server, 'sa', '12345609#');

if (!$link) {
    echo 'Something went wrong while connecting to MSSQL' ;
}else{
echo 'Parabens!';
}
?>

Provavelmente, se não tiverem o driver odbc configurado, terás que aceder através da função mssql_connect().

:)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.