hyster Posted January 12, 2011 Share Posted January 12, 2011 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> Quote Link to comment Share on other sites More sharing options...
punk_runner Posted January 12, 2011 Share Posted January 12, 2011 Here's your first problem // Microsoft Access 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"; } Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 12, 2011 Share Posted January 12, 2011 Here's your first problem // Microsoft Access hahahaa. :-) Quote Link to comment Share on other sites More sharing options...
hyster Posted January 12, 2011 Author Share Posted January 12, 2011 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 Quote Link to comment Share on other sites More sharing options...
hyster Posted January 12, 2011 Author Share Posted January 12, 2011 sorted. used my code and all i did was move $rs->MoveNext(); to just above the } in the loop. thanks for helping Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.