How to access remote SQL Server from PHP script [duplicate] - php

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
PHP Fatal error: Call to undefined function mssql_connect()
I am developing a light-weight PHP application which accesses a remote SQL server db.
So far, I am out of luck in getting connection setup to SQL Server db through my PHP script.
I keep getting this error when I am trying to connect to sql DB:
Fatal error: Call to undefined function mssql_connect()
I get similar error when I try sqlsrv_connect($myServer, $myUser, $myPass) too
Here is what I have already tried:
I search for solution on web for hours, but nothing works.
I downloaded drivers from http://www.microsoft.com/en-us/download/details.aspx?id=20098
and unzipped them into php/ext folder
modified php.ini to add newly downloaded drivers lines:
extension=php_sqlsrv_54_ts.dll
extension=php_pdo_sqlsrv_54_ts.dll
[sqlsrv]
sqlsrv.LogSubsystems = 1
sqlsrv.LogSeverity = 1
sqlsrv.WarningReturnAsErrors = 0
Restarted the Apache server
But, see phpinfo() output it doesn't have sqlserv in it http://bit.ly/TkMC6V
Just so you know, I am developing this on my windows machine by installing EasyPHP. This website will be deployed on a Unix box. I tried to connect sql server through php on both Windows and Unix machine without any success.
Version info:
SQL Server 9.0.5000
PHP ver 5.4.6
Apache 2.4
I just dont get sqlsrv in my phpinfo() as mentioned in this question PHP Fatal error: Call to undefined function mssql_connect()
Is there a different way to install the drivers, other than what I have outlined above?
Let me know if you need more info.
Thanks!

I found the issue, by looking at phpInfo() output carefully
Loaded Configuration File C:\Program Files (x86)\EasyPHP-12.1\apache\php.ini
I was modifying php.ini in php directory.
But, I needed to modify the one in apache directory
I can delete this silly question.
But, I think it might be helpful for someone facing similar issue.
Jeez , I spent 4 hour on this stupid issue. :)

Related

sasql_connect(): SQLAnywhere: [-100] Database server not found

it's about more than one full day that i started sqlanywhere and i'm so interested to use it,
i worked before with sqlsrv for ms sql server and connection via php ,
but i have problem for connecting php to sqlanywhere
here is the warning message when i try to run test.php
Installation successful Using php-5.6.0_sqlanywhere.dll
Warning: sasql_connect(): SQLAnywhere: [-100] Database server not found in C:\xampp\htdocs\test.php on line 44
Connection failed
$conn = sasql_connect( "UID=DBA;PWD=sql" );
if( $conn ) {
echo "Connected successfully\n";
sasql_disconnect( $conn );
} else {
echo "Connection failed\n";
}
I'm using xampp server php 5.6 and sqlanywhere 17 developer edition.
already i downloaded the php extension and copied on ext and also added the line in php.ini (extension=php-5.6.0_sqlanywhere.dll)
demo database i ran it with cmd : dbeng17 "%SQLANYSAMP17%\demo.db".
via cmd i tried this also :
C:>dbping -d -c "uid=dba;
SQL Anywhere Server Ping U
Connected to SQL Anywhere
Ping database successful.
but when i try via php it says: Warning: sasql_connect(): SQLAnywhere: [-100] Database server not found in C:\xampp\htdocs\test.php on line 44
Connection failed
please someone tell me what is the problem ?
thank you very much.
Your PHP installation may have multiple files similar to php.ini. Make sure you are modifying the php.ini file listed in phpinfo().
- A web server such as Apache, IIS, or any web server that supports
PHP.
- PHP installed on the same computer as the web server.
- SQL Anywhere installed on the same computer as the web server.
- The client software can be used as well. SQL Anywhere PHP extension
Refrance : https://wiki.scn.sap.com/wiki/display/SQLANY/Getting+Started+with+SAP+SQL+Anywhere+and+PHP
It solved for me when I installed and used it on another system , I don't know I tried first on a system that MSSQL server was install and I couldn't run it and tried on another system that mssql server was not installed and solved :)
sorry for being late to answer and thank you very much for those who took time to help me.

cannot run phpMyAdmin on Windows 10 - session.save_path issue?

I have installed mysql, php5 and apache on windows 10 and I downloaded phpMyAdmin but when I try to open it from localhost/phpmyadmin I get the error message:
Fatal error: Call to undefined function __() in C:\apache24\htdocs\phpmyadmin\libraries\sanitizing.lib.php on line 135
which I don't understand.
In one of other threads I found an information this may be caused by session.save_path being wrongly configured and when I open phpinfo() in the row with this variable there is no value in neither of the columns.
Apache is up and running and php is working and so is mysql. What could be the issue?
Thanks in advance for suggestions.
If you don't get your problem solved, you could try using this program for hosting your website on your localhost. I'm using it all day long and haven't got any problems with that, yet.
https://www.apachefriends.org/de/index.html

