PHP adodb - what is wrong

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
sanv
Forum Newbie
Posts: 12
Joined: Thu Nov 01, 2007 12:43 pm

PHP adodb - what is wrong

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

That code looks ok. You might want to check above this code to see if your braces all match.
(#10850)
User avatar
seppo0010
Forum Commoner
Posts: 47
Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina

Post by seppo0010 »

Which one is line 8?
Are you running PHP 5, right?
sanv
Forum Newbie
Posts: 12
Joined: Thu Nov 01, 2007 12:43 pm

Post 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.
User avatar
seppo0010
Forum Commoner
Posts: 47
Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina

Post by seppo0010 »

PHP 4 doesn't support try-catch, that's the error that is pointing...
sanv
Forum Newbie
Posts: 12
Joined: Thu Nov 01, 2007 12:43 pm

Post by sanv »

oh ok. so how can i use adodb then, because it requires a try and catch
User avatar
seppo0010
Forum Commoner
Posts: 47
Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina

Post 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
Post Reply