2013-05-30 77 views
-5

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a2121694/public_html/cbox/fb_lib/connect.php on line 12PHP錯誤。如何解決它?

Invalid session ID

任何人都知道熱解決我的錯誤一直試圖這個,但我無法解決它。缺乏知識huhu

<?php 
require './fb_connect.php'; 
include('../config.php'); 
$fb = new fbConnect(); 
if(!$fb->output) { 
header("Location:".$fb->getLoginUrl()); 
} else { 




$userInfo = $fb->getUserInfo(); 
$_SESSION['ses_id'] = md5(microtime()); 
$user = mysql_query("SELECT * FROM `".DB_PREFIX."user_accounts` WHERE `fbid`='".$userInfo['id']."'"); 
$buid = $userInfo['id']; 
if(mysql_num_rows($user)>0) { 
$userdata = mysql_fetch_assoc($user); 
if($userdata['last_request_time']<=(time()-10800)) { 
mysql_query("INSERT INTO `".DB_PREFIX."chats` VALUES('','Hello ! Welcome back to ".GLOBAL_NAME.", <b> ".$userdata['fbname']." </b><img src=\'http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/6.gif\'> You\'re Back! :)<br/><a href=\'http://www.barkadafm.net/view.php?link=http://www.txtmyt.com\' target=\'_blank\'><img src=\'http://bfm.chatmode.info/images/txtmyt.png\' width=\'480px\' alt=\'Free Unlimited Text to All Networks @ TXTMYT.COM\'/></a>','164790013558517','normal','".time()."')"); 
} 
mysql_query("UPDATE `".DB_PREFIX."user_accounts` SET 
`gender` = '".$userInfo['gender']."', 
`ses_id` = '".$_SESSION['ses_id']."', 
`active` = '1', 
`sign_time` = CURRENT_TIMESTAMP, 
`last_request_time` = '".time()."', 
`ip_address` = '".$_SERVER['REMOTE_ADDR']."' 
WHERE `fbid`='".$userInfo['id']."'"); 



} else { 
mysql_query("INSERT INTO `".DB_PREFIX."user_accounts` VALUES('', 
'".$userInfo['id']."', 
'".$userInfo['name']."', 
'".$userInfo['gender']."', 
'0', 
'".$_SESSION['ses_id']."', 
'1', 
CURRENT_TIMESTAMP, 
'".time()."', 
'".$_SERVER['REMOTE_ADDR']."','0','0')"); 
mysql_query("INSERT INTO `".DB_PREFIX."chats` VALUES('','Lets all Welcome,<b> ".$userInfo['name']." </b>:) Welcome sa BarkadaFM! <img src=\'http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/6.gif\'><br/><a href=\'http://www.barkadafm.net/view.php?link=http://www.txtmyt.com\' target=\'_blank\'><img src=\'http://bfm.chatmode.info/images/txtmyt.png\' width=\'480px\' alt=\'Free Unlimited Text to All Networks @ TXTMYT.COM\'/></a>','164790013558517','normal','".time()."')"); 
} 
if(isset($_SESSION['ses_id'])) { 
$getUserInfo = mysql_query("SELECT * FROM `".DB_PREFIX."user_accounts` WHERE `ses_id`='".$_SESSION['ses_id']."'"); 
if(mysql_num_rows($getUserInfo)>0) { 
while($data=mysql_fetch_assoc($getUserInfo)) { 
$_SESSION['fbid'] = $data['fbid']; 
$_SESSION['name'] = $data['fbname']; 
$_SESSION['gender'] = $data['gender']; 
$_SESSION['acctype'] = $data['acctype']; 
} 
} else { 
die("Invalid Session ID"); 
} 
?> 
<script> 
window.opener.location.href="../index.php"; 
self.close(); 
</script> 
<?php 
    } 
} 
    ?> 
+0

檢查您的查詢 – wazy

回答

-1

此查詢結果不正確?因爲如果它不是,並且返回一個錯誤,那麼你的下一行將不起作用。

$getUserInfo = mysql_query("SELECT * FROM `".DB_PREFIX."user_accounts` WHERE `ses_id`='".$_SESSION['ses_id']."'"); 

嘗試在查詢後回顯mysql_error()。

順便說一句,你可能想看看mysqli。

-1

相反的:

$user = mysql_query("SELECT * FROM `".DB_PREFIX."user_accounts` WHERE `fbid`='".$userInfo['id']."'"); 

$sql = "SELECT * FROM `".DB_PREFIX."user_accounts` WHERE `fbid`='".$userInfo['id']."'"; 

$result = mysql_query($sql); 
if (!$result) { 
    $message = '<b>Invalid query:</b><br>' . mysql_error() . '<br><br>'; 
    $message .= '<b>Whole query:</b><br>' . $sql . '<br><br>'; 
    die($message); 
} 

該錯誤是最有可能在呈現一個MySQL錯誤SQL語句,這會告訴你哪一個。

+0

它給了我這個錯誤致命錯誤:調用未定義的函數raise_error()在/home/a2121694/public_html/cbox/fb_lib/connect.php在線24 – Krad

+0

改變了一下,請再試一次: - ) – Borniet

+0

你能幫助我嗎?即時堆棧12小時已經只是一個新手:D – Krad