dongyuan1984
2017-07-10 16:53
浏览 102
已采纳

INNER JOIN:注意:显示未定义的索引

I have two table temp_bid and post_project. I want records who bid on projects. and for that, I have made a query using INNER JOIN but, getting Undefined Index error. It works in MySQL editor.

Here is my code.

<?php
include 'conn.php';
session_start();
if ($_SESSION['EmailID'] == "") {
    header("location:index.html");
}

$getTempBid = "SELECT * from temp_bid TB INNER JOIN post_project P ON P._id = TB.prj_id " + 
" WHERE TB.bidBy = '" .$_SESSION['EmailID']."'";

$tempBidResult = mysqli_query($conn,$getTempBid);

while($fetchTempBid = mysqli_fetch_row($tempBidResult)) {
    $tempBidId = $fetchTempBid['tempBidId'];
    $tempBidPrjId = $fetchTempBid['prj_id'];
    $tempBidPostBy = $fetchTempBid['postBy'];
    $tempBidBy = $fetchTempBid['bidBy'];
    $tempBidOn = new DateTime($fetchTempBid['bidOn']);
    $tempBidAmount = $fetchTempBid['amount'];
    $tempBidDays = $fetchTempBid['days'];
    $tempBidProposalDetails = $fetchTempBid['proposalDetails'];
    $tempBidStatus = $fetchTempBid['bidStatus'];
    $prjId = $fetchTempBid['_id'];
    $prjTitle = $fetchTempBid['projectTitle'];
    $prjDescriptions = $fetchTempBid['projectDescriptions'];
    $prjSkills = $fetchTempBid['projectRequiredSkill'];
    $prjSkills1 = explode(",", $prjSkills);
    $prjBudget = $fetchTempBid['projectBudget'];
    $prjPostDate = new DateTime($fetchTempBid['projectCreatedOn']);
    $prjStatus = $fetchTempBid['projectStatus'];
}
$records = mysqli_num_rows($tempBidResult);
?>

Output:

Notice: Undefined index: tempBidId in C:\wamp\www\Gopinath Infosystem\testpage.php on line 23
Notice: Undefined index: prj_id in C:\wamp\www\xxx\testpage.php on line 24
Notice: Undefined index: postBy in C:\wamp\www\xxx\testpage.php on line 25
Notice: Undefined index: bidBy in C:\wamp\www\xxx\testpage.php on line 26
Notice: Undefined index: bidOn in C:\wamp\www\xxx\testpage.php on line 27
Notice: Undefined index: amount in C:\wamp\www\xxx\testpage.php on line 28
Notice: Undefined index: days in C:\wamp\www\xxx\testpage.php on line 29

图片转代码服务由CSDN问答提供 功能建议

我有两个表 temp_bid post_project 。 我想要投标项目的记录。 为此,我使用INNER JOIN进行了查询,但得到了Undefined Index错误。 它适用于MySQL编辑器。

这是我的代码。

 &lt;?php 
include'conn.php'; 
session_start  (); 
if($ _SESSION ['EmailID'] ==“”){
 header(“location:index.html”); 
} 
 
 $ getTempBid =“SELECT * from temp_bid TB INNER JOIN  post_project P ON P._id = TB.prj_id“+ 
”WHERE TB.bidBy ='“。$ _ SESSION ['EmailID']。”'“; 
 
 $ tempBidResult = mysqli_query($ conn,$ getTempBid)  ; 
 
while($ fetchTempBid = mysqli_fetch_row($ tempBidResult)){
 $ tempBidId = $ fetchTempBid ['tempBidId']; 
 $ tempBidPrjId = $ fetchTempBid ['prj_id']; 
 $ tempBidPostBy = $ fetchTempBid [  'postBy']; 
 $ tempBidBy = $ fetchTempBid ['bidBy']; 
 $ tempBidOn = new DateTime($ fetchTempBid ['bidOn']); 
 $ tempBidAmount = $ fetchTempBid ['amount']; 
  $ tempBidDays = $ fetchTempBid ['days']; 
 $ tempBidProposalDetails = $ fetchTempBid ['proposalDetails']; 
 $ tempBidStatus = $ fetchTempBid ['bidStatus']; 
 $ prjId = $ fetchTempBid ['_ id'];  
 $ prjTitle = $ fetchTempBid ['projectTitle']; 
 $ prjDescriptions  = $ fetchTempBid ['projectDescriptions']; 
 $ prjSkills = $ fetchTempBid ['projectRequiredSkill']; 
 $ prjSkills1 = explode(“,”,$ prjSkills); 
 $ prjBudget = $ fetchTempBid ['projectBudget'];  
 $ prjPostDate = new DateTime($ fetchTempBid ['projectCreatedOn']); 
 $ prjStatus = $ fetchTempBid ['projectStatus']; 
} 
 $ records = mysqli_num_rows($ tempBidResult); 
?&gt; \  n   
 
 

输出:

 注意:未定义的索引:tempBidId在C:\ wamp中 \ www \ Gopinath Infosystem \ testpage.php第23行
通知:未定义的索引:第24行的C:\ wamp \ www \ xxx \ testpage.php中的prj_id 
通知:未定义的索引:postBy in C:\ wamp \ www \ 第25行的xxx \ testpage.php 
注意:第26行的C:\ wamp \ www \ xxx \ testpage.php中未定义的索引:bidBy 
注意:未定义的索引:C:\ wamp \ www \ xxx \ testpage中的bidOn。 第27行的php 
通知:未定义的索引:第28行的C:\ wamp \ www \ xxx \ testpage.php中的数量
通知:未定义的索引:第29行的C:\ wamp \ www \ xxx \ testpage.php中的天数 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanlu1908 2017-07-10 16:59
    已采纳

    mysqli_fetch_row returns an array with numeric keys. From the documentation:

    Fetches one row of data from the result set and returns it as an enumerated array, where each column is stored in an array offset starting from 0 (zero). Each subsequent call to this function will return the next row within the result set, or NULL if there are no more rows.

    Use mysqli_fetch_assoc instead to return an array with the keys being the column names.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题