0

In my php code, two ways,

('#201707',$cont_array[$i],'N') or ('#201707','$cont_array[$i]','N') failed during insert into table hpc_review

$transmit_next="<input  value='allDel' type='button'><br>John<br>snow<br>stack<br>";
$cont_array = explode("<br>", $transmit_next);
for($i=1;$i<count($cont_array);$i++)
{
    $query="insert into hpc_review (sysnum,handler,stat) values ('#201707',$cont_array[$i],'N');";
    $stat = $conn->query($query);
}
3
  • 1
    What is the error? Commented Jul 24, 2017 at 8:23
  • Can you include the error please? Commented Jul 24, 2017 at 8:24
  • I made mistake. In hpc_review,handler is int ,but cont_array[$i] is var Commented Jul 24, 2017 at 9:03

3 Answers 3

2

The solution is:

  $query="insert into hpc_review (sysnum,handler,stat) values ('#201707','".$cont_array[$i]."','N');";
Sign up to request clarification or add additional context in comments.

1 Comment

I made mistake. In hpc_review,handler is int ,but cont_array[$i] is var .
1

Try something like this:

$query="insert into hpc_review (sysnum,handler,stat) values ('#201707','" . $cont_array[$i] . "','N');";

But should use MySQLi driver and prepared statements, see: http://php.net/manual/en/mysqli.quickstart.prepared-statements.php

Comments

0

IF $cont_array[$i] is a string :

 $query="insert into hpc_review (sysnum,handler,stat) values ('#201707','{$cont_array[$i]}','N');";

if $cont_array[$i] is integer like ID:

 $query="insert into hpc_review (sysnum,handler,stat) values ('#201707',{$cont_array[$i]},'N');";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.