Fonction javascript

Fermé
nono555 - 4 juil. 2012 à 09:30
UgglyBoy Messages postés 422 Date d'inscription mercredi 24 septembre 2008 Statut Membre Dernière intervention 30 mai 2015 - 4 juil. 2012 à 18:13
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
A voir également:

3 réponses

UgglyBoy Messages postés 422 Date d'inscription mercredi 24 septembre 2008 Statut Membre Dernière intervention 30 mai 2015 64
4 juil. 2012 à 09:47
il manque
'

ici: ['ERROR_DB']
0
Super, merci beaucoup !!! J'ai cherché une erreur de ce genre mais ne l'est pas vue.

Par contre, il ne se passe rien quand je lance un programme qui devrait pourtant m'ouvrir une fenêtre d'erreur mais bon, je vais voir.

Merci.

nono555
0
UgglyBoy Messages postés 422 Date d'inscription mercredi 24 septembre 2008 Statut Membre Dernière intervention 30 mai 2015 64
4 juil. 2012 à 18:13
re post ton code en utilisant la balise <> code, ça sera plus lisible. merci
0