sql - mysqli_real_escape_string with mysqli_num_rows in php -


my problem count sql .

<input name='d_n[]'>  <input name='d_n[]'> 

php page

post value adam's

foreach($ds_director $key => $director){   // problem here //   $dnumsql = "select * list ds_name = ?";   $stmt = $con -> prepare($dnumsql);   $stmt -> bind_param('s',$director);   $stmt -> execute();   $dnum = $stmt->num_rows;   echo "$dnum"; // result again '0'   /////////////   if($dnum == 0){       $director_sql = mysqli_real_escape_string($con,ucwords($director));       $dsql =  "insert movie_ds (ds_m_name, ds_name, ds_status) values ('$director_sql', '$m_name', 'yönetmen')";       $dquery = mysqli_query($con,$dsql);        if($dquery){         echo "<p style='color:green'>good</p>";       }else{         echo mysqli_error($con);       } }else{      echo "<p style='color:red;'>not save</p>"; } } 

because of problem same value recorded

update problem editted = array input

better use prepare statement this. automatically escape string , prevent sql injection

$sql = 'select * list d_n =?'; $stmt =$con->prepare($sql); $stmt->bind_param('s', $_post['d_n']); $stmt->execute(); $numrows = $stmt->num_rows; 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -