我試圖做一個註冊表單。在這一刻,我試圖將輸入數據插入到數據庫中。我得到語法錯誤,意外的'{'in ..我無法找到錯誤的地方..請幫助看看我的代碼。順便說一句,這是我編輯的問題,我之前發佈的關於空白頁錯誤的代碼..對不起,我英文破碎。 :d語法錯誤,意想不到的'{'
partner_registration.php:
<?PHP
error_reporting(0);
include ('connect.php');
if(isset($_POST['submit']))
{
// The form is submitted
$c_name = ($_POST['txtName']);
$c_type = ($_POST['selType']);
$c_no = ($_POST['txtNo']);
$c_address = ($_POST['txtAddress']);
$c_city = ($_POST['txtCity']);
$c_postcode = ($_POST['txtPostcode']);
$c_state = ($_POST['selState']);
$c_country = ($_POST['selCountry']);
$c_email = ($_POST['txtEmail']);
$c_phone = ($_POST['txtPhone']);
$c_fax = ($_POST['txtFax']);
$c_name = $mysqli->real_escape_string($c_name);
$c_type = $mysqli->real_escape_string($c_type);
$c_no = $mysqli->real_escape_string($c_no);
$c_address = $mysqli->real_escape_string($c_address);
$c_city = $mysqli->real_escape_string($c_city);
$c_postcode = $mysqli->real_escape_string($c_postcode);
$c_state = $mysqli->real_escape_string($c_state);
$c_country = $mysqli->real_escape_string($c_country);
$c_email = $mysqli->real_escape_string($c_email);
$c_phone = $mysqli->real_escape_string($c_phone);
$c_fax = $mysqli->real_escape_string($c_fax);
// attempt insert query execution
if ($insert = $mysqli->query ("INSERT INTO tblpartner (companyName, companyRegistration, companyNo, companyAddress, companyCity, companyPostCode, companyState, companyCountry, companyEmail, companyPhone, companyFax) VALUES ('$c_name', '$c_type', '$c_no', '$c_address', '$c_city','$c_postcode', '$c_state', '$c_country', '$c_email', '$c_phone', '$c_fax')")
{
echo("Success", $mysqli->affected_rows);
}
}
?>
connect.php:
<?php
$hostname="localhost"; //local server name default localhost
$username="root"; //mysql username default is root.
$password="1234"; //blank if no password is set for mysql.
$database="intrasystem"; //database name which you created
//Open a new connection to the MySQL server
$mysqli = new mysqli('localhost','root','1234','intrasystem');
//Output any connection error
if($mysqli->connect_errno)
{
die('Cannot connect to database');
}
?>
你能看到錯誤日誌嗎? – raygo
'$ con'是一個對象。在所有情況下使用OOP。這個'$ c_name = mysqli_real_escape_string($ con,$ _POST ['txtName']);'是程序性的。 – chris85
閱讀'bind_param'手冊並檢查它的第一個參數。這是一個像'sssi''或類似的字符串。 –