PHP - al darle al boton se pone la pagina en blanco. codigo

 
Vista:

al darle al boton se pone la pagina en blanco. codigo

Publicado por Toni (4 intervenciones) el 10/10/2012 21:34:41
bueno. este codigo es un chat, el cual al enviar mensajes estos se actualizan... pero resulta que al darle al boton lo que hace es quedarse la pagina en blanco con el texto.

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php require_once('Connections/conexion.php'); ?>
<?php
session_start();
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO mensajes (sala, nick, mensaje) VALUES (%s, %s, %s)",
                       GetSQLValueString($_POST['sala'], "text"),
                       GetSQLValueString($_POST['nick'], "text"),
                       GetSQLValueString($_POST['mensaje'], "text"));
 
  mysql_select_db($database_conexion, $conexion);
  $Result1 = mysql_query($insertSQL, $conexion) or die(mysql_error());
}
 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
mysql_select_db($database_conexion, $conexion);
$query_Recordset1 = "SELECT * FROM mensajes";
$Recordset1 = mysql_query($query_Recordset1, $conexion) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
mysql_select_db($database_conexion, $conexion);
$query_Recordset2 = "SELECT * FROM usuarios ORDER BY nick ASC";
$Recordset2 = mysql_query($query_Recordset2, $conexion) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
 
if($_POST)
{
    //set_time_limit(0);    
    header("Edge-control: no-store");
    usleep(1000);
 
       do {
$content[]= $row_Recordset1['mensaje'];
  $sala[]= $row_Recordset1['sala'];
   } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
   for ( $i = 0 ; $i < count($content); $i++) {
 
if ($sala[$i] == $_SESSION['variable']) {
echo ($content[$i]."\n");
 
 }
 
 
}
 exit();
 
 
}
?>
 
 
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<table width="1015" border="1">
  <tr>
    <td width="861">Nick:<?php echo $_SESSION['MM_Username']?></td>
    <td width="138">Nombre sala:<?php echo $_SESSION['variable'];
 
?></td>
  </tr>
  <tr>
    <td height="167"><textarea name="content" cols="100" rows="10" id="content">Cargando...</textarea></td>
    <td align="left" valign="top"><form id="form2" name="form2" method="post" action="">
      <div id="toni">
        <ul id="MenuBar1" class="MenuBarHorizontal">
          <?php do { ?>
          <li><a class="MenuBarItemSubmenu" href="#"><?php echo $row_Recordset2['nick']; ?></a>
            <ul>
              <li><a href="#">Abrir privado</a></li>
              <li><a href="#">Iniciar webcam</a></li>
              <li><a href="#">Silenciar</a></li>
              </ul>
            </li>
          <?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
        </ul>
      </div>
</form></td>
</tr>
  <tr>
    <td align="left" valign="top"><form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1">
      <input type="text" name="mensaje" value="" size="32" />
      <input type="submit" value="Insertar registro" />
      <input type="hidden" name="sala" value="<?php echo $_SESSION['variable']; ?>" />
      <input type="hidden" name="nick" value="<?php echo $_SESSION['MM_Username']; ?>" />
      <input type="hidden" name="MM_insert" value="form2" />
      <input type="hidden" name="MM_insert" value="form1" />
    </form></td>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
</table>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
<script type="text/javascript" src="comet.js"></script>
<?PHP
 
 
mysql_free_result($Recordset1);
 
mysql_free_result($Recordset2);
?>

Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
-1
Responder