piccolo problemino con variabile tipo

searedone

Utente Attivo
11 Giu 2010
508
0
0
all'inizio della pagina di ranci.php ho messo questo:

PHP:
<?php

require ("db_connect.php"); 

$id_annunci=$_GET['id'];


$query = mysql_query ("SELECT * FROM
   annunci INNER JOIN regione ON (annunci.regioneid=regione.id )    
        INNER JOIN provincia ON (annunci.provinciaid=provincia.id)    
        INNER JOIN citta ON (annunci.cittaid=citta.id)    
        INNER JOIN cliente ON (annunci.clienteid=cliente.id)    
        INNER JOIN tipo ON (annunci.tipoid=tipo.id) 
        INNER JOIN modello ON (annunci.modelloid=modello.id) 
        INNER JOIN fascia ON (annunci.fasciaid=fascia.id)
        INNER JOIN condizioni ON (annunci.condizioniid=condizioni.id)
      INNER JOIN users ON (annunci.user_id=users.id)  
       WHERE id_annunci=$id_annunci LIMIT 1"); 


if (!$query) {
  exit('<p>Error performing query: ' . mysql_error() . '</p>');
}


while ($row = mysql_fetch_array($query)) {
$user_id = $row ['id'];
$titolo = $row ['titolo'];
$id_annunci = $row ['id_annunci'];
$ts = $row ['ts'];
$messaggio = substr($row['messaggio'], 0, 2000); 
$dotazione = substr($row['dotazione'], 0, 500); 
$strumentazione = substr($row['strumentazione'], 0, 500); 
  $telefono = substr($row['telefono'], 0, 25); 
 $modello = $row ['modello'];
  $mq = $row ['mq'];
    $locali = $row ['locali'];
     $prezzo = $row ['prezzo'];
      $tipologia = $row ['tipologia'];
      $tipo = $row ['tipo'];
      $altro = $row ['altro'];
       $condizioni = $row ['condizioni'];
      $name = $row ['name']; 
  $citta = $row ['citta'];
  $cliente = $row ['cliente'];
  $logo_cliente = $row ['logo_cliente'];
  $regione = $row ['regione'];
   $provincia = $row ['provincia'];
    $comune = $row ['comune'];
      $via = $row ['via'];
       $cap = $row ['cap'];
        $societa = $row ['societa'];
 $email = $row ['email'];
 $nome_file = $row ['nome_file'];
  $tipo_file = $row ['tipo_file'];
  $dati_file = $row ['dati_file'];
 $nome_file2 = $row ['nome_file2'];
  $tipo_file2 = $row ['tipo_file2'];
  $dati_file2 = $row ['dati_file2'];
  $nome_file3 = $row ['nome_file3'];
  $tipo_file3 = $row ['tipo_file3'];
  $dati_file3 = $row ['dati_file3'];
  $nome_file4 = $row ['nome_file4'];
  $tipo_file4 = $row ['tipo_file4'];
  $dati_file4 = $row ['dati_file4'];
  $nome_file5 = $row ['nome_file5'];
  $tipo_file5 = $row ['tipo_file5'];
  $dati_file5 = $row ['dati_file5'];
} 
?>

<?php  
$jokelist = mysql_query ("UPDATE annunci SET click_annuncio = click_annuncio + 1 WHERE id_annunci='$id_annunci' " ) or die (mysql_error());    
?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

lo richiamo così:

PHP:
<table width="100%">
  <tr>
    <td width="47%" align="left" valign="middle">Caratteristiche imbarcazione</td>
    <td width="53%"><?php      echo "<img src='immagini1.php?id=$user_id' name='nome_file_vero' width='150' height='40'/>" ; ?></td>
  </tr>
</table><br />
	</th>
    <th width="32%" scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td><table width="100%">
      <tr>
       <td> <?php echo "cod annuncio:<br />$id_annunci<br />"; ?><hr /></td>
    
     
         <td><?php echo "Prezzo :<br />$prezzo<br />"; ?><hr /> </td>
        <td><?php echo "Modello:<br />$titolo<br />";?> <hr /></td>
     
      </tr>
      <tr>
      
       <td><?php   echo "Tipologia venditore: <br />$cliente<br />";?><hr /></td>
        <td><?php echo "Stato Imbarcazione: <br />$tipo<br />";?><hr /></td>
        <td> <?php  echo "Condizioni barca:<br /> $condizioni<br />"; ?><hr /></td>

      </tr>
      <tr>
        <td><?php   echo "Regione: <br />$regione<br />";?><hr /></td>
        <td><?php  echo "Provincia: <br />$name<br />";?><hr /></td>
        <td><?php echo "Comune: <br />$citta<br />";?><hr /></td>
      </tr>
      <tr>
       
         <td> <?php echo "Lunghezza:<br /> $mq<br />"; ?><hr /></td>
          <td><?php   echo "Bagni:<br /> $tipologia<br />"; ?><hr /></td>
        <td><?php  echo "Cabine:<br /> $locali<br />"; ?><hr /></td>
      </tr>
    </table>
 
    
<table width="100%">
  <tr>
    <td><?php  echo "Data Inserimento: $ts<br /><br /><br />"; ?><hr />
    <?php  echo "Strumentazione di bordo:<br /> $strumentazione<br /><br /><br />";?><hr />
	<?php  echo "Dotazioni di bordo:<br /> $dotazione<br /><br /><br />"; ?><hr />
    <?php echo "Descrizione:<br />$messaggio<br />";?><hr /><br />
   
 <?php require "autopromo.php" ; ?>
    
    </td>
    </tr>
</table>

Ma il campo
PHP:
  <td><?php echo "Stato Imbarcazione: <br />$tipo<br />";?><hr /></td>
non mi viene fuori perché :(
 
Lo script mi sembra perfetto...non c'è un graffio!

Mio nonno mi diceva sempre: se escludi l'impossibile quello che rimane,
per quanto improvabile, dev'essere la verità.

Il campo $tipo è perfetto e uguale agli altri... se gli altri ti funzionano ti deve funzionare anche quello.
Molto provabilmente l'errore sta nelle tabelle.

L'errore può essere un carattere in più o una parola in meno...
fossi in te cambierei il nome di questo campo
con un altro nome .... $tipo2 e farei i relativi cambiamenti:

- in tutto lo script PHP
- e in entrambe le tabelle

Prova e vedi che succede...

au revoir
by max_400
 
Hai ragione,
ma la cosa strana è che lo stesso campo in altri posti funziona perfettamente ....

quindi non capisco solo perchè non funziona li :(
 
ciao
metti un var_dump
PHP:
<?php
//................
$tipologia = $row ['tipologia'];
$tipo = $row ['tipo'];
var_dump($row ['tipo']);//e guarda cosa ti restituisce
$altro = $row ['altro'];
$condizioni = $row ['condizioni']; 
//............
?>


@max_400
"elementare dottor Watson"
 
il gattoooooo!!!

Signor Gattino...ogni volta che vedo il tuo avatar mi viene da ridere forte!
Con quelle orecchie cosi grandi mi sembrano antenne paraboliche... ih ih ih

Ritornando al discorso searedone, dimenticavo la terza causa per quanto riguarda
la mancanza di un campo in una query... può essere anche l'invio (forse non nel caso tuo)

Ma hai provato a cambiare il nome e in tutti i campi?
Dovresti risalire tutto il percorso di quella variabile

invio ---> ricezione ---> database ----> stampa
 
Nada ...

non mi stampa nulla con il vardump :(

PHP:
while ($row = mysql_fetch_array($query)) {
$user_id = $row ['id'];
$titolo = $row ['titolo'];
$id_annunci = $row ['id_annunci'];
$ts = $row ['ts'];
$messaggio = substr($row['messaggio'], 0, 2000); 
$dotazione = substr($row['dotazione'], 0, 500); 
$strumentazione = substr($row['strumentazione'], 0, 500); 
  $telefono = substr($row['telefono'], 0, 25); 
 $modello = $row ['modello'];
  $mq = $row ['mq'];
    $locali = $row ['locali'];
     $prezzo = $row ['prezzo'];
      $tipologia = $row ['tipologia'];
      $tipo = $row ['tipo'];
      var_dump($row ['tipo']);
      $altro = $row ['altro'];
       $condizioni = $row ['condizioni'];
      $name = $row ['name']; 
  $citta = $row ['citta'];
 
ciao
sei sicuro che non stampi nulla
non ti da per caso qualcosa di simile a:
attento perche se mi dici che ti da la pag bianca e diverso, cioè il var_dump non viene eseguito quindi non fai il while



@max_400
sono antenne paraboliche: "...è per tracciarti meglio.... topolaccio mio..." (libera interpretazione da cappuccetto rosso)
 
ciao
verifica che tra l'istruzione
PHP:
$tipo = $row ['tipo'];
e l'istruzione
PHP:
<td><?php echo "Stato Imbarcazione: <br />$tipo<br />";?><hr /></td>
in qualche modo tu non vada ad annullare/modificare la variabile $tipo

le altre variabili te le stampa?
 
non penso questa è la cosa strana ... ti posto tutto il codice l'ho guardato 100 di volteeee


PHP:
	<?php

require ("db_connect.php"); 

$id_annunci=$_GET['id'];


$query = mysql_query ("SELECT * FROM
   annunci INNER JOIN regione ON (annunci.regioneid=regione.id )    
        INNER JOIN provincia ON (annunci.provinciaid=provincia.id)    
        INNER JOIN citta ON (annunci.cittaid=citta.id)    
        INNER JOIN cliente ON (annunci.clienteid=cliente.id)    
        INNER JOIN tipo ON (annunci.tipoid=tipo.id) 
        INNER JOIN modello ON (annunci.modelloid=modello.id) 
        INNER JOIN fascia ON (annunci.fasciaid=fascia.id)
        INNER JOIN condizioni ON (annunci.condizioniid=condizioni.id)
      INNER JOIN users ON (annunci.user_id=users.id)  
       WHERE id_annunci=$id_annunci LIMIT 1"); 


if (!$query) {
  exit('<p>Error performing query: ' . mysql_error() . '</p>');
}


while ($row = mysql_fetch_array($query)) {
$user_id = $row ['id'];
$titolo = $row ['titolo'];
$id_annunci = $row ['id_annunci'];
$ts = $row ['ts'];
$messaggio = substr($row['messaggio'], 0, 2000); 
$dotazione = substr($row['dotazione'], 0, 500); 
$strumentazione = substr($row['strumentazione'], 0, 500); 
  $telefono = substr($row['telefono'], 0, 25); 
 $modello = $row ['modello'];
  $mq = $row ['mq'];
    $locali = $row ['locali'];
     $prezzo = $row ['prezzo'];
      $tipologia = $row ['tipologia'];
      $tipo = $row ['tipo'];
      $altro = $row ['altro'];
       $condizioni = $row ['condizioni'];
      $name = $row ['name']; 
  $citta = $row ['citta'];
  $cliente = $row ['cliente'];
  $logo_cliente = $row ['logo_cliente'];
  $regione = $row ['regione'];
   $provincia = $row ['provincia'];
    $comune = $row ['comune'];
      $via = $row ['via'];
       $cap = $row ['cap'];
        $societa = $row ['societa'];
 $email = $row ['email'];
 $nome_file = $row ['nome_file'];
  $tipo_file = $row ['tipo_file'];
  $dati_file = $row ['dati_file'];
 $nome_file2 = $row ['nome_file2'];
  $tipo_file2 = $row ['tipo_file2'];
  $dati_file2 = $row ['dati_file2'];
  $nome_file3 = $row ['nome_file3'];
  $tipo_file3 = $row ['tipo_file3'];
  $dati_file3 = $row ['dati_file3'];
  $nome_file4 = $row ['nome_file4'];
  $tipo_file4 = $row ['tipo_file4'];
  $dati_file4 = $row ['dati_file4'];
  $nome_file5 = $row ['nome_file5'];
  $tipo_file5 = $row ['tipo_file5'];
  $dati_file5 = $row ['dati_file5'];
} 
?>

PHP:
<table width="100%">
  <tr>
    <td width="47%" align="left" valign="middle">Caratteristiche imbarcazione</td>
    <td width="53%"><?php      echo "<img src='immagini1.php?id=$user_id' name='nome_file_vero' width='150' height='40'/>" ; ?></td>
  </tr>
</table><br />
	</th>
    <th width="32%" scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td><table width="100%">
      <tr>
       <td> <?php echo "cod annuncio:<br />$id_annunci<br />"; ?><hr /></td>
    
     
         <td><?php echo "Prezzo :<br />$prezzo<br />"; ?><hr /> </td>
        <td><?php echo "Modello:<br />$titolo<br />";?> <hr /></td>
     
      </tr>
      <tr>
      
       <td><?php   echo "Tipologia venditore: <br />$cliente<br />";?><hr /></td>
        <td><?php echo "Stato Imbarcazione: <br />$tipo<br />";?><hr /></td>
        <td> <?php  echo "Condizioni barca:<br /> $condizioni<br />"; ?><hr /></td>

      </tr>
      <tr>
        <td><?php   echo "Regione: <br />$regione<br />";?><hr /></td>
        <td><?php  echo "Provincia: <br />$name<br />";?><hr /></td>
        <td><?php echo "Comune: <br />$citta<br />";?><hr /></td>
      </tr>
      <tr>
       
         <td> <?php echo "Lunghezza:<br /> $mq<br />"; ?><hr /></td>
          <td><?php   echo "Bagni:<br /> $tipologia<br />"; ?><hr /></td>
        <td><?php  echo "Cabine:<br /> $locali<br />"; ?><hr /></td>
      </tr>
    </table>
 
    
<table width="100%">
  <tr>
    <td><?php  echo "Data Inserimento: $ts<br /><br /><br />"; ?><hr />
    <?php  echo "Strumentazione di bordo:<br /> $strumentazione<br /><br /><br />";?><hr />
	<?php  echo "Dotazioni di bordo:<br /> $dotazione<br /><br /><br />"; ?><hr />
    <?php echo "Descrizione:<br />$messaggio<br />";?><hr /><br />
   
 <?php require "autopromo.php" ; ?>
    
    </td>
    </tr>
</table>

recupero tutto nella stessa pagina ... ho evitato di mettere tutto il resto del codice
 
ciao
prova a pulire il codice in questa maniera

PHP:
<?php 
require ("db_connect.php");  
$id_annunci=$_GET['id']; //nei get metti una verifica
$query = mysql_query ("SELECT * FROM 
   annunci INNER JOIN regione ON (annunci.regioneid=regione.id )     
        INNER JOIN provincia ON (annunci.provinciaid=provincia.id)     
        INNER JOIN citta ON (annunci.cittaid=citta.id)     
        INNER JOIN cliente ON (annunci.clienteid=cliente.id)     
        INNER JOIN tipo ON (annunci.tipoid=tipo.id)  
        INNER JOIN modello ON (annunci.modelloid=modello.id)  
        INNER JOIN fascia ON (annunci.fasciaid=fascia.id) 
        INNER JOIN condizioni ON (annunci.condizioniid=condizioni.id) 
        INNER JOIN users ON (annunci.user_id=users.id)   
          WHERE id_annunci=$id_annunci");//a che ti serve limit 1 , a un id corrisponde un unico record
if (!$query) { 
	exit('<p>Error performing query: ' . mysql_error() . '</p>'); 
} 
//dato come detto il record è unico non ti serve il while
$row = mysql_fetch_array($query));
//poi impara a scrivere il codice più pulito
//più pulito è il codice più facile è poi trovare l'errore
/*ti metto la table (non tutta) come l'hai messa tu però un paio di cose
1. guarda cha ad ogni <table> deve corrispondere la sua chiusura </table>
2. usa la sintassi eredok per stampare tutto l'anmbaradan della tabella
   non stare a entrare uscire 100 volte da php
*/
?>
<table width="100%"> 
  <tr> 
    <td width="47%" align="left" valign="middle">Caratteristiche imbarcazione</td> 
    <td width="53%"><?php echo "<img src='immagini1.php?id=".$row ['id']."' name='nome_file_vero' width='150' height='40'/>" ; ?></td> 
  </tr> 
</table><br />
    </th> 
    <th width="32%" scope="col">&nbsp;</th> 
  </tr> 
  <tr> 
    <td><table width="100%"> 
      <tr> 
       <td><?php echo "cod annuncio:<br />".$row ['id_annunci']."<br />"; ?><hr /></td>
       <td><?php echo "Prezzo :<br />".$row ['prezzo'];."<br />"; ?><hr /> </td> 
       <td><?php echo "Modello:<br />".$row ['titolo']."<br />";?> <hr /></td>
      </tr> 
      <tr> 
       <td><?php   echo "Tipologia venditore: <br />".$row ['cliente']."<br />";?><hr /></td> 
       <td><?php echo "Stato Imbarcazione: <br />".$row ['tipo']."$tipo<br />";?><hr /></td> 
        <td> <?php  echo "Condizioni barca:<br />".." $condizioni<br />"; ?><hr /></td> 
      </tr>
	  <!-- eccetera -->
	   <?php echo "Descrizione:<br />".substr($row['messaggio'], 0, 2000)."<br />";?><hr /><br />
	   <!-- eccetera -->
 
Ciao Borgo,
grazie mille per l'aiuto ma ho preferito non mettere quel campo li e modificarlo con uno nuovo :)

Ho qualche altro piccolo problemino che mi interessa di più --

se puoi mi aiuti li ...

cmq davvero grazie mille per la tua gentilezza
 

Discussioni simili