dongshen9058 2014-05-24 07:49
浏览 4
已采纳

使用php查询无法正常工作

I really don't undestand what is happening in here, This the form that im using which ask for a studentcode = lz.

  <form action="classgrades.php?id=<?php echo $courseid ?>" method="post">
       <input type="text" name="studentCode" value="" placeholder="Student Code.." />
       <button type="submit" value="Submit">Submit</button> 
  </form>

and this query to select the data from the table

$studentcode = $_POST['studentCode']; 
 $query = "SELECT fname FROM students WHERE studentcode = $studentcode";

I don't undestand whay im getting this error

ErrorSQLSTATE[42S22]: Column not found: 1054 Unknown column 'lz' in 'where clause'

and if I try with a student code that is a number work, but not for letters

  • 写回答

1条回答 默认 最新

  • dtjbcda841554 2014-05-24 07:50
    关注

    If you want to give characters as values, then you have to enclose it in quotes. Try with

    $query = "SELECT fname FROM students WHERE studentcode = '$studentcode'";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统