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
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";

 

}

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.