-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 12

Invalid session ID

anyone knows hot to fix my error ive been trying this but i cant solve it. lack of knowledge 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
  }
 }
  ?>
Kumar V
  • 8,810
  • 9
  • 39
  • 58
Krad
  • 1

2 Answers2

-1

Is this query correct? Because if it isn't and returns an error then your next line won't work.

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

Try echoing mysql_error() after your query.

By the way you may want to look into mysqli.

wazy
  • 1,065
  • 1
  • 10
  • 23
-1

Instead of:

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

do

$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);
}

The error is most probably in your SQL statement which renders a MySQL error, this will show you which one.

Borniet
  • 3,544
  • 4
  • 24
  • 33
  • it gives me this error Fatal error: Call to undefined function raise_error() in /home/a2121694/public_html/cbox/fb_lib/connect.php on line 24 – Krad May 30 '13 at 06:33
  • Changed it a bit, please try again :-) – Borniet May 30 '13 at 06:35
  • could you help me. im stack 12 hrs already just a little bit newbie :D – Krad May 30 '13 at 06:40
  • Will try :-) Just replace the code by the new code I've posted here, and post the message you get. – Borniet May 30 '13 at 06:41
  • this Invalid query: Table 'a2121694_anonzc.scgfx_user_accounts' doesn't exist Whole query: SELECT * FROM `scgfx_user_accounts` WHERE `fbid`='100005636942940' – Krad May 30 '13 at 06:46
  • Well, there's your problem for ya: your database doesn't have any table named: 'a2121694_anonzc.scgfx_user_accounts' – Borniet May 30 '13 at 06:49
  • so it means i should make a table name? a2121694_anonzc.scgfx_user_accounts like this – Krad May 30 '13 at 06:57
  • I would guess that the prefix is messing things up. Is this a move of a db? – Borniet May 30 '13 at 06:57
  • would you help me and open my hosting and fix errors in my database and prefix. im already stack for 12 hrs hir huhu – Krad May 30 '13 at 07:00