PHP和SQL无法正确返回

时间:2015-11-11 21:06:14

标签: php sql

我正在尝试从SQL数据库中提取三个字符的字符串并将其存储为会话,但它无法正常工作。

这是我请求SQL查询并设置会话的地方

func combineImages( card: Card ) -> UIImage
{
    let bottomImage: UIImage = UIImage( named: "cardFront" )!


    var textColor: UIColor = UIColor.blackColor()
    var textFont: UIFont = UIFont(name: "Muli", size: 120 )!

    UIGraphicsBeginImageContext( bottomImage.size )

    let textFontAttributes = [
        NSFontAttributeName: textFont,
        NSForegroundColorAttributeName: textColor,
    ]

    bottomImage.drawInRect( CGRectMake(0, 0, bottomImage.size.width, bottomImage.size.height) )

    var rect: CGRect = CGRectMake( 50, 48, 380, 360 )

    var drawText = "\( card.pictureName )"
    drawText.drawInRect( rect, withAttributes: textFontAttributes )

    // Create a new image out of the images we have created
    var newImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()

    // End the context now that we have the image we need
    UIGraphicsEndImageContext()


    return newImage


}

这是我尝试开会的地方:

$verified_query = mysql_query("SELECT verified FROM `members` WHERE username = '$myusername'");
$verified = mysql_result($verified_query, 0); // 0 is the index of the field, not the row

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION["myusername"] = $myusername;
$_SESSION["mypassword"] = $mypassword;
$_SESSION["verified"] = $verified;
header("location:index.php");
}
else {
echo "Wrong Username or Password";
}
?>

1 个答案:

答案 0 :(得分:2)

$verified = mysql_result($verified_query, 0); // 0 is the index of the field, not the row

// Mysql_num_row is counting table row
$count=mysql_num_rows($verified); <- Error was here