Foros del Web » Programando para Internet » PHP »

problemas No database selected

Estas en el tema de problemas No database selected en el foro de PHP en Foros del Web. Hola estoy intentando crear un libro de visitas, primero hice una base de datos de nombre guestbook cree la tabla con 4 modulos, nombre varchar ...
  #1 (permalink)  
Antiguo 10/09/2008, 17:23
 
Fecha de Ingreso: septiembre-2008
Mensajes: 5
Antigüedad: 11 años, 3 meses
Puntos: 0
problemas No database selected

Hola estoy intentando crear un libro de visitas, primero hice una base de datos de nombre guestbook cree la tabla con 4 modulos, nombre varchar 50 no null, correo varchar 50 no null, fecha int 10 no null y comentario int 11 auto increment

despues hice mi php...
con el siguiente código

<?php
$link = mysql_connect("localhost","oi000008'@'localhost"," ");
mysql_select_db("oi000008_guestbook",$link);

if($_POST['nombre']!="" && $_POST['comentario']!="")
{
$fecha = time();
$query = "INSERT INTO mensajes (nombre, correo, fecha, comentario) VALUES
('$_POST[nombre]','$_POST[correo]','$fecha','$_POST[comentario]')";
mysql_query ($query, $link) or die (mysql_error());
}
?><style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #CCCCCC;
}
body {
background-color: #666666;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.Estilo1 { color: #009999;
font-size: 16px;
}
-->
</style>

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) {
img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr)
for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
} }
}
//-->
</script>
<body onLoad="MM_preloadImages('menutodo_r2_c2_f3.gif',' menutodo_r2_c2_f2.gif','menutodo_r2_c2_f4.gif','me nutodo_r3_c4_f3.gif','menutodo_r3_c4_f2.gif','menu todo_r3_c4_f4.gif','menutodo_r3_c6_f3.gif','menuto do_r3_c6_f2.gif','menutodo_r3_c6_f4.gif','menutodo _r4_c8_f3.gif','menutodo_r4_c8_f2.gif','menutodo_r 4_c8_f4.gif','menutodo_r4_c10_f3.gif','menutodo_r4 _c10_f2.gif','menutodo_r4_c10_f4.gif','menuall_r2_ c2_f3.gif','menuall_r2_c2_f2.gif','menuall_r2_c2_f 4.gif','menuall_r3_c8_f3.gif','menuall_r3_c8_f2.gi f','menuall_r3_c8_f4.gif','menuall_r4_c4_f3.gif',' menuall_r4_c4_f2.gif','menuall_r4_c4_f4.gif','menu all_r4_c6_f3.gif','menuall_r4_c6_f2.gif','menuall_ r4_c6_f4.gif','menuall_r4_c10_f3.gif','menuall_r4_ c10_f2.gif','menuall_r4_c10_f4.gif')"><p>&nbsp;</p>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="854" height="53" align="middle">
<param name="movie" value="nataliadominguez.swf">
<param name="quality" value="high">
<embed src="nataliadominguez.swf" width="854" height="53" align="middle" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
</object></td>
</tr>
<tr>
<td><form method="POST" action="<?=$PHP_SELF?>">
<p align="center"><span class="Estilo1">Guestbook</span></p>
<p align="center">name /nombre:
<input type="text" name="nombre" size="20">
</p>
<p align="center">email / correo:
<input type="text" name="correo" size="20">
</p>
<p align="center"><br>
Commentes / Comentario:<br>
<textarea rows="17" name="comentario" cols="58"></textarea>
<br>
<input type="submit" value="Enviar" name="B1">
</p>
</form></td>
</tr>
<tr>
<td><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><p class="Estilo1">&nbsp;</p>
<tr>
<th scope="col"><table border="0" cellpadding="0" cellspacing="0" width="800">
<!-- fwtable fwsrc="menutodo.png" fwbase="menutodo.gif" fwstyle="Dreamweaver" fwdocid = "1971961467" fwnested="0" -->
<tr>
<td><img src="spacer.gif" width="18" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="78" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="62" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="98" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="76" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="85" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="85" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="92" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="82" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="97" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="27" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="1" border="0" alt=""></td>
</tr>
<tr>
<td colspan="11"><img name="menutodo_r1_c1" src="menutodo_r1_c1.gif" width="800" height="21" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="21" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="5"><img name="menutodo_r2_c1" src="menutodo_r2_c1.gif" width="18" height="28" border="0" alt=""></td>
<td rowspan="3"><a href="index2.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menutodo_r2_c2','m enutodo_r2_c2_f2.gif','menutodo_r2_c2_f4.gif',1);" onClick="MM_nbGroup('down','navbar1','menutodo_r2_ c2','menutodo_r2_c2_f3.gif',1);"><img name="menutodo_r2_c2" src="menutodo_r2_c2.gif" width="78" height="20" border="0" alt="inicio"></a></td>
<td colspan="9"><img name="menutodo_r2_c3" src="menutodo_r2_c3.gif" width="704" height="6" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="6" border="0" alt=""></td>
</tr>
  #2 (permalink)  
