[英]mysql query from php isnt working but it works in a different php file
我正在嘗試從我的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'");
只是回聲$ thestring它工作正常,我無法找出問題,因此感謝您的寶貴時間,我們非常感謝您的幫助
您提到$ thestring的事實使我認為也許應該將$ thestring用作查詢的參數,如下所示:
$result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$thestring'");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.