2015-09-07 19:52
浏览 62


I'm trying to select a row from a table using mysqli but all I can get is a bunch of null values and I don't really know why. The same query works using normal php mysql and if I try to perform the same query on phpMyAdmin using the parameter I pass goes through fine.

Here's the code:

$con = mysqli_connect('localhost', 'user', 'pass',"db");

if (mysqli_connect_errno()){
    die("Failed to connect to MySQL: " . mysqli_connect_error());
$coupon = $_GET['coupon'];
$sql = mysqli_prepare($con, "SELECT * FROM coupon WHERE coupon=?");
$sql->bind_param('s', $coupon);
echo $sql;



I already tried to search for an answer either here and on google but I couldn't find anything close to my problem. What am I doing wrong?

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

我正在尝试使用mysqli从表中选择一行,但我能得到的是一堆空值 我真的不知道为什么。 相同的查询使用普通的php mysql工作,如果我尝试使用参数在phpMyAdmin上执行相同的查询,我会通过罚款。

这是代码: \ n

  $ con = mysqli_connect('localhost','user','pass',“db”); 
 die(“无法连接到MySQL:  “.mysqli_connect_error()); 
 $ coupon = $ _GET ['coupon']; 
 $ sql = mysqli_prepare($ con,”SELECT * FROM coupon WHERE coupon =?“); 
 $ sql-  > bind_param('s',$ coupon); 
 $ sql-> execute(); 
 $ sql-> store_result(); 
echo $ sql; 
   \  ñ


 <代码> “affected_rows”:空,
 “个param_count”:空 ,
 “SQLSTATE”:空,\ N “标识”:空

我已经尝试在这里和谷歌搜索答案,但我找不到任何接近我问题的答案。 我做错了什么?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题