我试图将传递给我的函数的变量插入到.innerHTML =代码的输出中,但不知道如何正确地将其插入到HTML输出中.
function playsong(song)
{
parent.document.getElementById('player').innerHTML = '<object width="199" height="26"><param name="movie" value="audio_player_black.swf"><embed src="audio_player_black.swf?audio_file=upload/'[song]'&color=00000" width="199" height="26"></embed></object>';
}
Run Code Online (Sandbox Code Playgroud)
我只是在我的HTML输出中得到[song]而不是[song]的值
不知道我需要如何正确地做到这一点
部分代码:
我的下面的代码从我的数据库中提取查询,然后使用inner.HTML =来显示div中的数据.它在原始使用中工作正常....
但是,以下版本在iFrame中调用,因为它用于更新页面.
页面没有错误,然后JavaScript触发,但最后一行不起作用...
我刚刚意识到,可能因为它是在隐藏的iFrame中加载它试图在iFrame中设置div的innerHTML,当然这不会起作用.
这是发生了什么?它没有意义,因为我有另一个脚本以相同的方式在它的末尾调用JavaScript,它工作正常.
<?php
while ($row = mysql_fetch_array($result))
{
$p = $p.'<div id="left"><img src="http://www.sharingizcaring.com/bleepV2/images/thumbs/'.$row[image].'" /></div>';
$p = $p.'<div id="right"><h2>'.$row[artist].' - '.$row['title'].'</h2><br>'.$row['message'].'<br>';
$p = $p.'<a href="http://www.sharingizcaring.com/bleepV2/'.$row[username].'">'.$row[username].'</a> '.$row[date].'</div>';
$p = $p.'<div style="clear: both;"></div>';
$p = $p.'<div id="dotted-line"></div>';
}
$p = addslashes($p);
?>
<script>
alert('posts are firing? ');
document.getElementById('posts').innerHTML = 'why doth this faileth?';
</script>
Run Code Online (Sandbox Code Playgroud) 我使用下面的脚本检查我的密码长度,大写,小写和数字.
如何更改它以使其检查FOR符号而不是符号?
<?php
$password = 'afsd323A';
if(
//I want to change this first line so that I am also checking for at least 1 symbol.
ctype_alnum($password) // numbers & digits only
&& strlen($password)>6 // at least 7 chars
&& strlen($password)<21 // at most 20 chars
&& preg_match('`[A-Z]`',$password) // at least one upper case
&& preg_match('`[a-z]`',$password) // at least one lower case
&& preg_match('`[0-9]`',$password) // at least one digit
)
{
echo 'valid';
}
else
{
echo 'not valid';// not valid …Run Code Online (Sandbox Code Playgroud) 当我yiic在终端中运行自定义命令时,我收到以下错误.
我似乎无法追查这个错误的原因,任何人都可以指出我正确的方向.我知道数据库工作得很好,因为应用程序的其他部分工作正常.
<?php
class RbacCommand extends CConsoleCommand
{
private $_authManager;
public function getHelp()
{
return "<<<EOD
USAGE
rbac
DESCRIPTION
This command generates an initial RBAC authorization hierarchy.
EOD";
}
public function run($args)
{
if(($this->_authManager=Yii::app()->authManager)===null)
{
echo "Error: an authorization manager, named 'authManager' must be configured to use this command.\n";
echo "If you already added 'authManager' component in applicaton configuration,\n";
echo "please quit and re-enter the yiic shell.\n";
return;
}
echo "This command will create three roles: Owner, Member, …Run Code Online (Sandbox Code Playgroud) 我有一个PHP页面,我每分钟都通过CRON作业运行.
我已经运行了很长一段时间但突然间它开始抛出这些错误:
Maximum execution time of 30 seconds exceeded in /home2/sharingi/public_html/scrape/functions.php on line 84
Run Code Online (Sandbox Code Playgroud)
行号将随每个错误而变化,范围从第70行到90年代.
这是第0-95行的代码
function crawl_page( $base_url, $target_url, $userAgent, $links)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10); //follow up to 10 redirections - avoids loops
$html = curl_exec($ch);
if (!$html)
{
echo "<br />cURL error number:" .curl_errno($ch);
echo "<br />cURL error:" . curl_error($ch);
//exit;
}
//
// load scrapped …Run Code Online (Sandbox Code Playgroud) 我可以做Twitter和许多其他网站在网址显示用户页面的地方.
www.mysite.com/the_user_name
在PHP ...或者如何做到这一点?
我正在为我的页面构建XML RSS.遇到这个错误:
error on line 39 at column 46: xmlParseEntityRef: no name
Run Code Online (Sandbox Code Playgroud)
显然这是因为我不能用XML格式...我在上一个字段行中做了...
什么是清理我所有$row['field']'sPHP 的最佳方法,以便转变为&
这可能是我做不到的事情......
parent.document.getElementById('<?php echo $_GET['song']; ?>')
.innerHTML = '<img src="heart.png" onmouseover="heartOver('');" >';
Run Code Online (Sandbox Code Playgroud)
这onmouseover="heartOver('');部分打破了我的JavaScript.有没有办法逃避报价,所以我可以这样做?