Ver Mensaje Individual
  #3 (permalink)  
Antiguo 18/04/2014, 10:59
lightning2014
 
Fecha de Ingreso: abril-2014
Mensajes: 32
Antigüedad: 10 años, 1 mes
Puntos: 0
Exclamación Respuesta: insertar elementos en un array

Gracias , una consulta ¿el codigo php que hace la consulta la DB y genera el array a través del while en que parte del archivo debe ir?, dentro del "<html>" o dentro de "<script>"?:

Código PHP:
Ver original
  1. require("connect.inc.php");
  2.  
  3. $query = mysql_query("SELECT artista FROM musica");
  4.  
  5. $array = array();
  6.  
  7.     while($fila = mysql_fetch_assoc($query)) {
  8.  
  9.         $row = $fila['artista'];
  10.      
  11.         array_push($array,$row);
  12.     }
  13.  
  14.   $imprimirJs = json_encode($array);

Porque al incrustar esto:

<?php (echo o include) ?> me da un error el chorme:

Cita:
Uncaught SyntaxError: Unexpected token <
a cambio muestra esto :
Código HTML:
Ver original
  1. <br />
  2. <font size='1'><table class='xdebug-error xe-notice' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
  3. <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Use of undefined constant datos - assumed 'datos' in C:\wamp\www\typeahead 0.10.2\index.php on line <i>71</i></th></tr>
  4. <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
  5. <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
  6. <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0000</td><td bgcolor='#eeeeec' align='right'>144600</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='C:\wamp\www\typeahead 0.10.2\index.php' bgcolor='#eeeeec'>..\index.php<b>:</b>0</td></tr>
  7. </table></font>
  8. <br />

Última edición por lightning2014; 18/04/2014 a las 11:05