我被嘗試插入數據在SQL DB使用PHP,但它不工作。告訴我這裏有什麼問題SQL插入不工作在PHP
SQL代碼在這裏
CREATE TABLE `billing` (
`user_id` int(10) UNSIGNED NOT NULL,
`student_name` varchar(9) NOT NULL,
`student_roll` varchar(9) NOT NULL,
`student_batch_ID` varchar(9) NOT NULL,
`students_course` varchar(9) NOT NULL,
`students_payble_ammount` varchar(9) NOT NULL,
`payment_recived_date` varchar(9) NOT NULL,
`ammount_recived_by` varchar(9) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
HTML和PHP代碼在這裏所有的
<form method="post" action="<?php $_PHP_SELF ?>" name="new-Billing-Info-entry-form" id="new_record_form" class="border-style-1" enctype="multipart/form-data">
<label class="form-label-FOR-student-name border-style-1">Name:</label>
<input type="text" name="input_s_name" class="form-input-FOR-student-name border-style-1 form-control" placeholder="Enter Student Name"/>
<br/><br/>
<label class="form-label-FOR-student-name border-style-1">Roll:</label>
<input class="form-input-FOR-student-name border-style-1 form-control" type="text" name="input_s_roll" placeholder="Enter Roll Number"/>
<br/><br/>
<label class="form-label-FOR-student-name border-style-1">Batch:</label>
<input class="form-input-FOR-student-name border-style-1 form-control" type="text" name="input_s_batch" placeholder="Enter Batch Number"/>
<br/><br/>
<label class="form-label-FOR-student-name border-style-1">Course:</label>
<input name="input_s_course" type="text" class="form-input-FOR-student-name border-style-1 form-control" placeholder="Enter Course Name"/>
<br/><br/>
<label class="form-label-FOR-student-name border-style-1">Ammount:</label>
<input name="input_s_payble_ammount" type="text" class="form-input-FOR-student-name border-style-1 form-control" placeholder="Enter Payble Ammount"/>
<br/><br/>
<label class="form-label-FOR-student-name border-style-1">Date:</label>
<input id="input-date" class="form-input-FOR-student-name border-style-1 form-control" type="text" name="input_s_paid_date" placeholder="Select Billing Date"/>
<br/><br/>
<button type="submit" class="btn btn-primary save-btn-1" name="s_payment_info_save_btn">LOOKS GOOD, Save</button>
</form>
<?php if(isset($_POST['s_payment_info_save_btn'])!="")
{
$mysql_hostname = "localhost";
$billing_phpmyadmin_uid = "root";
$billing_phpmyadmin_pass = "";
$billing_db_Name = "student_billing";
$billing_db_connection = mysql_connect($mysql_hostname, $billing_phpmyadmin_uid, $billing_phpmyadmin_pass, $billing_db_Name);
$input_student_name = mysql_real_escape_string($_POST['input_s_name']);
$input_student_roll = mysql_real_escape_string($_POST['input_s_roll']);
$input_student_batch = mysql_real_escape_string($_POST['input_s_batch']);
$input_student_course = mysql_real_escape_string($_POST['input_s_course']);
$input_student_payble_ammount = mysql_real_escape_string($_POST['input_s_payble_ammount']);
$input_student_paid_date = mysql_real_escape_string($_POST['input_s_paid_date']);
if(!$billing_db_connection){
echo "<script type='text/javascript'> $(window).load(function(){ $('#modal_billing_DB_connection_error').modal('show'); }); </script>";
exit();
}else{
/* echo "<script type='text/javascript'> $(window).load(function(){ $('#modal_billing_DB_connection_success').modal('show'); }); </script>"; */
}
$billing_data_insert = "INSERT INTO `billing` (`student_name`, `student_roll`, `student_batch_id`, `students_course`, `students_payble_ammount`, `payment_recived_date`) VALUES ($input_student_Name, $input_student_roll, $input_student_batch, $input_student_course, $input_student_payble_ammount, $input_student_paid_date)";
if(!$billing_data_insert){
echo "<script type='text/javascript'> $(window).load(function(){ $('#modal_bill_successfully_generate_notification').modal('show'); }); </script>";
}else{
echo "<script type='text/javascript'> $(window).load(function(){ $('#modal_bill_error_generate_notification').modal('show'); }); </script>";
}
echo "<br/>", $input_student_name, "<br/>", $input_student_roll, "<br/>", $input_student_batch, "<br/>", $input_student_course, "<br/>", $input_student_payble_ammount, "<br/>", $input_student_paid_date;
mysql_close($billing_db_connection);
}
任何人都請回答 –