Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/05/2011, 05:44
murcielag56
 
Fecha de Ingreso: septiembre-2010
Mensajes: 72
Antigüedad: 13 años, 7 meses
Puntos: 0
error al insewrtar datos en tabla

Tengo el sguiente formulario. Después lo arreglaré, pero quiero que ahora funcione. Lo de escribir una pagina web no hay problema.
El problema está cuando le indico listado y presiono.
Me da este error: Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\Integra2_1\ite2_1\veloc_descarga1. php on line 61

Me supongo que además tengo que hacer el update de la DB.
Alguien puede darme una ayuda. Gracias
-------------------------------

<html>
<head><title> velocidad </title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-color: #669900;
}
.Estilo1 {
color: #CC0033;
font-weight: bold;
}
-->
</style></head>
<body>
<center><h1><strong> </strong></h1>
<h2>MENU VELOCIDAD DESCARGA WEBS </h2>
<p>&nbsp;</p>
<table width="84%" border="2" cellspacing="1" cellpadding="5">
<tr>
<td width="36%" height="57"><div align="center">INTRODUCCION NOMBRE P&Aacute;GINA </div></td>
<td width="64%"><form name="form1" method="post" action="veloc_descarga1.php">
<p>Nombre de la p&aacute;gina WEB
<input type="text" name="url" >
escriba asi http://www.google.com
</p>
<p>
<input type="submit" name="Submit" value="Enviar">
</p>
<p>&nbsp; </p>
</form></td>
</tr>
<form action="veloc_descarga1.php" method="post" target=inferior>
<input type="submit" name="lista" value="LISTADO">
<tr>
<td height="64">ESTADISTICAS</td>
<td>&nbsp;</td>
</tr>
</table>
<h1 class="Estilo1">&nbsp;</h1>
<p class="Estilo1">&nbsp;</p>
<p class="Estilo1">&nbsp;</p>
<p class="Estilo1">&nbsp;</p>
<hr>

<p> <br>

<p>&nbsp;</p>
</form>
</center>
</body>
</html>


------------------------------------
<?php
$direccion=$_POST['url'];
//if(isset($_REQUEST['url'])) {

if($direccion){
echo "$direccion";
//Veloc (bits / segundo) = bits / (TFin - TComienzo)
//carácter CUALQUIERA siempre tendrá un tamaño de 1 Byte, es decir 8 impulsos electrónicos ( 8 Bit)
$tmicro[1]= microtime();
$q_espacios = explode(" ",$tmicro[1]);
$tiempo_[1]= $q_espacios[1]+$q_espacios[0];

//file_get_contents — Transmite un archivo entero a una cadena
$pagina=file_get_contents($direccion);
$tamanoKB= strlen($pagina)/1024;
//for ($i=0;$i<$tamanoKB;$i++){
//for ($i=0;$i<srtlen($pagina);$i++){
//$line = fget($pagina);
//}
//$tamanoKB= strlen($pagina)/1024;

echo $tamanoKB ."<br>";

$tiempo_micro[2] = microtime();
$q_espacios= explode(" ",$t_micro[2]);
$tiempo_[2] =$q_espacios[1] + $q_espacios[0];
$timeutilizado = number_format(($tiempo_[2] - $tiempo_[1]),2, "." ,","); //Format a number with grouped thousands

//$velocdescarga= round($tamanoKB/$timeutilizado,3);

echo 'velocidad de conexión es de: '.$velocdescarga.' Kbps <br /> Se enviarón:'.$tamanoKB.
' Kb, Tiempo utilizado: '.$timeutilizado.' Segundos <hr>';
}

$conexion=mysql_connect("localhost","root","1234") ;
//$conexion=mysql_connect("localhost","root","majada ");
mysql_select_db("velocidad",$conexion);

//$conexion = mysql_connect('lldb499.servidoresdns.net', 'qdr098', 'Aula21');
//mysql_select_db('qdr098', $conexion);
If (mysql_errno($conexion)!=0)
{ $mensaje= mysql_error($conexion);
Echo "$mensaje";
}
if(isset($_REQUEST['lista'])) {

//$dia = current date();

$query = "INSERT INTO stat_table (
Num,
fecha,
velocidad,
tamano,
Npagina
) VALUES (
'current date',
'$$velocdescarga',
'$tamanoKB',
'$pagina',
);";
$result = mysql_query($query, $db);

}
?>

Última edición por murcielag56; 07/05/2011 a las 05:53 Razón: un error