第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

安照2-6和2-7課上講的代碼完全寫了一遍還是出問題,不知如何是好所以才麻煩老師費(fèi)點(diǎn)心了

userlist.php 代碼?? 麻煩老師幫看一下運(yùn)行的時(shí)候顯示http://img1.sycdn.imooc.com//5768fb4e0001483612790229.jpg

<?php
header('content-type:text/html;charset=utf-8');
$mysqli?=?new?mysqli('127.0.0.1','root','YOUNI258','books');
if($mysqli->connect_errno){
????die($mysqli->connect_error);
}
$mysqli->set_charset('utf8');
$sql="select?*?from?user;";
$mysqli_result=$mysqli->query($sql);
if($mysqli_result?&&?$mysqli_result->num_rows>0){
????while($row=$mysqli_result->fetch_assoc()){
????????$rows[]=$row;
????}
}
?????>
????<!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
????<html?xmlns="http://www.w3.org/1999/xhtml"?xml:lang="en">
????<head>
????????<meta?http-equiv="Content-Type"?content="text/html;charset=UTF-8"?/>
????????<title>Document</title>
????</head>
????<h2>用戶列表-<a?href="adduser.php">添加用戶</a></h2>
????<body>
????????<table?border="1"?cellpadding="0"?cellspacing="0"?bgcolor="aqua"?width="80%">
????????????<tr>
????????????????<td>編號(hào)</td>
????????????????<td>用戶名</td>
????????????????<td>年齡</td>
????????????????<td>操作</td>
????????????</tr>
????????????<?php?$i=1;?foreach($rows?as?$row):?>
????????????<tr>
????????????????<td><?php?echo?$i;?></td>
????????????????<td><?php?echo?$row['username'];?></td>
????????????????<td><?php?echo?$row['age'];?></td>
????????????????<td><a?href="update.php">更新</a>|<a?href="deluser.php">刪除</a></td>
????????????</tr>
????????????<?php?$i++;?endforeach;?>
????????</table>
????</body>
????</html>

adduser.php這個(gè)文件的代碼

<!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Transitional//EN"?"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html?xmlns="http://www.w3.org/1999/xhtml"?xml:lang="en">
<head>
????<meta?http-equiv="Content-Type"?content="text/html;charset=UTF-8"?/>
????<title>Document</title>
</head>
<body>
????<h2>添加用戶</h2>
????<form?action="action.php?act=adduser"?method="post">
????????<table?border="1"?cellpadding="0"?cellspacing="0"?bgcolor="aquamarine"?width="80%">
????????????<tr>
????????????????<td>用戶名</td>
????????????????<td><input?type="text"?name="username"?id="username"?required="required"?placeholder="請輸入合法用戶名"?/></td>
????????????</tr>
????????????????<tr>
????????????????<td>密碼</td>
????????????????<td><input?type="password"?name="password"?id="password"?required="required"?placeholder="請輸入密碼"?/></td>
????????????</tr>
????????????????<tr>
????????????????<td>年齡</td>
????????????????<td><input?type="number"?name="age"?id="age"?required="required"?placeholder="請輸入合法年齡"?/></td>
????????????</tr>
????????????????<tr>
????????????????<td?colspan="2"><input?type="submit"?value="添加用戶"?/></td>
????????????</tr>
????????</table>
????????
????????
????</form>
????
????
????
</body>
</html>

這個(gè)是action.php的代碼

這是action.php運(yùn)行時(shí)出現(xiàn)的錯(cuò)誤,我的mysql密碼是YOUNI258 帳號(hào)是root? 數(shù)據(jù)庫是books

這是我數(shù)據(jù)庫的數(shù)據(jù)

mysql> select * from user;
+----+----------+----------+-----+
| id | username | password | age |
+----+----------+----------+-----+
|? 1 | 第一個(gè)?? |????????? |? 18 |
|? 2 | 第二個(gè)?? |????????? |? 19 |
|? 3 | 第三個(gè)?? |????????? |? 20 |
|? 4 | 第四個(gè)?? |????????? |? 21 |
|? 5 | 第五個(gè)?? |????????? |? 22 |
|? 6 | 第六個(gè)?? |????????? |? 23 |
|? 7 | 第七個(gè)?? |????????? |? 24 |
|? 8 | 第八個(gè)?? |????????? |? 25 |
|? 9 | 第九個(gè)?? |????????? |? 26 |

mysql> desc user;
+----------+---------------------+------+-----+---------+----------------+
| Field??? | Type??????????????? | Null | Key | Default | Extra????????? |
+----------+---------------------+------+-----+---------+----------------+
| id?????? | tinyint(3) unsigned | NO?? | PRI | NULL??? | auto_increment |
| username | varchar(20)???????? | NO?? |???? | NULL??? |??????????????? |
| password | varchar(20)???????? | NO?? |???? | NULL??? |??????????????? |
| age????? | tinyint(3) unsigned | NO?? |???? | NULL??? |??????????????? |
+----------+---------------------+------+-----+---------+----------------++----+----------+----------+-----+


正在回答

1 回答

我知道錯(cuò)誤在哪里了?? mysql的權(quán)限設(shè)置模式? window系統(tǒng)的.my.ini找到此關(guān)鍵字

第一種:數(shù)據(jù)庫設(shè)計(jì)時(shí),為可能沒有數(shù)據(jù)的字段設(shè)置默認(rèn)值。

第二種:設(shè)置SQL的模式,此有兩種方法:

(1),配置my.ini,去掉:STRICT_TRANS_TABLES

my.ini配置代碼
# Set the SQL mode to strict
# sql-mode="STRICT_TRANS_TABLES,NO_AUTO_Create_USER,NO_ENGINE_SUBSTITUTION"
sql-mode="NO_AUTO_Create_USER,NO_ENGINE_SUBSTITUTION"

(2),運(yùn)行SQL命令。注:此命令需要權(quán)限!

SQL代碼
SET @@GLOBAL.sql_mode="NO_AUTO_Create_USER,NO_ENGINE_SUBSTITUTION";
因?yàn)楸容^擅長用Phpmyadmin 所以直接運(yùn)行了SQL的命令,問題解決。

然后把它修改成NO_AUTO_Create_USER,NO_ENGINE_SUBSTITUTION? 之后的都明白了。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

安照2-6和2-7課上講的代碼完全寫了一遍還是出問題,不知如何是好所以才麻煩老師費(fèi)點(diǎn)心了

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)