查看PHP7.1官方文檔,對(duì)這種錯(cuò)誤的解釋
創(chuàng)新互聯(lián)建站專注于滴道企業(yè)網(wǎng)站建設(shè),自適應(yīng)網(wǎng)站建設(shè),商城開發(fā)。滴道網(wǎng)站建設(shè)公司,為滴道等地區(qū)提供建站服務(wù)。全流程定制設(shè)計(jì),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)
New E_WARNING and E_NOTICE errors have been introduced when invalid strings are coerced using operators expecting numbers (+ - * / ** % | ^) or their assignment equivalents. An E_NOTICE is emitted when the string begins with a numeric value but contains trailing non-numeric characters, and an E_WARNING is emitted when the string does not contain a numeric value.
在使用(+ - * / ** % | ^) 運(yùn)算時(shí),例如a+b,如果a是開始一個(gè)數(shù)字值,但包含非數(shù)字字符(123a),b不是數(shù)字值開始時(shí)(b456),就會(huì)有A non-numeric value encountered警告。
你的里面年月日的表達(dá)用了-,php認(rèn)為是減號(hào),年月日被認(rèn)為是運(yùn)算。
你可以搜一下網(wǎng)上的教程有解決辦法。不過看你的截圖,這只是個(gè)notice, 你可以在控制器加上ini_set("error_reporting","E_ALL ~E_NOTICE");?就不會(huì)顯示了。
html
head
title瀏覽表中記錄/title
/head
body
center
?php
$db_host=localhost; //MYSQL服務(wù)器名
$db_user=root; //MYSQL用戶名
$db_pass=""; //MYSQL用戶對(duì)應(yīng)密碼
$db_name="test"; //要操作的數(shù)據(jù)庫
//使用mysql_connect()函數(shù)對(duì)服務(wù)器進(jìn)行連接,如果出錯(cuò)返回相應(yīng)信息
$link=mysql_connect($db_host,$db_user,$db_pass)or die("不能連接到服務(wù)器".mysql_error());
mysql_select_db($db_name,$link); //選擇相應(yīng)的數(shù)據(jù)庫,這里選擇test庫
$sql="select * from test1"; //先執(zhí)行SQL語句顯示所有記錄以與插入后相比較
$result=mysql_query($sql,$link); //使用mysql_query()發(fā)送SQL請(qǐng)求
echo "當(dāng)前表中的記錄有:";
echo "table border=1"; //使用表格格式化數(shù)據(jù)
echo "trtdID/tdtd姓名/tdtd郵箱/tdtd電話/tdtd地址/td/tr";
while($row=mysql_fetch_array($result)) //遍歷SQL語句執(zhí)行結(jié)果把值賦給數(shù)組
{
echo "tr";
echo "td".$row[id]."/td"; //顯示ID
echo "td".$row[name]." /td"; //顯示姓名
echo "td".$row[mail]." /td"; //顯示郵箱
echo "td".$row[phone]." /td"; //顯示電話
echo "td".$row[address]." /td"; //顯示地址
echo "/tr";
}
echo "/table";
?
/center
/body
/html
!--表單文件,拷入index.php--
!DOCTYPE?html
html
head
style
label{display:inline-block;width:100px;margin-bottom:10px;}
/style
titleAdd?students/title
/head
body
!--?數(shù)據(jù)庫用mysqli?面向過程調(diào)用方法--
form?method="post"?action="write2db.php"
!--數(shù)據(jù)庫用mysqli?面向過程調(diào)用方法
form?method="post"?action="write2db_sqlio.php"
--
!--數(shù)據(jù)庫用PDO調(diào)用方法
form?method="post"?action="write2db_pdo.php"
--
labelFirst?Name/label
input?type="text"?name="first_name"?/
br?/
labelLast?Name/label
input?type="text"?name="last_name"?/
br?/
labeldepartment/label
input?type="text"?name="department"?/
br?/
labelEmail/label
input?type="text"?name="email"?/
br?/
input?type="submit"?value="Add?students"
/form
/body
/html
------------------------------
?php
//拷貝命名為write2db.php,數(shù)據(jù)庫用mysqli?面向過程調(diào)用方法
//print_r($_POST);
//?create?a?variable
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$department=$_POST['department'];
$email=$_POST['email'];
//調(diào)試用
echo?"Your?input:?";
echo?$first_name;
echo?'br?/';
echo?$last_name;
echo?'br?/';
echo?$department;
echo?'br?/';
echo?$email;
echo?'br?/';
$servername?=?"localhost";
//Your?database?username?and?password
//$username?=?"username";
//$password?=?"password";
$username?=?"tester";
$password?=?"testerPassword";
//your?database?name
$dbname?=?"test";
$tablename?="student";
//?Create?connection
$connect?=?mysqli_connect($servername,?$username,?$password,?$dbname);
if?(!$connect)?{
die("Connection?failed:?"?.?mysqli_connect_error());
}
//Execute?the?query
$sql="INSERT?INTO?$tablename?(first_name,last_name,department,email)
VALUES('$first_name','$last_name','$department','$email')";
if?(mysqli_query($connect,?$sql))?{
echo?"Hooray!?New?record?is?inserted?to?database?successfully.?Please?check?database.";
}?else?{
echo?"Error:?"?.?$sql?.?"br?/"?.?mysqli_error($connect);
}
mysqli_close($connect);
?
?php
//拷貝命名為write2db_sqlio.php,數(shù)據(jù)庫用mysqli?面向?qū)ο笳{(diào)用方法
//print_r($_POST);
//?create?a?variable
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$department=$_POST['department'];
$email=$_POST['email'];
//調(diào)試用
echo?"Your?input:?";
echo?$first_name;
echo?'br?/';
echo?$last_name;
echo?'br?/';
echo?$department;
echo?'br?/';
echo?$email;
echo?'br?/';
$servername?=?"localhost";
//Your?database?username?and?password
//$username?=?"username";
//$password?=?"password";
$username?=?"tester";
$password?=?"testerPassword";
//database?name
$dbname?=?"test";
$tablename?="student";
//?Create?connection
$conn?=?new?mysqli($servername,?$username,?$password,?$dbname);
//?Check?connection
if?($conn-connect_error)?{
die("Connection?failed:?"?.?$conn-connect_error);
}?
$sql="INSERT?INTO?$tablename?(first_name,last_name,department,email)
VALUES('$first_name','$last_name','$department','$email')";
if?($conn-query($sql)?===?TRUE)?{
echo?"New?record?created?successfully";
}?else?{
echo?"Error:?"?.?$sql?.?"br"?.?$conn-error;
}
$conn-close();
?
?php
//拷貝為文件write2db_pdo.php,數(shù)據(jù)庫用PDO調(diào)用方法
//print_r($_POST);
a?variable
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$department=$_POST['department'];
$email=$_POST['email'];
//調(diào)試用
echo?"Your?input:?";
echo?$first_name;
echo?'br?/';
echo?$last_name;
echo?'br?/';
echo?$department;
echo?'br?/';
echo?$email;
echo?'br?/';
$servername?=?"localhost";
//Your?database?username?and?password
//$username?=?"username";
//$password?=?"password";
$username?=?"tester";
$password?=?"testerPassword";
//your?database?name
$dbname?=?"test";
$tablename?="student";
//?Create?connection
try?{
$conn?=?new?PDO("mysql:host=$servername;dbname=$dbname",?$username,?$password);
//?set?the?PDO?error?mode?to?exception
$conn-setAttribute(PDO::ATTR_ERRMODE,?PDO::ERRMODE_EXCEPTION);
$sql="INSERT?INTO?$tablename?(first_name,last_name,department,email)
VALUES('$first_name','$last_name','$department','$email')";
//?use?exec()?
$conn-exec($sql);
echo?"New?record?created?successfully";
}
catch(PDOException?$e)
{
echo?$sql?.?"br"?.?$e-getMessage();
}
$conn?=?null;
?
--創(chuàng)建數(shù)據(jù)庫test,?將此文件存為test.sql?導(dǎo)入數(shù)據(jù)庫,或者手動(dòng)創(chuàng)建表結(jié)構(gòu)
--?phpMyAdmin?SQL?Dump
--?version?4.7.4
--?
--
--?Host:?127.0.0.1:3306
--?Generation?Time:?Mar?12,?2018?at?04:04?AM
--?Server?version:?5.7.19
--?PHP?Version:?7.1.9
SET?SQL_MODE?=?"NO_AUTO_VALUE_ON_ZERO";
SET?AUTOCOMMIT?=?0;
START?TRANSACTION;
SET?time_zone?=?"+00:00";
/*!40101?SET?@OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT?*/;
/*!40101?SET?@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS?*/;
/*!40101?SET?@OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION?*/;
/*!40101?SET?NAMES?utf8mb4?*/;
--
--?Database:?`test`
--
--?--------------------------------------------------------
--
--?Table?structure?for?table?`student`
--
DROP?TABLE?IF?EXISTS?`student`;
CREATE?TABLE?IF?NOT?EXISTS?`student`?(
`id`?tinyint(3)?UNSIGNED?NOT?NULL?AUTO_INCREMENT,
`first_name`?varchar(20)?NOT?NULL,
`last_name`?varchar(20)?NOT?NULL,
`department`?varchar(50)?NOT?NULL,
`email`?varchar(50)?NOT?NULL,
PRIMARY?KEY?(`id`)
)?ENGINE=MyISAM?AUTO_INCREMENT=2?DEFAULT?CHARSET=utf8;
--
--?Dumping?data?for?table?`student`
--
INSERT?INTO?`student`?(`id`,?`first_name`,?`last_name`,?`department`,?`email`)?VALUES
(1,?'first1',?'last1',?'cs',?'1985@qq.com');
COMMIT;
/*!40101?SET?CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT?*/;
/*!40101?SET?CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS?*/;
/*!40101?SET?COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION?*/;
分享名稱:php7.1數(shù)據(jù)庫 php72
URL網(wǎng)址:http://jinyejixie.com/article22/hpdhjc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、商城網(wǎng)站、網(wǎng)站排名、微信公眾號(hào)、建站公司、定制網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容