PHP - problema

 
Vista:

problema

Publicado por fernando (20 intervenciones) el 30/12/2012 19:53:32
Hola tengo este codigo es para sacar los mensajes del foro
la base de datos es libre la tabla es mensajes y el campo mensaje


1
2
3
4
5
6
7
8
<?php do { ?>
 <?php  mysql_select_db($database_libre, $libre);
  $publicacion_sql=" SELECT mensaje FROM mensajes WHERE categoria= " .
  $row_Categorias['id_categoria'];
  $pTotales = mysql_query($publicacion_sql) or die(mysql_error());
  ?>
 
  <td width=><?php echo mysql_num_rows($pTotales);?></span></td>


si necesitais algun dato mas me lo decis.
el error que me da en la pagina es:

este es el error:
Notice: Undefined variable: row_Categorias in C:\xampp\htdocs\libre\acceso.php on line 189
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

la linea 189 en realidad es

$publicacion_sql=" SELECT mensaje FROM mensajes WHERE categoria= " .

algien me podria ayudar
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

problema

Publicado por xve (6935 intervenciones) el 31/12/2012 09:38:04
Hola Fernando, no es un error es una notificación... te indica que la variable $row_Categorias no esta definida... de donde sale esta variable?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problema

Publicado por fernando (20 intervenciones) el 31/12/2012 11:39:06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<table width="99%" border="0" cellspacing="0" cellpadding="3">
          <tr>
            <td width="33%"><span class="letra">Categorias</span>
              <?php if($_SESSION['MM_UserGroup']=="admin"){
							?>
              <a href="insectar categoria.php?nombre_user=<?php echo $row_usuarios['nombre_user']; ?>">Insectar_categoria
              <?php  }   ?>
            </a></td>
            <td width="42%"><span class="centro3">Publicaciones totales</span></td>
            <td width="25%"><span class="centro3">Ultimo Post</span></td>
          </tr>
          <tr align="center">
            <td><a href="categorias.php?id_categorias=<?php echo $row_categorias['id_categoria']; ?>&amp;nombre_user=<?php echo $row_usuarios['nombre_user']; ?>"><strong><?php echo $row_categorias['nombre']; ?></strong></a><br />
            Descricion: <?php echo $row_categorias['descripcion']; ?></td>
 
 
            <td><?php echo mysql_num_rows($pTotales);?></td>
            <td><?php $up = mysql_fetch_assoc($uPost);
			echo $up {'fecha'};
			echo '<br/>';
	        echo $up {'autor'};?></td>
 
 
          </tr>
        </table>

Esta es toda la tabla esa variable debe salir del foro
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de xve
Val: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

problema

Publicado por xve (6935 intervenciones) el 31/12/2012 17:58:02
Hola Fernando, creo que ya veo tu problema... tu tienes puesto:
$row_Categorias
y tendria que ser:
$row_categorias

Nos puedes comentar?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

problema

Publicado por fernando (20 intervenciones) el 01/01/2013 18:45:11
Este es el codigo:
1
2
3
4
5
6
7
8
9
<?php
		mysql_select_db($database_libre, $libre);
$publicacion_sql = "SELECT mensaje FROM mensajes WHERE categoria = " .
$row_categoria['categoria'];
$ultimo_sql = "SELECT autor,fecha FROM mensajes WHERE tema = " .
$row_temas['id_tema'] . " ORDER BY fecha DESC LIMIT 1";
$uPost = mysql_query($ultimo_sql) or die(mysql_error ());
$pTotales = mysql_query($publicacion_sql) or die(mysql_error());
		?>

y este va debajo

1
2
3
4
5
6
7
<td><?php echo mysql_num_rows($pTotales);?></td>
 
        <td><?php echo $row_temas['autor']; ?></td>
        <td><?php $up = mysql_fetch_assoc($uPost);
			echo $up {'fecha'};
			echo '<br/>';
	        echo $up {'autor'};?></td>


Y este el problema que da

Notice: Undefined variable: row_categoria in C:\xampp\htdocs\libre\acceso.php on line 235

Notice: Undefined variable: row_temas in C:\xampp\htdocs\libre\acceso.php on line 237
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY fecha DESC LIMIT 1' at line 1

Y este es todo el codigo de la tabla:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<table width="99%" border="0" cellspacing="0" cellpadding="3">
        <tr>
          <td width="50%"><span class="letra">Categorias</span>
            <strong>
            <?php if($_SESSION['MM_UserGroup']=="admin"){
							?>
            <a href="insectar categoria.php?nombre_user=<?php echo $row_usuarios['nombre_user']; ?>">Insectar_categoria
            <?php  }   ?>
          </a></strong></td>
          <td width="26%" align="center"><span class="centro3">Publicaciones totales</span></td>
          <td width="24%" align="center"><span class="centro3">Ultimo Post</span></td>
        </tr>
        <?php do { ?>
 
 
 
      <?php
		mysql_select_db($database_libre, $libre);
$publicacion_sql = "SELECT mensaje FROM mensajes WHERE categoria = " .
$row_categoria['categoria'];
$ultimo_sql = "SELECT autor,fecha FROM mensajes WHERE tema = " .
$row_temas['id_tema'] . " ORDER BY fecha DESC LIMIT 1";
$uPost = mysql_query($ultimo_sql) or die(mysql_error ());
$pTotales = mysql_query($publicacion_sql) or die(mysql_error());
		?>
 
  <tr>
<td><a href="categorias.php?id_categorias=<?php echo $row_categorias['id_categoria']; ?>&amp;nombre_user=<?php echo $row_usuarios['nombre_user']; ?>"><strong><?php echo $row_categorias['nombre']; ?></strong></a><strong><a href="insectar categoria.php?nombre_user=<?php echo $row_usuarios['nombre_user']; ?>">
              <?php if($_SESSION['MM_UserGroup']=="admin"){
							?>
            </a><a href="borrar_confirma.php?nombre_user=<?php echo $row_usuarios['nombre_user']; ?>&amp;id_categoria=<?php echo $row_categorias['id_categoria']; ?>">Eliminar </a><a href="insectar categoria.php?nombre_user=<?php echo $row_usuarios['nombre_user']; ?>">
 <?php  }   ?>
</a><a href="editar_categoria.php?nombre_user=<?php echo $row_usuarios['nombre_user']; ?>&amp;categoria=<?php echo $row_categorias['id_categoria']; ?>">
 <?php if($_SESSION['MM_UserGroup']=="admin"){							?>
Editar</a><a href="borrar_confirma.php?nombre_user=<?php echo $row_usuarios['nombre_user']; ?>">
<?php  }   ?>
</a></strong><br />
              Descricion: <?php echo $row_categorias['descripcion']; ?></td>
           <td><?php echo mysql_num_rows($pTotales);?></td>
        <td><?php echo $row_temas['autor']; ?></td>
        <td><?php $up = mysql_fetch_assoc($uPost);
			echo $up {'fecha'};
			echo '<br/>';
	        echo $up {'autor'};?></td>
          </tr>
          <?php } while ($row_categorias = mysql_fetch_assoc($categorias)); ?>
      </table>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar