Jump to content

Catchable fatal error:


hyster

Recommended Posts

im getting this error "Catchable fatal error: Object of class variant could not be converted to string in C:\wamp\www\mdb\1mdb.php on line 36"

<td><?php echo $make; ?></td>

no matter what i use as the query it always shows this error on the last row even a query that has 3 results it only shows the 1st 1(every other row echo's fine). its not a problem with the data as i switch between asc and dsc in the query every row shows at some point.

im thinking that maybe the looping needs to be told to stop, but i can n ot find any info that makes sense to me on google.

 

thanks

<?php
$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); 

// Microsoft Access connection string.
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\wamp\\www\\mdb\\one.mdb");

// SQL statement to build recordset.
$rs = $conn->Execute("SELECT * from OneTouchImaging where make like 'toshiba' order by sku");
?>
<table border="1">
<?php
// Display all the values in the records set
while (!$rs->EOF) { 

  $make = $rs->Fields["Make"]; 
  $model = $rs->Fields["Model"]; 
    $cpu = $rs->Fields["Cpu"]; 
    $disksize = $rs->Fields["DiskSize"]; 
    $bios = $rs->Fields["BIOS"]; 
    $sku = $rs->Fields["SKU"]; 
    $user = $rs->Fields["User"]; 
    
    
    $model->value."<br>\n";
    $make->value."<br>\n"; 
    $cpu->value."<br>\n";
    $disksize->value."<br>\n";
    $bios->value."<br>\n";
    $sku->value."<br>\n";
    $user->value."<br>\n";
    $rs->MoveNext();

?>

<tr>
<td><?php echo $make; ?></td> 
<td><?php echo $model; ?></td>
<td><?php echo $cpu; ?></td> 
<td><?php echo $disksize; ?></td>
<td><?php echo $bios; ?></td> 
<td><?php echo $sku; ?></td>
<td><?php echo $user; ?></td>
<?php
} 
$rs->Close(); 
?>
</tr>
</table>

Link to comment
https://forums.phpfreaks.com/topic/224182-catchable-fatal-error/
Share on other sites

Here's your first problem

 

// Microsoft Access

 

:P

 

Second, instead of the while loop, try this:

 

foreach ($rs as $Fields) {

 

    $make = $Fields["Make"]  . "<br>\n";

    $model = $Fields["Model"] . "<br>\n";

    $cpu = $Fields["Cpu"] . "<br>\n"; 

    $disksize = $Fields["DiskSize"] . "<br>\n";

    $bios = $Fields["BIOS"] . "<br>\n";

    $sku = $Fields["SKU"] . "<br>\n";

    $user = $Fields["User"] . "<br>\n";

 

}

 

gives me this error now. i have not seen an error like this before

 

Fatal error: Uncaught exception 'Exception' with message 'Object of type variant did not create an Iterator' in C:\wamp\www\mdb\1mdb.php:14 Stack trace: #0 C:\wamp\www\mdb\1mdb.php(14): unknown() #1 {main} thrown in C:\wamp\www\mdb\1mdb.php on line 14

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.