jammer Posted April 8, 2008 Share Posted April 8, 2008 Hello i have a reentrant page that lists a bunch of orders and i am trying to delete an order but i keep getting the error Fatal error: Method name must be a string in /model/Order.php on line 33. Using PHP5 Any help would be appreciated. here is my list of orders code: <?php //Present a list of all orders. //Select and show an order. //Give the option to delete a selected order (which represents //the order having been processed). $top = dirname(dirname(__FILE__)); require_once "$top/model/Order.php"; require_once "$top/order-helper.php"; $param = array_merge( $_GET, $_POST ); $delButton = $param["delButton"]; $pass = $param["pass"]; //$radioChk = ($pass > 0) ? $param["radioChk"] : 0; /*This checks to see if an order is selected * if not the order is initialized to zero * */ if ($pass>0) { $radioChk = $param["radioChk"]; $OrderId = Order::find($radioChk); //finds specific order info from order ID Order::delete($OrderId); } else { $radioChk = 0; } $findAllOrders = Order::findAll(); //finds all orders //$OrderId = Order::find($radioChk); $file = basename($_SERVER['PHP_SELF']); $title = "Show and Delete Orders"; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title><?= $title ?></title> </head> <body> <h2><?= $title ?></h2> <form> <? foreach ($findAllOrders as $order) { echo "<hr />"; dump_order($order); echo "<br />"; $sel = ($radioChk) ? "checked" : ""; ?> <input type="hidden" name="pass" value="1" /> <input type="radio" name="radioChk" value="<?= $order['id'] ?>" <?= $sel ?> > <input type="submit" name="delButton" value="Delete" /> <? //$radioChk = $param["$radioChk"]; echo"id: $radioChk"; //for testing ?> OrderId: <?= $OrderId['id'] ?> <? } ?> </form> </table> </body> </html> for the above code i don't think i need the $OrderID for Order::delete($OrderId); I think i can just do Order::delete($param); But it still gives the same fatal error. here is my MySQL order code: <?php require_once "db/Database.php"; class Order { private static $table = "orders"; private static $table_def = "id INT AUTO_INCREMENT NOT NULL, user VARCHAR(20), items MEDIUMBLOB, created DATETIME, PRIMARY KEY(id)"; public function delete( $order ) { $cx = Database::connect(); $table = self::$table; $id = $order['radioChk']; if (!$cx->$query( "DELETE FROM $table WHERE id='$id'" ) ) throw new Exception($cx->error); } } ?> there error says it starts on line 33 (where the if statement starts) Any ideas? Link to comment https://forums.phpfreaks.com/topic/100144-mysql-delete-help/ Share on other sites More sharing options...
we4freelance Posted April 8, 2008 Share Posted April 8, 2008 Hello, I think you if statement should be like below if (!$cx->query( "DELETE FROM $table WHERE id='$id'" ) ) throw new Exception($cx->error); Please replace your if statement with above. Hope this helps. Thanks. We4freelance. Link to comment https://forums.phpfreaks.com/topic/100144-mysql-delete-help/#findComment-512196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.