Call to undefined function mysql_connect() on Heroku. (PHP works fine locally but not on heroku- why?)

Thanks for your help in advance. I have been working on this bug for more than 12 hours now.
There is an AJAX signup form in my Heroku site which runs on MySQL and is connected to ClearDB Database. I can successfully send data to the database on my local server (MAMP). However, I cannot do the same on the server.
The requests cannot get send to the database and gets stuck at loading. Upon inspection I realise it is a PHP 500 Error.
I found the key problem in the Heroku logs. 2014-11-24T15:02:31.238493+00:00 app[web.1]: [24-Nov-2014 15:02:30 UTC] PHP Fatal error: Call to undefined function mysql_connect() in /app/index.php on line 5
Line 5 of the index.php is mysql_connect('hostname', 'username, 'password');
I have tried running php_getinfo(); and found that there is no MySQL support in the server. On a side note, I have MySQL support in my localhost.
The server php.ini paths are as such: Configuration File (php.ini) Path /app/.heroku/php/etc/php & Loaded Configuration File /app/vendor/heroku/heroku-buildpack-php/conf/php/php.ini
What should I do?
mysql_* functions are deprecated and actually removed in the next PHP version. Check out mysqli.
Worth noting that you can enable mysql_* on Heroku via composer.json. This is documented in Heroku's devcenter docs on PHP support.
Also recommend you consider using a more modern MySQL library, though :)

"Fatal Error: Call to undefined function mb_detect_encoding()" when trying to run phpMyAdmin 4.2.7 on IIS 8 with PHP 5.4.30

I have PHP 5.4.30 installed and running well using the FastCGI module and IIS 8 (on Windows 8.1). I have MySQL installed and would like to manage it with phpMyAdmin, however, I get this error whenever I try to access the page:
Fatal error: Call to undefined function mb_detect_encoding() in C:\inetpub\wwwroot\phpmyadmin\libraries\php-gettext\gettext.inc on line 177
Many older threads I have seen suggest adding extensions to the php.ini, but in the later versions of php, the php.ini file becomes php.ini-production and php.ini-development. Whenever I try to modify either of these files or create a php.ini file, I get an error 500 when trying to visit other php pages. I have also seen many solutions related to Xampp / Apache, but none of them seem to work in IIS 8 (that I have found).
Thanks in advance for any suggestions!
You probably need the php_mbstring.dll file installed. You can find it on the PHP Windows Extensions page

connect to SQL Anywhere by TCP/IP

I'm new in sql anywhere, currently I'm trying to connect using PHP.
This is what I've got so far:
$conn = sqlanywhere_connect ( "UID=usr;PWD=pass;ENG=serv;DBN=bd_name;COMMLINKS=TCPIP{HOST=10.1.1.189:2638}" );
SQL Anywhere is installed on another machine, where I can't run apache, website is running on localhost (xampp). This is only for test, when website would be ready I will connect to correct db.
This is error I've got:
Warning: sqlanywhere_connect(): The SQLAnywhere client libraries could not be loaded. Please ensure that dbcapi.dll can be found in your PATH environment variable. in C:\xampp\htdocs\core\cache\includes\elements\modsnippet\25.include.cache.php on line 21
I haven't got dbcapi.dll file, but I'm not sure I should have it.
In documentation I couldnt find this file (SQL Anywhere 10 which I've got), but for SQL Anywhere 11 I could find pages where was info about this file.
To use sqlanywhere_connect I've download SQL Anywhere module for curren ver. of PHP onto my machine and I've add it to php.ini file.
What should I do? Should I download missing file? Would it be enough or I could get more errors asking for other files?
I had a similar problem and the solution proposed here:
https://groups.google.com/forum/#!msg/sql-anywhere-web-development/zK9Tf-X3cYk/GAoqK2DnB9EJ
worked for me.
Specifically, my xampp + php needed the 32 bit dbcapi.dll but when I installed SQL Anywhere 12 I neglected to check the box to install the 32 bit version as well. Re-installing, chossing "modify" and installing the 32 bit SQL Anywhere 12 got "php test.php" working.
I would down load the missing file and go from there you are using xamp which is pre-built to talk to mySQl I doubt there is any extra .dll in the Instillation to connect with SQLAnywhere

Categories