Hi all,
Can anybody take a look at my code and tell me as to why i'm getting an error?
The following is my code
The error which i am getting is: mb_strlen() expects parameter 1 to be string, array given .
Can anybody take a look at my code and tell me as to why i'm getting an error?
The following is my code
public function actionCreate() { $connection=Yii::app()->db; $model=new BusType; $model2=new BusProducts; // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); //Get the number of models you will be working with $maxRows =count($_POST['quantity']); if(isset($_POST['BusType'])) { $model->attributes=$_POST['BusType']; $model2->attributes=$_POST['BusProducts']; if($model->save()) { $bus_type_id=$model->bus_type_id; for ($i = 0; $i < $maxRows ; $i++) { $quantity = $_POST['quantity'][$i]; $product_id = $_POST['product_id'][$i]; $cat_id = $_POST['cat_id'][$i]; $subcat_id = $_POST['subcat_id'][$i]; $sql = "insert into bus_products (bus_type_id,quantity,product_id,cat_id,subcat_id) values (:bus_type_id,:quantity,:product_id,:cat_id,:subcat_id)"; $command=$connection->createCommand($sql); $command->bindParam(":bus_type_id",$bus_type_id,PDO::PARAM_INT); $command->bindParam(":quantity",$quantity,PDO::PARAM_INT); $command->bindParam(":product_id",$product_id,PDO::PARAM_INT); $command->bindParam(":cat_id",$cat_id,PDO::PARAM_INT); $command->bindParam(":subcat_id",$subcat_id,PDO::PARAM_INT); $command->execute(); } $this->redirect(array('view','id'=>$model->bus_type_id)); } } $this->render('create',array( 'model'=>$model, 'model2'=>$model2, )); }
The error which i am getting is: mb_strlen() expects parameter 1 to be string, array given .