SQL Server data to php - php

I have this php script:
<?php
$server = 'PCCSAF\SQLEXPRESS';
$link = mssql_connect($server, 'username', 'password');
if (!$link) {
die('wrong');
}
?>
I need to connect to local SQL Server express server, but I always get
Fatal error: Call to undefined function mssql_connect() in C:\wamp\www\dbgrab\index.php on line 4
I've tried to install ntwdblib.dll, uncomment extension=php_ming.dll and extension=php_mssql.dll in php.ini, but it still not works.
I'm using PHP 5.4.3 and WAMP server 2.2 on 64bit windows7
Thank you.

WAMP Server x64 is not compatible with PHP SQL Server Driver. Try using 32 bit WAMP.

Related

How can fix error PDOException: could not find driver?

I have local site in Wamp32, apache 2.4.23, php 7.0.10 and mysql 5.7.14
I wrote program to connect to sql server 2014 in another server but when I run this program it has an error
"could not find driver"
In php.ini I have:
extension=php_sqlsrv_7_ts.dll
extension=php_pdo_sqlsrv_7_ts.dll
My command for connect to sql server is:
$connection = new PDO('sqlsrv:Server=myserverIP;Database=mydatabase', 'username', 'password');
My server OS is windows server 2012R2

Fatal error: Call to undefined function sqlsrv_connect() in php 5.6.25

OS: Windows 8.1
Web Server: WAMPSERVER 3.0.6
PHP Version: 5.6.25
Goal: To establish MYSQL Database connection using PHP
What has been done:
Downloaded SQLSRV Drivers (SQLSRV32.EXE)
Copied files php_pdo_sqlsrv_56_ts.dll and php_sqlsrv_56_ts.dll to the directory "C:\wamp64\bin\php\php5.6.25\ext"
extension_dir = "c:/wamp64/bin/php/php5.6.25/ext/"
Added the following lines to the dynamic extensions part in the php.ini file:
extension=php_pdo_sqlsrv_56_ts.dll
extension=php_sqlsrv_56_ts.dll
Restarted Web Server
But: phpinfo() is not listed in sqlsrv()
Code:
$myServer = "(local)";
$myUser = "sa";
$myPass = "pass";
$myDB = "example_db";
$connectionInfo = array("Database"=>$myDB, "UID" => $myUser, "PWD" => $myPass);
$conn = sqlsrv_connect($myServer, $connectionInfo);
Error:
Fatal error: Call to undefined function sqlsrv_connect() in
C:\wamp64\www\optimum_p\common\dbconnect.php on line 6
As per OP's comment:
The problem was WAMP, to fix the problem:
uninstall WAMP
install XAMPP
Problem solved.

PHP mssql_connect issue

I'm running this php file:
<?php
$link = mssql_connect('db1.peanut.butter.com:3184', 'user', 'pass');
?>
and getting this error:
Warning: mssql_connect(): Unable to connect to server: db1.peanut.butter.com:3184 in /tmp/query.php on line 3
The server is up and running, and I was able to connect and query it from the SSMS.
How should I write the server in the mssql_connect command?
Full name? Just 'db1'? No port?
Thanks!
This function was removed from PHP 7.0.0
Check if that might be the case.

Unable to connect SQL SERVER 2008 R2

i have one page for register ... all my config is right but my register.php can't connect to my sql server..
Error
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: x.x.x.x in C:\xampp\htdocs\rfweb\regis.php on line 81
code in line 81 is
$connectsql=mssql_connect($db_host, $db_user, $db_pass) or die('<center><b>'.$lang_error_cant_connect1.'</b><br>'.$lang_error_cant_connect2.'<br><br>Back</center>');
spesification :
SQL SERVER 2008 R2 and xampp 1.6
i've try to setting ODBC, Restart SQL, ect
anyone help me to fix it?
Try sqlsrv queries instead of mssql, and make sure you properly configured the ports of your xampp. Another thing, try to check whether you have IIS, maybe it's blocking your xampp.

Trying to connect PDO on a local server

I am trying to connecting PDO on my local server. I'm using Windows 7 Professional 64-bit and have AppServ installed. In a php document I use the following code for connection:
<?php
$dbh = new PDO('mysql:host=localhost;dbname=test', 'root', 'password');
?>
But the code turns out to be an error: Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\AppServ\www\a.php:2
I checked phpinfo() and it shows that sqlite and sqlite2 are the only two databases installed in PDO. So how can I install MySQL PDO?
Thank you all. I just removed the semicolon in the php.ini file for MySQL and it works! The default location of php.ini file is in C:/Windows/.

Categories