Already changed file php.ini
And the index.php file contains:
<?php
$server = 'name/SQLEXPRESS';
$link = mssql_connect($server, 'namepc', 'pw');
if (!$link) {
die('Something went wrong');
}
?>
And the error message on the localhost is:
Warning: mssql_connect() [function.mssql-connect]:. (severity 14)
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server:
Something went wrong
Already made it!
Just create a new usser on managment studio and linked it the new accound to your php code.
Related
I have tested my MS SQL Server connection with this PHP code:
<?php
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = 'WIN-71KGFN2PPCC\SQLEXPRESS';
// Connect to MSSQL
$link = mssql_connect($server, 'sa', 'test1234');
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}else{
}
?>
and had this warning and error message:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: WIN-71KGFN2PPCC\SQLEXPRESS in C:\inetpub\wwwroot\index.php on line 7
Something went wrong while connecting to MSSQL
I tried many solutions, I also enabled the TCP/IP protocol of my MS SQL Server from the SQL Configuration Manager, adding the port 1433 to it and to the firewall. Any other solution to it? Please help me.
I am trying to connect to my MySQL version 8.0.11 database in zend server version 7.2.10 using php but I could not connect it
Warning: mysqli::__construct(): Unexpected server respose while doing caching_sha2 auth: 109 in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7
Warning: mysqli::__construct(): MySQL server has gone away in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7
Warning: mysqli::__construct(): (HY000/2006): MySQL server has gone away in C:\Program Files (x86)\Zend\Apache24\htdocs\connectdatabase.php on line 7
Connection failed :MySQL server has gone away
I am getting the following warnings when i try to run my code.
i have searched and tried ALTER USER 'username'#'hostname' IDENTIFIED WITH mysql_native_password BY "userpassword" command but it does not work for me
<?php
$servername = "localhost";
$username = "root";
$password = "hello";
$conn = new mysqli($servername,$username,$password);
if(mysqli_connect_error())
{
die("Connection failed :" . mysqli_connect_error());
}
echo "CONNECTED SUCCESSFULLY";
?>
Try with caching_sha2_password:
ALTER USER 'username'#'hostname'IDENTIFIED WITH caching_sha2_password BY 'userpassword';
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.
I have a snippet of code under the PHP file in Eclipse PHP.
$username = mysql_real_escape_string( $username );
It generates an error Warning:
mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /web_development/php_work/new_test/test.php on line 37
Looks like the Eclipse PHP couldn't connect to the MySQL of XAMPP, so How do I fix that?
I added two lines
#mysql_connect('localhost','root', '') or die('Could not connect to : ' . mysql_error());
#mysql_select_db('test') or die( "-Unable to select database");
but Eclipse still throws me.
mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to local MySQL server through socket '/tmp/mysql.sock'
thx.
I wrote code as below:
<?php
$conn = mssql_connect("xx.xx.xx.xx", "username", "password")
or die("Can't connect to server ".mssql_error());
echo "Success";
mssql_close($conn);
?>
The error is:
PHP Warning: mssql_connect()
[function.mssql-connect]: Unable to
connect to server: xx.xx.xx.xx in
xxxxxxx\conn.php
on line 2 PHP Fatal error: Call to
undefined function mssql_error() in
xxxxxxx\conn.php
on line 3
The server is Apache2.2, the version of Sql Server is 2005, the version of PHP is 5.2.5, and I remove the ; before extension=php_mssql.dll and there is a php_mssql.dll in the ext directory
Could you check your apache log if there is a problem with the mssql extension when the service starts?
Use mssql_get_last_message()
<?php
$conn = mssql_connect("xx.xx.xx.xx", "username", "password")
or die("Can't connect to server ".mssql_get_last_message());
echo "Success";
mssql_close($conn);
?>