我正在尝试将我的第一个php脚本连接到mysql数据库。我正在使用XAMPP作为我的服务器。 我不断收到消息“错误查询数据库”。
贝娄是我的代码。我真的很感激你的帮助。
//Below is how you connect to a database and insert data
//First create a variable with the connection commands so the query function you will use in a moment won't be so long
$dbc = mysqli_connect('localhost', 'root', '', 'aliendatabase') or die ('Error connecting to MySQL server.');
//Next create a variable to hold your query commands for the same reason
$query = "INSERT INTO aliens_abduction (first_name, last_name " .
"when_it_happened, how_long, how_many, alien_description, " .
"what_they_did, fang_spotted, other, email) " .
"VALUES ('Sally', 'Jones', '3 days ago', '1 day', 'four', " .
"'slimmy', 'asked questions', " .
"'yes', 'I may have seen your dog. Contact me.', " .
"'sally@gregs-list.net')";
//Now the variable that holds the query function
$result = mysqli_query($dbc, $query)
or die ('Error querying database.');
答案 0 :(得分:0)
您可以使用
- (void)textTapped:(UITapGestureRecognizer *)recognizer
{
UITextView *textView = (UITextView *)recognizer.view;
// Location of the tap in text-container coordinates
NSLayoutManager *layoutManager = textView.layoutManager;
CGPoint location = [recognizer locationInView:textView];
location.x -= textView.textContainerInset.left;
location.y -= textView.textContainerInset.top;
// Find the character that's been tapped on
NSUInteger characterIndex;
characterIndex = [layoutManager characterIndexForPoint:location
inTextContainer:textView.textContainer
fractionOfDistanceBetweenInsertionPoints:NULL];
if (characterIndex < textView.textStorage.length) {
NSRange range;
id value = [textView.attributedText attribute:@"myCustomTag" atIndex:characterIndex effectiveRange:&range];
// Handle as required...
NSLog(@"%@, %d, %d", value, range.location, range.length);
}
}
避免任何混淆