Page 1 of 1

PHP adodb - what is wrong

Posted: Thu Nov 01, 2007 12:48 pm
by sanv
hey,

i am trying to make a connection to a MS access database using adodb with the following code:

Code: Select all

$conn = new COM("ADODB.Connection");
	
	try
	{
		$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=".realpath("bla.mdb").";");
		$rs = new COM("ADODB.Recordset");
		$rs->Open("SELECT us, ps FROM users", $conn, 0, 1);
	
		while(!$rs->EOF) 
		{ 
			if(($usrname == $rs->Fields('us')->value) && ($pwd == $rs->Fields('ps')->value))
			{
				$rs->Close();
				$conn->Close();
				$rs = null;
				$conn = null;
				header('Location: test.php');
				exit();
			}
			$rs->MoveNext();
		} 
		
		$rs->Close();
		$conn->Close();
		$rs = null;
		$conn = null;
		header('Location: index.php');
		exit();
	} 
	catch( Exception $exception ) 
	{
		die("database error");
	}
I get the following error message:

Parse error: syntax error, unexpected '{' in test.php on line 8

Thanks for the forthcoming help

Posted: Thu Nov 01, 2007 1:03 pm
by Christopher
That code looks ok. You might want to check above this code to see if your braces all match.

Posted: Thu Nov 01, 2007 1:30 pm
by seppo0010
Which one is line 8?
Are you running PHP 5, right?

Posted: Thu Nov 01, 2007 1:52 pm
by sanv
You might want to check above this code to see if your braces all match
they all match.

line 8 is straight after the try statement.

i think my webserver runs php4 something, if i run the code locally it runs without any problem.

Posted: Thu Nov 01, 2007 2:00 pm
by seppo0010
PHP 4 doesn't support try-catch, that's the error that is pointing...

Posted: Thu Nov 01, 2007 2:12 pm
by sanv
oh ok. so how can i use adodb then, because it requires a try and catch

Posted: Thu Nov 01, 2007 4:31 pm
by seppo0010
I haven't work with adodb. You might want to search for some PHP 4 class for doing this... I've found http://sourceforge.net/project/showfile ... e_id=34890 this, but I haven't test it