我尝试从javascript函数启动参数,但是当我有一个空格时,它似乎是引用问题。SyntaxError:未终止的字符串文字只有空格
这是Mozilla的
SyntaxError: unterminated string literal
的错误,这是我的代码
$requete = pg_query($dbconnect,"SELECT '<table id=''id1''><col width=''30%''/><col width=''20%''/><col width=''30%''/><col width=''20%''/><tr></tr><tr><td id=''fiche'' colspan=4>Caract</td></tr><tr><td>Stat</td><td>'||coalesce(stat,'')||'</td><td>Service1</td><td>'||coalesce(serv,'')||'</td></tr><tr><td>Date1</td><td>'||coalesce((substring(CAST(date1 AS character varying) from 9 for 2)||'/'||substring(CAST(date1 AS character varying) from 6 for 2)||'/'||substring(CAST(date1 AS character varying) from 1 for 4)),'')||'</td><td>Heure fin</td><td>'||coalesce(heure_fin,'')||'</td></tr><tr><td>Heure début</td><td>'||coalesce(heure_debut,'')||'</td><td>Durée</td><td>'||coalesce(duree::varchar,'')||'</td></tr><tr><td colspan=2><a onclick=document.getElementById(''affichage_popup'').style.display=''none''; class=''bouton'' id=''retour''>Retour</a></td><td colspan=2><a onclick=lancement(''script\\\php\\\postgres_query.php'',0,''DELETE FROM table WHERE id=2''); class=''bouton'' id=''supprimer''>Supprimer la fiche</a></td></tr></table>' AS fiche FROM table")
如果我对代码进行分析的回报与Mozilla的我有这个
<a id="test')" where="" intervention="" from="" onclick="lancement('script/php/postgres_query.php',0,'DELETE" id="supprimer" class="bouton">Supprimer la fiche</a>
我试着用'/ s'等正则表达式代替空格,这是同样的事情。
似乎错误在这里'onclick ='lancement('script/php/postgres_query.php',0,'DELETE'',没有关闭')'同样为什么在同一个锚标记上有两个id – brk
如果我写'onclick = lancement(''script \\\ php \\\ postgres_query.php'',0,''DELETEFROMtableWHEREid = 2'');',Mozilla的代码返回很好:'onclick =“lancement(' script/php/postgres_query.php',0,''DELETEFROMtableWHEREid = 2''也是,我已经在Id和一个班级上了'' –
另外,值得注意的是,代码极易受SQL注入攻击。 – vlaz