RE: PHP and MSSQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



yes, it's possible. I'm learning php myself. (I'm a CF junkie.)

I got this script from somewhere. I have the info on a backup CD at home.
I'll post it if you're having problems with the script below. (I did a
google for: ODBC connection mySQL, or something similar to that.)

The script below is what I adapted for my purposes.

You have to go to (I'm using Win2000, yours would be similar, but
necessarily the same)

START >
CONTROL PANEL >
ADMINISTRATIVE TOOLS >
DATA SOURCES (ODBC) >
SYSTEM DSN : ADD [select Access]; enter the name; click "select" and give
the path to your db.

Once again, if you're not using Win2000 the above will be slightly
different.

The php is below:

<?php


	function monthly() {
		/*
			Make the connection to the database. The syntax is
			odbc_connect( 'SYSTEM_DSN' , 'USER', 'PASSWORD' );
			$cnx will hold the
			pconnect is used to establish a persistent database
			connection to the Database until the procedure is completed.
		*/

		$cnx = odbc_connect( 'SYSTEM_DSN' , 'root', '' );
		if (!$cnx) {
			Error_handler( "Error in odbc_connect" , $cnx );
		}

		// send a simple odbc query . returns an odbc cursor
		$cur= odbc_exec( $cnx,
					"

					SELECT yourFieldName1, yourFieldName2, yourFieldName3
					FROM table

					" );
		if (!$cur) {
			Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
		}

		// fetch the succesive result rows
		while( odbc_fetch_row( $cur ) ) {

			$yourFieldName1= odbc_result( $cur, 1 );
			$yourFieldName2= odbc_result( $cur, 2 );
			$yourFieldName3= odbc_result( $cur, 3 );

			echo"

				$yourFieldName1 -- $yourFieldName2 -- $yourFieldName3<br>

				";
			}

		// close the connection. important if persistent connection are "On"
		odbc_close( $cnx);
	 }

?>

<html>
<head>
	<title></title>
	<link href="internal.css" title="new" type="text/css" rel="stylesheet">
	<style>

	</style>
</head>
<body>

<div id="left"><?php include ("nav.php"); ?></div>
<div id="center">

<?php

	monthly();
?>

</div>

</body>
</html>


--glm



-----Original Message-----
From: DragonEye WebDesign [mailto:webmaster@xxxxxxxxxxxxxxxxxxx]
Sent: Wednesday, December 31, 2003 4:08 AM
To: php-db@xxxxxxxxxxxxx
Subject:  PHP and MSSQL


hi,

I have been learning PHP and MySQL from a book that I have bought. I am
really pleased with the way these 2 systems work, but I was wondering if
MSSQL wouldn't be easier to use, more specifically I was wondering wether I
could make an Access Database and connect it to my php website using MSSQL.

I heard it would be possible

And now I ask the experts... :-)

grtz

DragonEye

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-----Original Message-----
From: DragonEye WebDesign [mailto:webmaster@xxxxxxxxxxxxxxxxxxx]
Sent: Wednesday, December 31, 2003 4:08 AM
To: php-db@xxxxxxxxxxxxx
Subject:  PHP and MSSQL


hi,

I have been learning PHP and MySQL from a book that I have bought. I am
really pleased with the way these 2 systems work, but I was wondering if
MSSQL wouldn't be easier to use, more specifically I was wondering wether I
could make an Access Database and connect it to my php website using MSSQL.

I heard it would be possible

And now I ask the experts... :-)

grtz

DragonEye

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux