Can not write to MySQL table
i haven't been able write record mysql database table; tried numerous php code lines without success must missing.
the lines above statement if(!testerr) { -- other tests of data input on form , work correctly. if reason testing of input fails, $tester set 't' , user returned form.
otherwise following should executed.
to check, added $_session lines @ top ensure vars ($taker , $purpose in $sql= statement filled.
when the /* attempt connection sequence executed , $_session not present, no data written table.
when $_session included along write table code, resultant 'success' header('location: ' ."inv_post.php"); page presents errors (invalid index in $taker=$_session['taker'].
when $_session executed not write code, success page executes echo $taker , $purpose appropriately.
regards , always.
tom smith
here code. if(!testerr) within -- if ($_server["request_method"] == "post") {} --section of code
if (!$testerr) {
$_session['taker']= $taker;
$_session['purpose'] = $purpose;
/* attempt mysql server connection.
$link = mysqli_connect("localhost","root","","112fielda_sitemgt");
// check connection
if($link === false){
die("error: not connect. " . mysqli_connect_error());
}
// attempt insert query execution
$sql = "insert bev_inventories
(bev_inv_id, bev_inv_taker, bev_inv_purpose)
values
(null, $taker, $purpose)";
if(mysqli_query($link, $sql)){
echo "records added successfully.";
} else {
echo "error: not able execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
*/
header('location: ' ."inv_post.php");
}
in first message, sentence @ top should read:
if reason testing of input fails, $testerr set 't' , user returned form. (so auto-fill!) $testerr in code error condition flag.
tom
More discussions in Dreamweaver support forum
adobe
Comments
Post a Comment