未将数据插入表中,但正在加载php文件。目标C $con = mysql_connect($DB_HostName,$DB_User,$DB_Pass); mysql_select_db("$DB_Name"); $email = $_GET['email']; $userid = $_GET['userid']; $bname = $_GET['bname']; $bgenre = $_GET['bgenre']; $bio = $_GET['bio']; $sql = "insert into $DB_Table (bname, bgenre, bio, userid) values('$bname', '$bgenre','$bio','$userid') select userid from $DB_Table2 where email = '$email'; $res = mysql_query($sql,$con); mysql_close($con); if($res) { echo"You created a band!"; }else{ echo"Band account wasn't created"; } ?>
我正在尝试创建一个与登录我的应用程序的用户绑定的组帐户。所有代码都正常运行,并且正在连接到数据库,但由于某些原因,它不会将新组插入到我的数据库表中。这是我到目前为止得到的。任何帮助都将不胜感激。 php文件未将数据插入表中,但正在加载php文件。目标C $con = mysql_connect($DB_HostName,$DB_User,$DB_Pass); mysql_select_db("$DB_Name"); $email = $_GET['email']; $userid = $_GET['userid']; $bname = $_GET['bname']; $bgenre = $_GET['bgenre']; $bio = $_GET['bio']; $sql = "insert into $DB_Table (bname, bgenre, bio, userid) values('$bname', '$bgenre','$bio','$userid') select userid from $DB_Table2 where email = '$email'; $res = mysql_query($sql,$con); mysql_close($con); if($res) { echo"You created a band!"; }else{ echo"Band account wasn't created"; } ?>,php,ios,mysql,objective-c,Php,Ios,Mysql,Objective C,我正在尝试创建一个与登录我的应用程序的用户绑定的组帐户。所有代码都正常运行,并且正在连接到数据库,但由于某些原因,它不会将新组插入到我的数据库表中。这是我到目前为止得到的。任何帮助都将不胜感激。 php文件 $con = mysql_connect($DB_HostName,$DB_User,$DB_Pass); mysql_select_db("$DB_Name"); $email = $_GET['email'];
$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass);
mysql_select_db("$DB_Name");
$email = $_GET['email'];
$userid = $_GET['userid'];
$bname = $_GET['bname'];
$bgenre = $_GET['bgenre'];
$bio = $_GET['bio'];
$sql = "insert into $DB_Table (bname, bgenre, bio, userid) values('$bname', '$bgenre','$bio','$userid')
select userid from $DB_Table2 where email = '$email';
$res = mysql_query($sql,$con);
mysql_close($con);
if($res) {
echo"You created a band!";
}else{
echo"Band account wasn't created";
}
?>
vc1.h
vc3.m
vc3.h
您的PHP甚至看起来都无效。上下文中的SQL也没有。看起来您试图同时运行两个查询。把它们分开。另外,停止使用mysql函数,因为它们已经被弃用,并且从PHP7开始被删除。将函数迁移为使用PDO或mysqli。如下所示:$sql=insert到$DB_Table bname、bgenre、bio、userid值“$bname”、“$bgenre”、“$bio”、“$res2”;$sql1=从$DB_表2中选择userid,其中email='$email';$res2=mysqli\u查询$sql1,$con;$res=mysqli\u查询$sql,$con;是的,那可能会更好。操作仍然不起作用
#import <UIKit/UIKit.h>
#import "loginUserViewController.h"
@interface Home : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *username;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *Nav;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *logout;
-(IBAction)logout:(id)sender;
-(IBAction)bandHome:(id)sender;
@end
#import "Home.h"
#import "loginUserViewController.h"
@interface Home ()
@end
@implementation Home
@synthesize username, band1, band2, band3;
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self){
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
loginUserViewController *object = [[loginUserViewController alloc]init];
NSString *string = [[NSString alloc] initWithFormat:@"%i",[object.email.text intValue]];
username.text = string;
}
#import "loginUserViewController.h"
#import "Home.h"
#import "AppDelegate.h"
#import "createBandViewController.h"
@interface loginUserViewController ()
@end
@implementation loginUserViewController
@synthesize email, password;
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
}
- (void)viewDidload
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[self setEmail:nil];
[self setPassword:nil];
[super viewDidUnload];
}
-(IBAction)loginUser:(id)sender {
if ([email.text isEqualToString:@""] || [password.text isEqualToString:@""])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"Please Fill all the field" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
return;
}
NSMutableString *strURL = [[NSMutableString alloc] initWithFormat:@"http://cgi.soic.indiana.edu/~team54/login2.php?email=%@&password=%@", email.text, password.text ];
[strURL setString:[strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
NSMutableString *strResult = [[NSMutableString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
NSLog(@"logging in");
if ([strResult isEqualToString:@"1"])
{
NSLog(@"Logged in!");
[self performSegueWithIdentifier:@"login" sender:self];
}else
{
// invalid information
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"Invalide Information" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
return;
}
email.text = @"";
password.text = @"";
}
#import <UIKit/UIKit.h>
@interface createBandViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *bname;
@property (weak, nonatomic) IBOutlet UITextField *bgenre;
@property (weak, nonatomic) IBOutlet UITextField *bio;
@property (weak, nonatomic) IBOutlet UIButton *createBand;
-(IBAction)addBand:(id)sender;
@end