duanlei2458 2017-07-29 18:08
浏览 53

未定义的变量:第17行的C:\ xampp \ htdocs \ training.php中的sql [重复]

I'm trying to get the id and storing it in a variable but it shows me that the variable is not defined and the query is not execute because of the variable , I'm not understand why.

   include 'connect.php';
   if(isset($_GET['OrgName']))
   {
     $file=$_GET['OrgName'];

$sql="SELECT oraganzation.OrgName,oraganzation.City,oraganzation.OrgEmail,oraganzation.OrgPhoneNO, oraganzation.Workfield, oraganzation.Trainingrecruitment, oraganzation.WebsiteLink,Student_comments.comment
 FROM oraganzation , Student_comments
 WHERE oraganzation.OrgName=$file  AND oraganzation.OrgID=Student_comments.OrgID ";  
 }
 $result= mysqli_query($con,$sql) or die ("could not found; ".mysqli_error ($con));

while ($row=mysqli_fetch_array($result) )
 {

  echo "<br><strong> Name : </strong>". $row['OrgName'].
 "<br><strong>
 <br><strong> City : </strong>". $row['City'].
 "<br><strong>
 Email: </strong>" . $row['OrgEmail'].
"<br><strong>
PhoneNO: </strong>". $row['OrgPhoneNO'].
 "<br> <strong>
Work field: </strong> " . $row['Workfield'].
"<br><strong>
Training recruitment:</strong> " . $row['Trainingrecruitment'].
"<br> <strong>
Website Link: </strong> " . $row['WebsiteLink'].
 "<br> <strong>
Comments: </strong> "  .$row['comment']. "<br>" ;

  }

And this is my code from previous page that I put the a href for get the name

    $sql="SELECT OrgName, City, OrgEmail, OrgPhoneNO, Workfield, Trainingrecruitment, WebsiteLink,OrgID
  FROM oraganzation";

 $result= mysqli_query($con,$sql) or die ("could not found; ".mysqli_error($con));

 while ($row=mysqli_fetch_array($result) )
 {

?>

 <div class="content "> 
<a href="training.php?name=<?php echo $row['OrgName'] ?> "><?php echo $row['OrgName'] ;?> </a>

        <?php
echo "<br><strong> City : </strong>". $row['City'].
    "<br><strong>
   Email: </strong>" . $row['OrgEmail'].
   "<br><strong>
   PhoneNO: </strong>". $row['OrgPhoneNO'].
  "<br> <strong>
   Work field: </strong> " . $row['Workfield'].
 "<br><strong>
 Training recruitment:</strong> " . $row['Trainingrecruitment'].
  "<br> <strong>
   Website Link: </strong> " . $row['WebsiteLink']. 


    "</div> ";} ?>
</div>
  • 写回答

1条回答 默认 最新

  • dqmhgz5848 2017-07-29 18:11
    关注

    $sql is defined only if

    if(isset($_GET['OrgName']))
    

    You should move the closing brace after $sql, to after running the query, or define the $sql even if OrgName is not set

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题