Page 1 of 1
catch error (SOLVED!)
Posted: Fri Dec 31, 2010 8:12 am
by DelPazzo
Hi,
How to catch this error:
Uncaught exception 'com_exception' with message '<b>Source:</b> ADODB.Field<br/><b>Description:</b> either BOF or EOF is True...
for this line:
I tried:
Code: Select all
if (trim($a->value) !="") {
echo 'hallo';
} else {
die("<tr><td>Keine Rechnung vorgemerkt</td></tr>");
}
but it does not work.
Re: catch error
Posted: Fri Dec 31, 2010 8:30 am
by social_experiment
If there is an exception that has been thrown, it needs to be caught
Code: Select all
<?php
try {
// execute code
}
catch (Exception $e) {
// display message
}
?>
In your case it might be something to the nature of :
Code: Select all
<?php
try {
//
$a = new Classname
if (trim($a->value) != "") {
echo 'Hallo';
}
else {
// error message
}
}
catch (Exception $e) {
echo $e->getMessage();
}
?>
Re: catch error
Posted: Fri Dec 31, 2010 8:41 am
by DelPazzo
that throws:
Class 'Classname' not found in
where you set: $a = new Classname
Re: catch error
Posted: Fri Dec 31, 2010 8:50 am
by social_experiment
Yes it will because my code is an example. $a->value indicates to me an object is involved so you have to instantiate an object first, which is what the line $a = new Classname does. You should substitute it (Classname) for the name of your class.
Re: catch error
Posted: Fri Dec 31, 2010 9:43 am
by DelPazzo
social_experiment wrote:Yes it will because my code is an example. $a->value indicates to me an object is involved so you have to instantiate an object first, which is what the line $a = new Classname does. You should substitute it (Classname) for the name of your class.
sorry... me noob. how to find out which class it is?

Re: catch error
Posted: Fri Dec 31, 2010 10:05 am
by anantha
you can try to use get_class()...see php website for the list of functions that can be used....
Re: catch error
Posted: Sat Jan 01, 2011 5:01 am
by social_experiment
anantha wrote:you can try to use get_class()
I think this will only work if an object has been instantiated.
Code: Select all
<?php
class foo {
function name()
{
echo "My name is " , get_class($this) , "\n";
}
}
// create an object
$bar = new foo();
// external call
echo "Its name is " , get_class($bar) , "\n";
// internal call
$bar->name();
?>
Is there any additional code that you can paste?
Re: catch error
Posted: Sat Jan 01, 2011 6:43 am
by DelPazzo
this is the only code that comes before:
Code: Select all
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr); //Open the connection to the database
$recordSet = &$conn->Execute('SELECT max(uebkunden.id) as id, translat.rechid, uebkunden.name FROM translat INNER JOIN uebkunden ON translat.kunde = uebkunden.id WHERE (translat.rechid <> 0) AND (translat.rechn = 1) AND (translat.druck = 0) group by uebkunden.id, uebkunden.name, translat.rechid order by rechid');
if (trim($a->value) !="") {
Re: catch error
Posted: Sat Jan 01, 2011 7:54 am
by social_experiment
What happens if you modify the code like the sample below
Code: Select all
<?php
//
try {
$recordSet = &$conn->Execute('SELECT max(uebkunden.id) as id, translat.rechid, uebkunden.name FROM translat INNER JOIN uebkunden ON translat.kunde = uebkunden.id WHERE (translat.rechid <> 0) AND (translat.rechn = 1) AND (translat.druck = 0) group by uebkunden.id, uebkunden.name, translat.rechid order by rechid');
// rest of the code
}
catch (Exception $e) {
echo $e->getMessage();
}
?>
Re: catch error
Posted: Sat Jan 01, 2011 9:07 am
by DelPazzo
that works perfectly....
thx a lot.
here is the complete code now working as it should:
Code: Select all
try {
$recordSet = &$conn->Execute('SELECT max(uebkunden.id) as id, translat.rechid, uebkunden.name FROM translat INNER JOIN uebkunden ON translat.kunde = uebkunden.id WHERE (translat.rechid <> 0) AND (translat.rechn = 1) AND (translat.druck = 0) group by uebkunden.id, uebkunden.name, translat.rechid order by rechid');
$a = $recordSet->fields['name'];
if (trim($a->value) !="") {
echo '<tr><td><form name="marken" method="post"> ';
Echo ' <select size="1" name="kunde" onChange="document.marken.submit();">';
Echo ' <option value="">---Auswahl---</option> ';
while (!$recordSet->EOF) {
Echo ' <option value="'.$recordSet->fields['id'].'" ';
Echo ' >'.$recordSet->fields['name'].' '.$recordSet->fields['rechid'].'</option> ';
$recordSet->MoveNext();
}
echo ' </select></td></tr>';
}
}
catch (Exception $e) {
echo ' <tr><td>Keine Rechnung vorgemerkt</td></tr>';
}