Antiguo 10/09/2008, 17:24
 
Fecha de Ingreso: septiembre-2008
Mensajes: 5
Antigüedad: 11 años, 3 meses
Puntos: 0
Respuesta: problemas No database selected

<tr>
<td rowspan="4"><img name="menutodo_r3_c3" src="menutodo_r3_c3.gif" width="62" height="22" border="0" alt=""></td>
<td rowspan="2"><a href="biografia.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menutodo_r3_c4','m enutodo_r3_c4_f2.gif','menutodo_r3_c4_f4.gif',1);" onClick="MM_nbGroup('down','navbar1','menutodo_r3_ c4','menutodo_r3_c4_f3.gif',1);"><img name="menutodo_r3_c4" src="menutodo_r3_c4.gif" width="98" height="14" border="0" alt="Biograf&iacute;a de Natalia"></a></td>
<td rowspan="4"><img name="menutodo_r3_c5" src="menutodo_r3_c5.gif" width="76" height="22" border="0" alt=""></td>
<td rowspan="2"><a href="obra.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menutodo_r3_c6','m enutodo_r3_c6_f2.gif','menutodo_r3_c6_f4.gif',1);" onClick="MM_nbGroup('down','navbar1','menutodo_r3_ c6','menutodo_r3_c6_f3.gif',1);"><img name="menutodo_r3_c6" src="menutodo_r3_c6.gif" width="85" height="14" border="0" alt="Obra de Natalia"></a></td>
<td colspan="5"><img name="menutodo_r3_c7" src="menutodo_r3_c7.gif" width="383" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="1" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="3"><img name="menutodo_r4_c7" src="menutodo_r4_c7.gif" width="85" height="21" border="0" alt=""></td>
<td rowspan="2"><a href="registro.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menutodo_r4_c8','m enutodo_r4_c8_f2.gif','menutodo_r4_c8_f4.gif',1);" onClick="MM_nbGroup('down','navbar1','menutodo_r4_ c8','menutodo_r4_c8_f3.gif',1);"><img name="menutodo_r4_c8" src="menutodo_r4_c8.gif" width="92" height="20" border="0" alt="registro"></a></td>
<td rowspan="3"><img name="menutodo_r4_c9" src="menutodo_r4_c9.gif" width="82" height="21" border="0" alt=""></td>
<td rowspan="2"><a href="contacto.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menutodo_r4_c10',' menutodo_r4_c10_f2.gif','menutodo_r4_c10_f4.gif',1 );" onClick="MM_nbGroup('down','navbar1','menutodo_r4_ c10','menutodo_r4_c10_f3.gif',1);"><img name="menutodo_r4_c10" src="menutodo_r4_c10.gif" width="97" height="20" border="0" alt="Contacto con Natalia"></a></td>
<td rowspan="3"><img name="menutodo_r4_c11" src="menutodo_r4_c11.gif" width="27" height="21" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="13" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="2"><img name="menutodo_r5_c2" src="menutodo_r5_c2.gif" width="78" height="8" border="0" alt=""></td>
<td rowspan="2"><img name="menutodo_r5_c4" src="menutodo_r5_c4.gif" width="98" height="8" border="0" alt=""></td>
<td rowspan="2"><img name="menutodo_r5_c6" src="menutodo_r5_c6.gif" width="85" height="8" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="7" border="0" alt=""></td>
</tr>
<tr>
<td><img name="menutodo_r6_c8" src="menutodo_r6_c8.gif" width="92" height="1" border="0" alt=""></td>
<td><img name="menutodo_r6_c10" src="menutodo_r6_c10.gif" width="97" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="1" border="0" alt=""></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="800">
<!-- fwtable fwsrc="menuall.png" fwbase="menuall.gif" fwstyle="Dreamweaver" fwdocid = "1971961467" fwnested="0" -->
<tr>
<td><img src="spacer.gif" width="33" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="85" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="54" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="111" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="70" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="73" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="68" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="92" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="85" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="86" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="43" height="1" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="1" border="0" alt=""></td>
</tr>
<tr>
<td colspan="11"><img name="menuall_r1_c1" src="menuall_r1_c1.gif" width="800" height="16" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="16" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="6"><img name="menuall_r2_c1" src="menuall_r2_c1.gif" width="33" height="34" border="0" alt=""></td>
<td rowspan="3"><a href="index3.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menuall_r2_c2','me nuall_r2_c2_f2.gif','menuall_r2_c2_f4.gif',1);" onClick="MM_nbGroup('down','navbar1','menuall_r2_c 2','menuall_r2_c2_f3.gif',1);"><img name="menuall_r2_c2" src="menuall_r2_c2.gif" width="85" height="20" border="0" alt="home"></a></td>
<td colspan="9"><img name="menuall_r2_c3" src="menuall_r2_c3.gif" width="682" height="4" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="4" border="0" alt=""></td>
</tr>
<tr>
<td colspan="5"><img name="menuall_r3_c3" src="menuall_r3_c3.gif" width="376" height="2" border="0" alt=""></td>
<td rowspan="3"><a href="register.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menuall_r3_c8','me nuall_r3_c8_f2.gif','menuall_r3_c8_f4.gif',1);" onClick="MM_nbGroup('down','navbar1','menuall_r3_c 8','menuall_r3_c8_f3.gif',1);"><img name="menuall_r3_c8" src="menuall_r3_c8.gif" width="92" height="20" border="0" alt="register"></a></td>
<td colspan="3"><img name="menuall_r3_c9" src="menuall_r3_c9.gif" width="214" height="2" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="2" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="4"><img name="menuall_r4_c3" src="menuall_r4_c3.gif" width="54" height="28" border="0" alt=""></td>
<td><a href="biography.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menuall_r4_c4','me nuall_r4_c4_f2.gif','menuall_r4_c4_f4.gif',1);" onClick="MM_nbGroup('down','navbar1','menuall_r4_c 4','menuall_r4_c4_f3.gif',1);"><img name="menuall_r4_c4" src="menuall_r4_c4.gif" width="111" height="14" border="0" alt="Biography Natalia"></a></td>
<td rowspan="4"><img name="menuall_r4_c5" src="menuall_r4_c5.gif" width="70" height="28" border="0" alt=""></td>
<td rowspan="3"><a href="work.htm" target="_top" onClick="MM_nbGroup('down','navbar1','menuall_r4_c 6','menuall_r4_c6_f3.gif',1);" onMouseOver="MM_nbGroup('over','menuall_r4_c6','me nuall_r4_c6_f2.gif','menuall_r4_c6_f4.gif',1);" onMouseOut="MM_nbGroup('out');"><img name="menuall_r4_c6" src="menuall_r4_c6.gif" width="73" height="20" border="0" alt="Work Natalia"></a></td>
<td rowspan="4"><img name="menuall_r4_c7" src="menuall_r4_c7.gif" width="68" height="28" border="0" alt=""></td>
<td rowspan="4"><img name="menuall_r4_c9" src="menuall_r4_c9.gif" width="85" height="28" border="0" alt=""></td>
<td rowspan="3"><a href="contact.htm" target="_self" onMouseOut="MM_nbGroup('out');" onMouseOver="MM_nbGroup('over','menuall_r4_c10','m enuall_r4_c10_f2.gif','menuall_r4_c10_f4.gif',1);" onClick="MM_nbGroup('down','navbar1','menuall_r4_c 10','menuall_r4_c10_f3.gif',1);"><img name="menuall_r4_c10" src="menuall_r4_c10.gif" width="86" height="20" border="0" alt="Contact Natalia"></a></td>
<td rowspan="4"><img name="menuall_r4_c11" src="menuall_r4_c11.gif" width="43" height="28" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="14" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="3"><img name="menuall_r5_c2" src="menuall_r5_c2.gif" width="85" height="14" border="0" alt=""></td>
<td rowspan="3"><img name="menuall_r5_c4" src="menuall_r5_c4.gif" width="111" height="14" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="4" border="0" alt=""></td>
</tr>
<tr>
<td rowspan="2"><img name="menuall_r6_c8" src="menuall_r6_c8.gif" width="92" height="10" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="2" border="0" alt=""></td>
</tr>
<tr>
<td><img name="menuall_r7_c6" src="menuall_r7_c6.gif" width="73" height="8" border="0" alt=""></td>
<td><img name="menuall_r7_c10" src="menuall_r7_c10.gif" width="86" height="8" border="0" alt=""></td>
<td><img src="spacer.gif" width="1" height="8" border="0" alt=""></td>
</tr>
</table></th>
</tr>
</table></td>
</tr>
</table>
  #3 (permalink)  
