Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    139

    Problemi con lettura database mysql

    Il problema è il seguente:

    Il codice che riporto qui sotto è contenuto nella cella "codice" nella tabella "pagine"
    Codice PHP:
    <?
    $db_tabella 
    "news";
    $data = (date("d-m-y"));

    $query=mysql_db_query($db_database,"select * from news ORDER BY id DESC LIMIT 0,3",$conn);
    $num=mysql_num_rows($query);

    $abc=0;
    while ( 
    $abc<$num ){
    echo 
    '<div align="center">
                    <table border="0" width="448" id="table1" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="6">
                            [img]images/template/sx-top.gif[/img]</td>
                            <td background="images/template/top.gif">
                            <span style="font-size: 1pt"></span></td>
                            <td width="6">
                            [img]images/template/dx-top.gif[/img]</td>
                        </tr>
                        <tr>
                            <td background="images/template/sx.gif" width="6"></td>
                            <td bgcolor="#808080" style="padding-top: 2px; padding-bottom: 2px">
                            <p align="center">[b]'
    .mysql_result($query,$abc,"titolo").' ['.mysql_result($query,$abc,"data").'][/b]</td>
                            <td width="6" background="images/template/dx.gif"></td>
                        </tr>
                        <tr>
                            <td width="6">
                            [img]images/template/sx-bottom.gif[/img]</td>
                            <td background="images/template/bottom.gif">
                            <span style="font-size: 1pt"></span></td>
                            <td width="6">
                            [img]images/template/dx-bottom.gif[/img]</td>
                        </tr>
                        <tr>
                        <td width="6">
                            [img]images/template/sx-top1.gif[/img]</td>
                            <td background="images/template/top1.gif">
                            <span style="font-size: 1pt"></span></td>
                            <td width="6">
                            [img]images/template/dx-top1.gif[/img]</td>
                        </tr>
                        <tr>
                            <td width="6" background="images/template/sx.gif"></td>
                            <td bgcolor="#C0C0C0" style="padding-left: 5px; padding-right: 5px; padding-top:2px; padding-bottom:2px">
                            '
    .mysql_result($query,$abc,"testo").'
                            <hr>
                            <p style="margin-top: -5px"><span style="font-size: 8pt">[i]by '
    .mysql_result($query,$abc,"autore").'[/i]</span></p>
                            </td>
                            <td width="6" background="images/template/dx.gif"></td>
                        </tr>
                        <tr>
                            <td width="6">
                            [img]images/template/sx-bottom.gif[/img]</td>
                            <td background="images/template/bottom.gif">
                            <span style="font-size: 1pt"></span></td>
                            <td width="6">
                            [img]images/template/dx-bottom.gif[/img]</td></tr>
                    </table>
                    </div>
                    <span style="font-size: 5pt">
                    

                    </span>'
    ;
    $abc++;
    }
    ?>
    Usando questo codice per stampare il contenuto della cella:
    Codice PHP:
    $querycentro=mysql_db_query($db_database,"select codice from pagine WHERE nome_pagina='".$nomepagina."'",$conn);
    $pag=mysql_result($querycentro,0,"codice");
    echo 
    $pag
    mi visualizza il codice php

    Come posso fare per far convertire il codice in html???

    Grazie per le risposte

  2. #2
    forse hai solo lo short tag php disabilitato.

    usa il tag php come php comanda.... <?php

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  3. #3
    ma piero, con l'echo non si stampa anzichè eseguire? non dovrebbe usare return?

  4. #4
    Originariamente inviato da elysaweb
    ma piero, con l'echo non si stampa anzichè eseguire? non dovrebbe usare return?
    $pag=mysql_result($querycentro,0,"codice");

    in $pag c'e' una stringa da stampare. Nulla da eseguire. Sicuramente sara' per lo short tag e non viene parsato il file ma stampato il codice php come fosse testo.

    Questo almeno sono le mie attuali supposizioni.

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  5. #5
    Ah! Credevo che in "codice" ci fosse del codice php da eseguire...

  6. #6
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    139
    Originariamente inviato da piero.mac
    forse hai solo lo short tag php disabilitato.

    usa il tag php come php comanda.... <?php
    niente da fare ....
    mi stampa sempre il codice come se lo avessi scritto in html invece che in php ...

  7. #7
    Originariamente inviato da Fenix'89
    niente da fare ....
    mi stampa sempre il codice come se lo avessi scritto in html invece che in php ...
    ma hai installato il server http, il php e' avviato?

    fai un file con il phpinfo() ... copia e incolla ed eseguilo:

    Codice PHP:
    <?php
    phpinfo
    ();
    ?>
    vedi che ti risponde

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  8. #8
    Originariamente inviato da Fenix'89
    niente da fare ....
    mi stampa sempre il codice come se lo avessi scritto in html invece che in php ...
    ci puoi far vedere che codice ti stampa?

  9. #9
    Utente di HTML.it
    Registrato dal
    Apr 2007
    Messaggi
    139


    mi stampa questo.


    Però mi è venuto un dubbio:

    Io uso echo '...' per stampare il codice sequente:
    Codice PHP:
    <? 
    $db_tabella 
    "news"
    $data = (date("d-m-y")); 

    $query=mysql_db_query($db_database,"select * from news ORDER BY id DESC LIMIT 0,3",$conn); 
    $num=mysql_num_rows($query); 

    $abc=0
    while ( 
    $abc<$num ){ 
    echo 
    '<div align="center"> 
                    <table border="0" width="448" id="table1" cellspacing="0" cellpadding="0"> 
                        <tr> 
                            <td width="6"> 
                            [img]images/template/sx-top.gif[/img]</td> 
                            <td background="images/template/top.gif"> 
                            <span style="font-size: 1pt"></span></td> 
                            <td width="6"> 
                            [img]images/template/dx-top.gif[/img]</td> 
                        </tr> 
                        <tr> 
                            <td background="images/template/sx.gif" width="6"></td> 
                            <td bgcolor="#808080" style="padding-top: 2px; padding-bottom: 2px"> 
                            <p align="center">[b]'
    .mysql_result($query,$abc,"titolo").' ['.mysql_result($query,$abc,"data").'][/b]</td> 
                            <td width="6" background="images/template/dx.gif"></td> 
                        </tr> 
                        <tr> 
                            <td width="6"> 
                            [img]images/template/sx-bottom.gif[/img]</td> 
                            <td background="images/template/bottom.gif"> 
                            <span style="font-size: 1pt"></span></td> 
                            <td width="6"> 
                            [img]images/template/dx-bottom.gif[/img]</td> 
                        </tr> 
                        <tr> 
                        <td width="6"> 
                            [img]images/template/sx-top1.gif[/img]</td> 
                            <td background="images/template/top1.gif"> 
                            <span style="font-size: 1pt"></span></td> 
                            <td width="6"> 
                            [img]images/template/dx-top1.gif[/img]</td> 
                        </tr> 
                        <tr> 
                            <td width="6" background="images/template/sx.gif"></td> 
                            <td bgcolor="#C0C0C0" style="padding-left: 5px; padding-right: 5px; padding-top:2px; padding-bottom:2px"> 
                            '
    .mysql_result($query,$abc,"testo").
                            <hr> 
                            <p style="margin-top: -5px"><span style="font-size: 8pt">[i]by '
    .mysql_result($query,$abc,"autore").'[/i]</span></p> 
                            </td> 
                            <td width="6" background="images/template/dx.gif"></td> 
                        </tr> 
                        <tr> 
                            <td width="6"> 
                            [img]images/template/sx-bottom.gif[/img]</td> 
                            <td background="images/template/bottom.gif"> 
                            <span style="font-size: 1pt"></span></td> 
                            <td width="6"> 
                            [img]images/template/dx-bottom.gif[/img]</td></tr> 
                    </table> 
                    </div> 
                    <span style="font-size: 5pt"> 
                    
     
                    </span>'

    $abc++; 

    ?>
    Ma php non lo vede come testo questo????
    non dovrei usare un altro metodo???

  10. #10
    il file deve avere estensione .php
    il tag php deve essere esteso <?php
    devi avere installato il server http con il php come modulo *funzionanti*

    se non hai soddisfatto queste tre condizioni devi mandare il pc a Lourdes per un miracolo.

    quello che fai vedere e' semplicemente perche' il php non viene parsato ma inviato semplicemente come testo al browser.

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.