我正在尝试从我的 MySQL 数据库进行查询,这是代码
<?php
$link = new MySQLi('localhost','root','Rrtynt','copy');
if(isset($_POST['id'])){
$name = $_POST['id'];
$profile = 'profile';
$thestring = $name.$profile;
//echo $thestring;
$result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$name'");
echo $result;
}
?>
查询代码
$result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$name'");
在不同的 php 脚本中使用相同的代码,但它一直给我 http 500 错误,我使用它从 javascript 文件发布
$.post("/getfirstfolder.php", { id: value1 }, function (data) {
cop = data;
console.log("Data: " + data);
});
如果我拿出来
$result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$name'");
只需 echo $thestring 就可以了,我无法找出问题所在,所以感谢您的宝贵时间,非常感谢您的帮助
最佳答案
您提到 $thestring 的事实让我认为也许您应该使用 $thestring 作为查询的参数,如下所示:
$result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$thestring'");
关于javascript - 来自 php 的 mysql 查询不起作用,但它在不同的 php 文件中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36673470/