Antiguo 10/09/2008, 17:25
 
Fecha de Ingreso: septiembre-2008
Mensajes: 5
Antigüedad: 11 años, 3 meses
Puntos: 0
Respuesta: problemas No database selected

<p><center>
<?php
$query = "SELECT * FROM mensajes ORDER BY fecha";
$result = mysql_query ($query, $link) or die (mysql_error());

if(mysql_num_rows($result)!=0)
{
print '<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse"
bordercolor="#111111" width="446" height="90">';
$i=0;

while ($row = mysql_fetch_array($result))
{
if($i % 2)
{
$color = "#DBDBDB";
}else{
$color = "#E9E9E9";
}
$i++;

if($row[correo]!="")
{
$nombre = '<a href="mailto:'.$row[correo].'">'.$row[nombre].'</a>';
}else{
$nombre = $row[nombre];
}
print '<tr>
<td width="130" height="14" valign="top" bgcolor="'.$color.'">'.$nombre.'
('.date("d/m/Y",$row[fecha]).')</td>
<td width="310" height="90" valign="top" rowspan="2"
bgcolor="'.$color.'">Comentario:<br>'.nl2br($row[comentario]).'</td>
</tr>
<tr>
<td width="130" height="72" valign="top" bgcolor="'.$color.'"></td>
</tr>';
}
print '</table>';
}
?>
</p>

