我嘗試從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