Fonction javascript
nono555
-
UgglyBoy Messages postés 426 Date d'inscription Statut Membre Dernière intervention -
UgglyBoy Messages postés 426 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'essaie de mettre un code javascript pour ouvrir une fenêtre :
<?php
function db_error_display_V1($err_msg, $link)
{
global $lang;
global $db_string_lang;
printf($err_msg);
if ($link) {
printf($db_string_lang['ERROR_DB'][$lang] . "%d %s", mysql_errno($link), mysql_error($link));
}
}
function xhtml_header($title)
{
$header = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"
. "<!DOCTYPE html \n"
. "\tPUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
. "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\" >\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n"
. "<head>\n"
. " <title>\n"
. " " .$title . "\n"
. " </title>\n"
. "<link type=\"text/css\" href=\"styles/dvdtek.css\" rel=\"stylesheet\" />\n"
. "</head>\n";
return $header;
}
function db_error_display($err_msg, $link)
{
global $lang;
global $db_string_lang;
$xhtml_header = addcslashes(xhtml_header($db_string_lang['ERROR_DB][$lang]),"\n\"");
printf("<script type=\"text/javascript\" src=\"tools_window.js\"></script>\n");
printf("<script type=\"text/javascript\" >\n");
printf("<!--//--><![CDATA[ // ><!--\n");
printf("errorWindow = errorWindowOpen(\"\", \"errorWindow\");\n");
printf("errorWindow.document.write(%s);\n", "\"$xhtml_header\\n\"");
printf("errorWindow.document.write(%s);\n", "\"<body>\\n\"");
printf("errorWindow.document.write(%s);\n", "\"\\t <p class=\\\"error\\\">$err_msg !<br />\\n\"");
if ($link)
{
$mysql_err = printf($db_string_lang['ERROR_DB'][$lang] . "%d %s", mysql_errno($link), mysql_error($link));
printf("errorWindow.document.write(%s);\n", "\"\\t $mysql_err\\n\"");
}
printf("errorWindow.document.write(%s);\n", "\"\\t<br /></p>\\n\\t<a href=\\\"#\\\" onclick=\\\"window.opener.location.href='cinedvd_bfe.php';
window.close();\\\">Retour</a>\\n\"");
printf("errorWindow.document.write(%s);\n", "\"</body>\\n\"");
printf("errorWindow.document.write(%s);\n", "\"</html>\\n\"");
printf("// --><!]]>");
printf("</script>\n");
}
?>
mon code javascript du fichier tools_window.js est :
function errorWindowOpen(url, name){
var newWin = window.open(url, name, "resizable=no, scrollbars=yes, width=500, height=100");
return newWin;
}
Le problème est que quand je lance, le programme me retourne :
"Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\Program Files\EasyPHP-5.3.9\www\TestMysql\tools_db_common.php on line 43"
Je sais que cette erreur disparaît quand je mets en commentaire le code "$xhtml_header = addcslashes(xhtml_header($db_string_lang['ERROR_DB][$lang]),"\n\"");"
mais je ne comprends pas pourquoi et rien ne se passe quand même.
Quelqu'un peut-il m'aider ?
Dans le code javascript, faut-il ajouter des choses au début et à la fin du fichier ?
Merci.
nono555
J'essaie de mettre un code javascript pour ouvrir une fenêtre :
<?php
function db_error_display_V1($err_msg, $link)
{
global $lang;
global $db_string_lang;
printf($err_msg);
if ($link) {
printf($db_string_lang['ERROR_DB'][$lang] . "%d %s", mysql_errno($link), mysql_error($link));
}
}
function xhtml_header($title)
{
$header = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"
. "<!DOCTYPE html \n"
. "\tPUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
. "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\" >\n"
. "<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n"
. "<head>\n"
. " <title>\n"
. " " .$title . "\n"
. " </title>\n"
. "<link type=\"text/css\" href=\"styles/dvdtek.css\" rel=\"stylesheet\" />\n"
. "</head>\n";
return $header;
}
function db_error_display($err_msg, $link)
{
global $lang;
global $db_string_lang;
$xhtml_header = addcslashes(xhtml_header($db_string_lang['ERROR_DB][$lang]),"\n\"");
printf("<script type=\"text/javascript\" src=\"tools_window.js\"></script>\n");
printf("<script type=\"text/javascript\" >\n");
printf("<!--//--><![CDATA[ // ><!--\n");
printf("errorWindow = errorWindowOpen(\"\", \"errorWindow\");\n");
printf("errorWindow.document.write(%s);\n", "\"$xhtml_header\\n\"");
printf("errorWindow.document.write(%s);\n", "\"<body>\\n\"");
printf("errorWindow.document.write(%s);\n", "\"\\t <p class=\\\"error\\\">$err_msg !<br />\\n\"");
if ($link)
{
$mysql_err = printf($db_string_lang['ERROR_DB'][$lang] . "%d %s", mysql_errno($link), mysql_error($link));
printf("errorWindow.document.write(%s);\n", "\"\\t $mysql_err\\n\"");
}
printf("errorWindow.document.write(%s);\n", "\"\\t<br /></p>\\n\\t<a href=\\\"#\\\" onclick=\\\"window.opener.location.href='cinedvd_bfe.php';
window.close();\\\">Retour</a>\\n\"");
printf("errorWindow.document.write(%s);\n", "\"</body>\\n\"");
printf("errorWindow.document.write(%s);\n", "\"</html>\\n\"");
printf("// --><!]]>");
printf("</script>\n");
}
?>
mon code javascript du fichier tools_window.js est :
function errorWindowOpen(url, name){
var newWin = window.open(url, name, "resizable=no, scrollbars=yes, width=500, height=100");
return newWin;
}
Le problème est que quand je lance, le programme me retourne :
"Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\Program Files\EasyPHP-5.3.9\www\TestMysql\tools_db_common.php on line 43"
Je sais que cette erreur disparaît quand je mets en commentaire le code "$xhtml_header = addcslashes(xhtml_header($db_string_lang['ERROR_DB][$lang]),"\n\"");"
mais je ne comprends pas pourquoi et rien ne se passe quand même.
Quelqu'un peut-il m'aider ?
Dans le code javascript, faut-il ajouter des choses au début et à la fin du fichier ?
Merci.
nono555
A voir également:
- Fonction javascript
- Fonction si et - Guide
- Fonction miroir - Guide
- Telecharger javascript - Télécharger - Langages
- Fonction moyenne excel - Guide
- Fonction remplacer sur word - Guide