2016-04-02 6 views
0

Zunächst einmal vielen Dank an alle für mich zu helfen, und bitte mein Englisch entschuldigen, ich versuche, die beste :)über SQL und str_replace Funktion

Dies ist, was ich tun will zu tun:

ich habe eine Tabelle in MySQL-Datenbank namens acciones, ich will jede „Aktion“ in der Tabelle registrierte eine im Text gedruckt auf dem Bildschirm machen ersetzen:

<?php 
    include('../procesos/abre_conexion.php'); 
    $query99 = "SELECT * from acciones";  
    // This line make the query 
    $result99 = mysql_query($query99); 
    $registro99 = mysql_fetch_array($result99) 
?> 
<?php 
    // create the function 
    function howls($valor) { 
     // set the variable // saving as array // possible texts 
     $variables = array('$registro99[original]',); 
     // $imagenes, tambien contendra un array 
     // with the replace text 
     $sus = array('$registro99[reemplazo]',); 
     // making the replace 
     return (str_replace($variables, $sus, $valor)); 
    } 
    // starting function 
    ob_start("howls"); 
?> 
#SalirA beber Cerveza Montoro en barrio santo con Andreita. 
<?php 
    // ending function 
    ob_end_flush(); 
?> 
<? include('../procesos/cierra_conexion.php'); ?> 

Aber er nicht Werke tun, jede Anregung?

Antwort

0

Erstens, you should NOT be using the mysql_* functions. Sie sind veraltet und vollständig aus PHP7 entfernt.

Was passiert mit Ihrem Code? Sie sollten nicht die $registro Variablen angeben. Wenn Sie sie aus irgendeinem Grund zitiert benötigen, müssen Sie double-quote ihnen.

function howls($valor) { 
    // set the variable // saving as array // possible texts 
    $variables = array("{$registro99[original]}",); 
    // $imagenes, tambien contendra un array 
    // with the replace text 
    $sus = array("{$registro99[reemplazo]}",); 
    // making the replace 
    return (str_replace($variables, $sus, $valor)); 
} 
+0

Hallo! Vielen Dank für Ihre Antwort GentlemanMax :) Ich habe versucht, wie Sie sagten, aber immer noch nicht funktioniert: / –