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
sanv
Forum Newbie
Posts: 12 Joined: Thu Nov 01, 2007 12:43 pm
Post
by sanv » Thu Nov 01, 2007 12:48 pm
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
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Thu Nov 01, 2007 1:03 pm
That code looks ok. You might want to check above this code to see if your braces all match.
(#10850)
seppo0010
Forum Commoner
Posts: 47 Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina
Post
by seppo0010 » Thu Nov 01, 2007 1:30 pm
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 » Thu Nov 01, 2007 1:52 pm
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.
seppo0010
Forum Commoner
Posts: 47 Joined: Wed Oct 24, 2007 4:13 pm
Location: Buenos Aires, Argentina
Post
by seppo0010 » Thu Nov 01, 2007 2:00 pm
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 » Thu Nov 01, 2007 2:12 pm
oh ok. so how can i use adodb then, because it requires a try and catch