dongxianrang9269 2014-09-01 00:04
浏览 39
已采纳

选择查询仅返回字符串直到空格

Here is my select query:

$username = $_GET['username'];
$stmt = $mysqli->prepare('SELECT email, phone, addressLine1, addressLine2, city, postcode            FROM users WHERE username = ?');
$stmt->bind_param('s', $username);

$stmt->execute();
$stmt->bind_result($email, $phone, $addressLine1, $addressLine2, $city, $postcode);
$stmt->fetch();
printf('<p>Address Line 1:</p> <input type="text" name="AddressLine1" value=%s><br>', $addressLine1);

However, instead of $addressLine1 giving the result "A test address" it will only give "A"

I have been at this for a while but haven't worked it out yet.

They are stored as VARCHARs in my DB.

EDIT: This is where i use addressLine1

printf('<p>Address Line 1:</p> <input type="text" name="AddressLine1" value=%s><br>', $addressLine1);
  • 写回答

2条回答 默认 最新

  • doulu4316 2014-09-01 00:07
    关注

    You have a space in your text and if you use that as an html attribute make sure and quote it else the attribute terminates at the first space

    printf('<p>Address Line 1:</p> <input type="text" name="AddressLine1" value="%s"><br>', $addressLine1);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