PHP to write a JS script into my html source doc
<p>I am trying to use PHP to write a JS script into my html source doc. I have investigated numerous other forums, but still can't quite identify the error..</p>

<p>The JS script I am trying to embed follows syntax from a default YUI Charting Library script. </p>

<p>Assuming my php string output (generated from the <i><b>echo: $data->dump_yui($row_numbers=false, $col_letters=false, $sheet=0, $table_class='excel'); </b></i>) appropriately suits the parameters r'qd by the YUI script syntax, where am I going wrong with embedding the script in my html doc?</p>

<p>PHP written to JavaScript in the HTML :</p>

<pre><code>&lt;?php 
echo "&lt;script language=javascript&gt;";
echo 'document.write("YUI().use('charts',function(Y){var myDataValues = [';
echo $data-&gt;dump_yui($row_numbers=false, $col_letters=false, $sheet=0, $table_class='excel');
echo "&lt;br&gt;];&lt;br&gt;&lt;br&gt;var styleDef = {series:&lt;br&gt;{Stock:{line:{color:'#898DD5'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#222',alpha:0,wmode:'transparent'},over:{fill:{color:'#eee'},border:{color:'#000'},width:9,height:9}}},&lt;br&gt;Liability:{line:{color:'#171944'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#222',alpha:0,wmode:'transparent'},over:{fill:{color:'#eee'},border:{color:'#000'},width:9,height:9}}},&lt;br&gt;Shipment:{line:{color:'#ff0000',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#ff0000',alpha:0,wmode:'transparent'},over:{fill:{color:'#ff0000',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}},&lt;br&gt;Production:{line:{color:'#FFD700',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#FFD700',alpha:0,wmode:'transparent'},over:{fill:{color:'#FFD700',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}},&lt;br&gt;Order:{line:{color:'#006400',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#006400',alpha:0,wmode:'transparent'},over:{fill:{color:'#006400',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}}}};&lt;br&gt;var myAxes={dateRange:{keys:['date'],position:'bottom',type:'category',title:'Date Range',styles:{majorTicks:{display:'none'},label:{rotation:-45,margin:{top:5}},title:{fontSize:'90%'}}}};var mychart=new Y.Chart({dataProvider:myDataValues,interactionType:'planar',render:'#mychart',categoryKey:'Date',styles:styleDef,categoryType:'time',horizontalGridlines:{styles:{line:{color:'#fff'}}},verticalGridlines:{styles:{line:{color:'#fff'}}}});&lt;br&gt;});";
echo '");';
echo "&lt;/script&gt;";
?&gt;
</code></pre>

<p>(I have also tried executing the script without the 'document.write' included)</p>

<p>I am fairly green to PHP.. Any ideas?</p>

<p><strong><em>_</em>__
Update (Jul 18, 12):
Thanks for feedback - I tried all of the fixes, and chart is still not rendering, with code:</strong></p>

<pre><code>&lt;?php 
echo "&lt;script type='text/javascript'&gt;";
echo 'document.write("YUI().use(\'charts\',function(Y){var myDataValues = [';
echo $data-&gt;dump_yui($row_numbers=false, $col_letters=false, $sheet=0, $table_class='excel');
echo "\n];\n\nvar styleDef = {series:\n{Stock:{line:{color:'#898DD5'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#222',alpha:0,wmode:'transparent'},over:{fill:{color:'#eee'},border:{color:'#000'},width:9,height:9}}},&lt;br&gt;Liability:{line:{color:'#171944'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#222',alpha:0,wmode:'transparent'},over:{fill:{color:'#eee'},border:{color:'#000'},width:9,height:9}}},&lt;br&gt;Shipment:{line:{color:'#ff0000',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#ff0000',alpha:0,wmode:'transparent'},over:{fill:{color:'#ff0000',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}},&lt;br&gt;Production:{line:{color:'#FFD700',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#FFD700',alpha:0,wmode:'transparent'},over:{fill:{color:'#FFD700',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}},&lt;br&gt;Order:{line:{color:'#006400',alpha:0,wmode:'transparent'},marker:{fill:{color:'#eee',alpha:0,wmode:'transparent'},border:{color:'#006400',alpha:0,wmode:'transparent'},over:{fill:{color:'#006400',alpha:0,wmode:'transparent'},border:{color:'#000',alpha:0,wmode:'transparent'},width:16,height:16}}}}};&lt;br&gt;var myAxes={dateRange:{keys:['date'],position:'bottom',type:'category',title:'Date Range',styles:{majorTicks:{display:'none'},label:{rotation:-45,margin:{top:5}},title:{fontSize:'90%'}}}};var mychart=new Y.Chart({dataProvider:myDataValues,interactionType:'planar',render:'#mychart',categoryKey:'Date',styles:styleDef,categoryType:'time',horizontalGridlines:{styles:{line:{color:'#fff'}}},verticalGridlines:{styles:{line:{color:'#fff'}}}});&lt;br&gt;});";
echo '");';
echo "&lt;/script&gt;";
?&gt;
</code></pre>

<p>**<strong>_</strong>
Update (Jul 20, 12):</p>

<p>Thanks for the additional feedback everyone. I pushed a page up to my server that contains the three code snippets (in a somewhat organized fashion). </p>

<hr>

<ul>
<li><a href="http://demo.opendataregistry.com/dashboard/Jacobs_PHP_thanks_for_taking_a_look.html" rel="nofollow">http://demo.opendataregistry.com/dashboard/Jacobs_PHP_thanks_for_taking_a_look.html</a></li>
</ul>

<hr>

<p>... still can't manage to squash this bug!</p>
