August 26, 200917 yr Hello all. Got a little problem with my script. Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, boolean given in /home2/irn3rdc/public_html/gorsehill/public_html/user1/index.php on line 106 The above is the error I'm getting when i process my script. if(empty($errors)) {//everything is okay // add the prodcut to the database. $q = 'INSERT INTO product(prod_id, prod_name, prod_desc, prod_price, prod_imagename, prod_dim) VALUES (NULL,"'.$prod_name.'","'.$prod_desc.'","'.$prod_price.'","'.$i.'","'.$prod_dim.'")'; $r = mysqli_query($dbc, $q); //check results line> 106 if (mysqli_affected_rows($r) == 1){ //true $thankyou[] = 'The print has been added'; //clear $_POST $_POST = array(); }else{ //error $errors[] = 'There has been a system error and your submission could not be processed'; } mysqli_close($dbc); }//end of errors if Line 106 is indicated, It is inserting the data into the database fine... just not like that mysqli_affected_rows if? any ideas? Ben
August 26, 200917 yr To quote from the php manual regarding the parameter you pass to mysqli_affected_rows(): Procedural style only: A link identifier returned by mysqli_connect() In other words, assuming $dbc is the variable for mysqli_connect, use $dbc instead of $r as the parameter for mysqli_affected_rows.
August 26, 200917 yr Author To quote from the php manual regarding the parameter you pass to mysqli_affected_rows(): In other words, assuming $dbc is the variable for mysqli_connect, use $dbc instead of $r as the parameter for mysqli_affected_rows. ElanMan to the rescue once again, Owe you one mate Worked like a charm Ben P.S , the penguin is a better look for you
August 26, 200917 yr P.S , the penguin is a better look for you What was wrong with my other look? I thought I looked really cool
Create an account or sign in to comment