我有一个用户access_token的数据库,我做了代码,确保如果数据库中已经存在新的用户访问令牌,它应该显示错误我试图做一个循环并将if语句放在其中但它不起作用。
<?php
mysql_connect("localhost", "___", "___");
mysql_select_db("___");
session_start();
require_once ('twitteroauth/twitteroauth.php');
require_once ('config.php');
if (empty($_SESSION['access_token']) ||
empty($_SESSION['access_token']['oauth_token']) ||
empty($_SESSION['access_token']['oauth_token_secret'])) {
header('Location: ./clearsessions.php');
}
$access_token = $_SESSION['access_token'];
$connection = new TwitterOAuth(CONSUMER_KEY,
CONSUMER_SECRET,
$access_token['oauth_token'],
$access_token['oauth_token_secret']);
$content = $connection->get('account/verify_credentials');
$u = "SELECT * FROM users";
$uu = mysql_query($u);
while ($uuu = mysql_fetch_object($uu))
{
foreach($uuu->access_token as $ali)
{
if ($access_token['oauth_token'] != $ali)
{
$newuser = "INSERT INTO users(access_token,access_token_secret)
VALUES ('{$access_token['oauth_token']}',
'{$access_token['oauth_token_secret']}' )";
$donewuser = mysql_query($newuser);
include ('html.inc');
}
else
{
echo "error";
}
}
}