PHP how to works with SQL anywhere 10..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sweeleen
Forum Newbie
Posts: 5
Joined: Mon Jun 25, 2007 1:20 am

PHP how to works with SQL anywhere 10..

Post by sweeleen »

Hi, all. I am a newbie of PHP and i just learn it since last week. I m currently under training in a company.
Currently I m requesting by my manager that to configure PHP works with SQL anywhere 10. But, after i try to configure it. I get tis error msg-->

PHP Warning: PHP Startup: sqlanywhere: Unable to initialize module Module compiled with module API=20050922, debug=0, thread-safety=1 PHP compiled with module API=20060613, debug=0, thread-safety=1 These options need to match in Unknown on line 0 PHP Fatal error: Call to undefined function sqlanywhere_connect() in C:\Program Files\SQL Anywhere 10\src\php\examples\connect.php on line 2

I am wondering what this error means and how to solve this?

Here are the steps that I configure PHP and SQL anywhere 10.
1. I installed PHP 5.3.2 without any extension.
2. I copy php-5.1.2_sqlanywhere10.dll this file from SQL anywhere 10 and paste into C:\PHP\ext folder.
3. I modified the code in PHP.ini by adding this line
extension=php-5.1.2_sqlanywhere10.dll only.
4. I start my server in the sample database provided by SQL anywhere 10.
5. I run my connect.php in IIS, then it gets these errors.

I know the version of SQL anywhere 10 is not compatible with PHP version. But, I am following the steps provided by this link:
http://www.ianywhere.com/developer/prod ... 87280.html

Here is my code for connect.php

Code: Select all

<?php
    $conn = sqlanywhere_connect( "uid=dba;pwd=sql" );

    if( ! $conn ) {
	echo "Connection failed\n";
    } else {
	echo "Connected successfully\n";
	sqlanywhere_disconnect( $conn );
    }

?>
Is it anything that I miss out? Anyone with the solution can you please share with me ? Thankyou.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

extensions need to be built against the PHP engine they will run with. In this instance, sqlanywhere was built for 5.1.2, while you are running 5.2.3. You need to either downgrade PHP or upgrade sqlanywhere.
sweeleen
Forum Newbie
Posts: 5
Joined: Mon Jun 25, 2007 1:20 am

Post by sweeleen »

Ya. I also knew that the version is a problem.
I do search on some of the websites with tis error "Unable to initialize module Module"
Some of them will solve this problem with recompile the PHP or the extension which I am not very sure.

Besides the versioning problem, any mistakes that I made ? I think it also lack of 1 library...isit?
sweeleen
Forum Newbie
Posts: 5
Joined: Mon Jun 25, 2007 1:20 am

Post by sweeleen »

I have another question.

How to Build the Drivers From Source Code? and also how to recompile PHP driver source?
sweeleen
Forum Newbie
Posts: 5
Joined: Mon Jun 25, 2007 1:20 am

Post by sweeleen »

ok. Now i already downgrade my PHP by using PHP 5.1.1 and the extension file also 5.1.1. and now left 1 error.

>Fatal error: Call to undefined function sqlanywhere_connect() in C:\Program Files\SQL Anywhere 10\src\php\examples\connect.php on line 2

1. I m using PHP 5.1.1 which from the zip folder. So, i copy the whole folder to C:\PHP\
2. Then i copy php-5.1.1_sqlanywhere10.dll into the C:\PHP\ext\ folder.
3. As i read from the SQL anywhere white paper, it says that i need to include another file which is dblib10.dll.
4. I also included the code extension=php-5.1.1_sqlanywhere10.dll
5. So i copy this file to the main folder of PHP which is C:\PHP\.
6. Then, i run it on IIS there is an error.

I dunno how to include the library or include any codes to make the extension and library works?
Can anyone give some suggestion on how to do it and how to solve that error?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

sweeleen wrote:4. I also included the code extension=php-5.1.1_sqlanywhere10.dll
please run

Code: Select all

<?php echo 'php.ini: ', get_cfg_var('cfg_file_path'); ?>
and check wether you have edited the right file.
sweeleen
Forum Newbie
Posts: 5
Joined: Mon Jun 25, 2007 1:20 am

Post by sweeleen »

yeah....i got it run on my pc...i mean PHP 5.1.1 and the extension with 5.1.1 too. It is my fault tht running the wrong php.ini file....

Thanks guys.

But now i have another question to ask, if I still want to use PHP 5.2.3. How should i recompile my PHP?
Any one know how to recompile, can you please share with me?
Post Reply