我正在尝试使用PHP从网站连接到数据库.
我使用以下PHP -
<?php
$con = mssql_connect("Server","user","password");
if (!$con)
{
die('Could not connect: ' . mssql_error());
}
// some code
?>
Run Code Online (Sandbox Code Playgroud)
我正在尝试将Web表单的结果发送到数据库,使用 -
<form action="insert.php" method="POST">
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误 -
Server Error in '/' Application.
The HTTP verb POST used to access path '/insert.php' is not allowed.
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?提前致谢.
我在asp页面中有以下复选框 -
<asp:CheckBox ID="CheckBox1" runat="server"
Text='<%# Container.DataItem.ToString() %>'/>
Run Code Online (Sandbox Code Playgroud)
我想将Checked值设置为true或者false确定
Text='<%# Container.DataItem.ToString() %>' 值.
所以如果 - '<%# Container.DataItem.ToString() %>'等于1那么Checked="True".
我怎样才能做到这一点?
我有以下代码可以治疗 -
List<string> test = new List<string>();
test.Add("cat");
if (test.Any(str => str.Contains("cat")))
{
// do something
};
Run Code Online (Sandbox Code Playgroud)
但是有没有办法检查是否存在完全匹配的例子 -
if (test.Any(str => str.Contains("the cat sat")))
{
// do something
};
Run Code Online (Sandbox Code Playgroud)
我希望能够检查列表中是否存在字符串中的任何单词.我怎样才能做到这一点?
我有一个简单的.csv文件,我想从写入新文件中提取数据.
我写一个读取文件的脚本,读取每一行,然后按不同的顺序拆分和构造列,如果.csv中的行包含'xxx' - 不要将行输出到输出文件.
我已经设法在一个文件中读取,并创建了一个辅助文件,但是对于Perl是新手,并且仍在尝试计算命令,以下是我为了掌握Perl而编写的测试脚本,并且想知道我是否可以对我需要的东西嗤之以鼻? -
open (FILE, "c1.csv") || die "couldn't open the file!";
open (F1, ">c2.csv") || die "couldn't open the file!";
#print "start\n";
sub trim($);
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
$a = 0;
$b = 0;
while ($line=<FILE>)
{
chop($line);
if ($line =~ /xxx/)
{
$addr = $line;
$post = substr($line, length($line)-18,8);
}
$a = $a + 1;
}
print $b;
print " end\n";
Run Code Online (Sandbox Code Playgroud)
任何帮助深表感谢.
我有一个html页面,其中包含我想要使用Perl脚本解析为数据库的特定文本.
我希望能够剥离我不想要的所有东西,html的例子是 -
<div class="postbody">
<h3><a href "foo">Re: John Smith <span class="posthilit">England</span></a></h3>
<div class="content">Is C# better than Visula Basic?</div>
</div>
Run Code Online (Sandbox Code Playgroud)
因此我想导入数据库
我已经开始创建一个Perl脚本,但需要将其更改为我想要的工作;
use DBI;
open (FILE, "list") || die "couldn't open the file!";
open (F1, ">list.csv") || die "couldn't open the file!";
print F1 "Name\|Lives In\|Commented\n";
while ($line=<FILE>)
{
chop($line);
$text = "";
$add = 0;
open (DATA, $line) || die "couldn't open the data!";
while ($data=<DATA>)
{
if ($data =~ /ds\-div/)
{
$data =~ s/\,//g; …Run Code Online (Sandbox Code Playgroud) 我有以下html-
<a href="http://address.com">John</a>: I really <b>love</b> <b>soccer</b>;
Run Code Online (Sandbox Code Playgroud)
我想把它解析成一个csv,我会有
name = John
评论=我真的很喜欢足球.
关键词=爱情,足球
在控制台应用程序中,非常感谢任何帮助.
我有以下 javascript -
var trim = intsAsJSArray.replace(/[\[\]]/g, "");
var data = trim.split(",");
data = data.map(function (d) {
return +d;
});
Run Code Online (Sandbox Code Playgroud)
但是,这在 IE 中失败并出现错误 -
Error: Object doesn't support property or method 'map'
Run Code Online (Sandbox Code Playgroud)
这很令人困惑,因为它同时适用于 Chrome 和 FireFox。为什么是这样?
我正在尝试向 cytoscape.js 中的标签添加多个值,如下所示 -
{
"selector": "edge",
"style": {
"curve-style": "haystack",
"text-wrap": "wrap",
"label": "data(count)" + "data(edgevalue)",
"font-size": "8px",
"color": "black",
"haystack-radius": "0.5",
"opacity": "0.4",
"line-color": "#bbb",
"width": "mapData(weight, 0, 1, 1, 8)",
}
},
Run Code Online (Sandbox Code Playgroud)
然而,这实际上只是显示 -
data(count)data(edgevalue)
Run Code Online (Sandbox Code Playgroud)
作为标签文本。如果我删除一个或另一个,它会为每个打印正确的值。我尝试为换行符添加一个 '\n',它创建了一个换行符,但值与上面的相同。
我也试过data(count + edgevalue)没有用。
如何在标签文本中实现多个数据属性?
以下Perl脚本有效地读取html文件并删除我不需要的内容.它还会打开一个空白的csv文档.
我的问题是我想将精简结果导入CSV的3个字段,使用名称作为字段1,生活在字段2中并注释为字段3.
结果将显示在cmd提示符中,但不会显示在CSV中.
use warnings;
use strict;
use DBI;
use HTML::TreeBuilder;
use Text::CSV;
open (FILE, 'file.htm');
open (F1, ">file.csv") || die "couldn't open the file!";
my $csv = Text::CSV->new ({ binary => 1, empty_is_undef => 1 })
or die "Cannot use CSV: ".Text::CSV->error_diag ();
open my $fh, "<", 'file.csv' or die "ERROR: $!";
$csv->column_names('field1', 'field2', 'field3');
while ( my $l = $csv->getline_hr($fh)) {
next if ($l->{'field1'} =~ /xxx/);
printf "Field1: %s Field2: %s Field3: %s\n",
$l->{'field1'}, $l->{'field2'}, $1->{'field3'}
}
close …Run Code Online (Sandbox Code Playgroud) 我有以下正则表达式 -
string s = "{\"data\": {\"words\": [{\"wordsText\": \"Three Elephants /d
in the jungle\"}]}}";
string[] words = s.Split('\\',':','[',']','{','}','"');
foreach (string word in words)
{
Console.WriteLine(word);
}
Run Code Online (Sandbox Code Playgroud)
哪个输出 -
data
words
wordsText
Three Elephants /d in the jungle
Run Code Online (Sandbox Code Playgroud)
什么是摆脱输出中前3行的最佳方法,以便我只获得最后一行 - Three Elephants /d in the jungle.
我相信如果我在"wordsText\":此之后写出所有文本可能是一种可能的方法,我们非常感谢任何帮助.
我有以下两个html-的例子
<a href="http://foo.com">User</a>: <a style="color:#333" href="http://foo.com/word"></a> blue elephant ·
<a href="http://foo.com">User</a>: <a style="color:#333" href="http://foo.com/word">@<b>word</b></a> blue elephant ·
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用C#解析它以放入csv文件并且它在某种程度上工作,但是当html中包含"@"符号时,它将使csv单元格保持空白或者不包含单词" @'之前.我试图得到的主要部分@word blue elephant是带回一个空白单元格,而第一个html示例则blue elephant根据需要返回.
我使用以下技术来做到这一点 -
string[] comm = System.Text.RegularExpressions.Regex.Split(content[1], "<a");
Run Code Online (Sandbox Code Playgroud)
我如何改变它以适用于第二个html示例?
我使用以下脚本 -
<HTML>
<meta http-equiv='Content-Type' content='text/xml; charset=windows-1252'>
<script type="text/javascript">
function show(){
var navLinks = document.getElementsByClassName('a');
for (var i = 0; i < navLinks.length; i++) {
var link = navLinks[i];
var title = link.title;
alert(title);
}
}
</script>
<HEAD>
<TITLE>Properties</TITLE>
</HEAD>
<BODY>
<button type="button" onClick="show()">Close</button>
<table cellpadding=0 cellspacing=0>
<tr>
<td>Contact</td>
<td class="a">(01) 234 5678</td>
</tr>
</table>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)
我想要做的就是显示一个警告框,(01) 234 5678但IE8什么都不做,Chrome显示一个空白警告框.
我是Javascript的新手,但我哪里错了?
我正在计算阵列中存在多少个字符串 -
Tags = "the cat the mat the sat";
string[] words = Tags.Split(' ');
int counter = 0;
foreach (string item in words)
{
if (item != "")
{
counter++;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我怎么能修改我的代码,以便计算每个字符串的出现次数.所以例如 -
然后以某种方式存储这些值?