我正在做一个网站,我有2个不同的页面使用类似的代码,但只有1个可以工作,另一个似乎有错误“trim()期望参数1是字符串,对象在”...中给出
editimage.php链接到search.php链接到imagetoupdate.php
updateaccount.php链接到searchEmail.php,链接到accounttoupdate.php
可行的(updateaccount.php):
<form action="searchEmail.php" method="post">
<input type="text" name="email" style="color:#000000" placeholder="Enter email" />
<input type="submit" name="submit" style="color:#000000" value="Search">
</form>
可行的(searchEmail.php):
$email = $_POST['email'];
$emailTrim = trim($email);
$sql = "SELECT * FROM account WHERE Email = '$emailTrim'";
$search = mysqli_query ( $conn, $sql);
$emailfound = mysqli_num_rows($search);
if($emailfound >= 1)
{
$_SESSION['MM_email'] = $email;
header("Location:accountToUpdate.php");
}
else{
echo 'Email not found';
}
可行的(accounttoupdate.php):
$email = $_SESSION['MM_email'];
$emailTrim = trim($email);
$sql = "SELECT * FROM account WHERE Email = '$emailTrim'";
$account = mysqli_query ( $conn, $sql);
不可行(editimage.php):
<form action="search.php" method="post">
<input type="text" name="search" style="color:#000000" placeholder="Enter email/photo no./date" />
<input type="submit" name="submit" style="color:#000000" value="Search">
</form>
不可行(search.php):
$search = $_POST['search'];
$searchTrim = trim($search);
$sql = "SELECT * FROM upload_data WHERE UploadedBy = '$searchTrim' OR photoNo = '$searchTrim' OR Datetime LIKE '%$searchTrim%'";
$search = mysqli_query ( $conn, $sql);
$searchfound = mysqli_num_rows($search);
if($searchfound >= 1)
{
$_SESSION['MM_image'] = $search;
header("Location:imageToUpdate.php");
}
else{
echo 'Invalid input';
}
不可行(imagetoupdate.php):
$search = $_SESSION['MM_image'];
$searchTrim = trim($search);
$sql = "SELECT * FROM upload_data WHERE UploadedBy = '$searchTrim' OR photoNo = '$searchTrim' OR Datetime LIKE '%$searchTrim%'";
$image_list = mysqli_query ( $conn, $sql);
答案 0 :(得分:0)
我认为问题在于search.php
。我想说你需要改变这个:
$_SESSION['MM_image'] = $search;
到此:
$_SESSION['MM_image'] = $searchTrim;