2013-02-07 93 views
0

我有以下代碼:PHP腳本mysqli的神祕不工作

<?php 
session_start(); 
echo $_SESSION['Username']; 
$mysqli = new mysqli('****','****','****','****'); 
if($mysqli->errno) 
{ 
    mail("**@yahoo.com", "***/Account.php Connection Error", $mysqli->error . "\nUser: " . $_SESSION['Username']); 
} 
else 
{ 
    $stmt = $mysqli->prepare("SELECT FirstName, LastName, Expires, Expires WHERE EMail=?"); 
    $stmt->bind_param('s', $_SESSION['Username']); 
    $stmt->execute(); 
    $stmt->bind_result($FirstName, $LastName, $Expires); 
    $stmt->store_result(); 
    while($row = $stmt->fetch()) 
    { 
       .... 

我得到很奇怪的行爲。我收到錯誤Fatal error: Call to a member function bind_param() on a non-object in /home/content/42/7401242/html/****/Account.php on line 12

我用這個確切的代碼在許多其他的網頁和它完美的作品。任何想法爲什麼我可能會隨機得到這個錯誤?

回答

1

我不知道,如果你是電子郵件用戶名綁定之前錯過了FROM。還ü失蹤FROM條款

$stmt = $mysqli->prepare("SELECT FirstName, LastName, Expires from Expires WHERE EMail=?"); 
    $stmt->bind_param('s', $_SESSION['Username']); 
           ^^^^^^^^^^-----------------be sure if its email variable 
1

你的表名

SELECT FirstName, LastName, Expires FROM Expires WHERE EMail=?