Jump to content

PHP and SQL connect


saint959

Recommended Posts

Hi All,

 

I am hoping someone can help me out. i am attempting to connect to a Microsoft SQL database. below is the code i am using as a test just to see if the connection is being made

 

<?PHP
msql_connect('servername','username','password') or die ('Unable to connect to server.');
msql_select_db('tablename') or die ('Unable to select database.');
?>

 

If anyone has any ideas please, any help will be hugely appreciated.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/57055-php-and-sql-connect/
Share on other sites

Hi redarrow, thanks for the reply.

 

I am receiving the below error:

 

Warning: Wrong parameter count for msql_connect() in "file directory" on line 7

 

Warning: msql_select_db(): supplied argument is not a valid mSQL-Link resource in "file directory" on line 8

Unable to select database.

 

IS there a difference between msql and mssql???

Link to comment
https://forums.phpfreaks.com/topic/57055-php-and-sql-connect/#findComment-281895
Share on other sites

hi redarrow, yes we are using SQL 2005 for windows.

 

i have requested that the mssql extension be included in the php.ini and will test that in a few mins.

 

Thanks for the help so far, it is much appreciated, will try that now

 

suma237, thanks for your help but i am not trying to connect to a MySQL database. I am struggling to connect to a Microsoft Database which uses a different connection to MySQL.

 

 

Link to comment
https://forums.phpfreaks.com/topic/57055-php-and-sql-connect/#findComment-281901
Share on other sites

 

got this aswell m8 i am trying sorry for not nowing m8.

 

<html>
<body>
<?php
$con = mssql_connect ("<ip of the server SQL>", "sa", "");
mssql_select_db ("<Data Base>", $con);
$sql= "SELECT * FROM <Table>";
$rs= mssql_query ($sql, $con);
echo "The field number one is: ";
echo mssql_result ($rs, 0, 0);
mssql_close ($con);
?>
</body>
</html> 

Link to comment
https://forums.phpfreaks.com/topic/57055-php-and-sql-connect/#findComment-281902
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.