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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何獲取只有當(dāng)前登錄用戶之前輸入數(shù)據(jù)庫的數(shù)據(jù)?

如何獲取只有當(dāng)前登錄用戶之前輸入數(shù)據(jù)庫的數(shù)據(jù)?

PHP
MMMHUHU 2022-07-22 16:58:22
我在開發(fā)方面相當(dāng)新,因為在此之前我所做的只是管理數(shù)據(jù)庫。我想出了一個系統(tǒng),它將擁有三種類型的用戶。行政管理用戶通過將用戶角色管理到登錄中,我已成功創(chuàng)建多用戶登錄頁面。但我目前遇到的問題是,我無法查看只有當(dāng)前用戶之前提交的數(shù)據(jù)。例如,我有兩個用戶,Ariel 和 Lyla。我想要做的是,當(dāng) Ariel 登錄系統(tǒng)時,Ariel 只能看到她提交到數(shù)據(jù)庫的內(nèi)容,至于目前,她可以看到提交的全部數(shù)據(jù)。我已經(jīng)這樣做了$sql = "SELECT * FROM iirincidentmain_draft WHERE username='$_SESSION[user][username]'";但作為回報我得到了這個錯誤注意:數(shù)組到字符串的轉(zhuǎn)換我的完整代碼如下<?phpsession_start();//Checking User Logged or Notif(empty($_SESSION['user'])){ header('location:../index.php');}//Restrict admin or Moderator to Access user.php pageif($_SESSION['user']['role']=='admin'){ header('location:../admin/index.php');}if($_SESSION['user']['role']=='management'){ header('location:../management/index.php');}require_once("../db.php");?><div class="col-md-9 bg-white padding-2"><h3>Reports in Draft</h3>    <div class="row margin-top-20">      <div class="col-md-12">       <div class="box-body table-responsive no-padding">        <table id="example" class="table table-striped table-bordered" style="width:100%">      <thead>        <th>Incident Date</th>        <th>OPU Region Or Country</th>        <th>Incident Title</th>                              <th>Incident Category</th>        <th>Status</th>        <th>Draft IIR</th>        <th>Edit</th>      </thead>      <tbody>            <?php$sql = "SELECT * FROM iir_incidentmain_draft WHERE username='$_SESSION[user][username]'";  $result = $conn->query($sql);     if($result->num_rows > 0) {        while($row = $result->fetch_assoc())          {?>         <tr>有人可以給我建議嗎?
查看完整描述

1 回答

?
jeck貓

TA貢獻(xiàn)1909條經(jīng)驗 獲得超7個贊

更改此行:

$sql = "SELECT * FROM iir_incidentmain_draft WHERE username='$_SESSION[user][username]'";

成為:

$sql = "SELECT * FROM iir_incidentmain_draft WHERE username='" . $_SESSION['user']['username'] . "'";

換句話說,您在會話中的鍵中缺少引號的錯字。在將數(shù)組值附加到字符串時,也有必要(我認(rèn)為)使用點表示法。因此,您得到的字符串轉(zhuǎn)換錯誤可能是由于解析器僅$SESSION在嵌入外部雙引號時才看到的。

其他人可能會注意到你應(yīng)該逃避這一切。轉(zhuǎn)義用戶名的有效方法是設(shè)置 sql 準(zhǔn)備語句。


查看完整回答
反對 回復(fù) 2022-07-22
  • 1 回答
  • 0 關(guān)注
  • 93 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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