Pero el promblema es que me marca No database selected no se si no se esta conectando o que pasa... pueden ver aqui: http://www.nataliadominguez.net/libro.php
  #4 (permalink)  
Antiguo 10/09/2008, 23:23
Avatar de pepeverastegui  
Fecha de Ingreso: septiembre-2008
Ubicación: Pedernales, Michoacan
Mensajes: 82
Antigüedad: 11 años, 3 meses
Puntos: 2
Respuesta: problemas No database selected

Cita:
Iniciado por amarlatierra Ver Mensaje
<?php
$link = mysql_connect("localhost","oi000008'@'localhost"," ");
mysql_select_db("oi000008_guestbook",$link);
ps mira no se que pueda ser
pero por decirmis conexiones io las tengo asi


$db =mysql_connect("localhost", "root", "password");
mysql_select_db("basededatos");

io no paso el segundo parametro que tu pasas al mysql_select_db()
yo unicamente manejo un solo servidor de bases de datos pruebale alo mejro pudiera funcionar
  #5 (permalink)  
Antiguo 11/09/2008, 02:03
 
Fecha de Ingreso: agosto-2008
Mensajes: 218
Antigüedad: 11 años, 4 meses
Puntos: 7
Respuesta: problemas No database selected

Cita:
Iniciado por amarlatierra
<?php
$link = mysql_connect("localhost","oi000008'@'localhost"," ");
mysql_select_db("oi000008_guestbook",$link);
prueba así: mysql_connect("localhost", USER, PASSWORD);
donde USER es el usuario y PASSWORD la contraseña.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:39.