php - Mysql errors while sending contact form -
i errors
warning: mysqli_close() expects 1 parameter, 0 given in /home1/ab61859/public_html/contact.php on line 143 and
warning: cannot modify header information - headers sent (output started @ /home1/ab61859/public_html/contact.php:143) in /home1/ab61859/public_html/contact.php on line 144
my php code here http://pastebin.com/4kvr7bg1
i have no idea did wrong, please me thanks, itsmeromian
in following code (which pastebin link above):
foreach($form_data $name=>$value) { mysqli_query($db, "update $mysql_table set $name='".mysqli_real_escape_string($db, $value)."' id=$id") or die('failed update table!<br>'.mysqli_error($db)); } mysqli_close(); header('location: '.$success_url); exit;
you need put connection or link handle generated during connection in mysqli_close() statement knows 1 close (i.e. can have more 1 open @ time). if change snippet use following line close error should go away.
mysqli_close($db);
once close error goes away redirect header issues on next line may work. may because if have other output happening before issue header continue fail. headers can used when web page has not generated other non-header output.
as side note may want build 1 large sql string instead of doing database update each field returned. however, that's food more learning and/or future question.
Comments
Post a Comment