Re: passing values to a javascript variable

From: Date: Fri, 22 Jun 2001 00:28:13 +0000
Subject: Re: passing values to a javascript variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-54821@lists.php.net to get a copy of this message
On Thu, 21 Jun 2001, Romulo Roberto Pereira wrote: > Hello! > > The following give me: unterminated string constant (this is a javascript > error) > > when I execute the following: > > while ($row = mysql_fetch_array ($data_query_action)) { > $data_data = $row["data_data"]; > } > echo "<script language=\"javascript\">\n var > ndata=\"".addslashes($data_data)."\";\nPutCode > (ndata);\n</script>"; > > Ideas? Please I need help. > > Thank you, > This is usually a problem where a string literal is spanning thru several lines. Remember, in JavaScript one statement ends either with a semi-colon or a newline '\n'. You should do str_replace("\n", '\n', $data_data) in there before doing addslashes(). Believe it or not, thats the error. Joao -- João Prado Maia <jpm@phpbrasil.com> http://phpbrasil.com - php com um jeitinho brasileiro

« previous php.general (#54821) next »