Foros del Web » Programando para Internet » PHP »

Ayuda!!!!!!!!.... puro codigo y .... lectura BD

Estas en el tema de Ayuda!!!!!!!!.... puro codigo y .... lectura BD en el foro de PHP en Foros del Web. Lamentablemente no trabajé nunca con BD en PHP... y no sé cómo hacerlo. Tengo mi BD en Access y quisiera saber si es posible hacer ...
  #1 (permalink)  
Antiguo 06/02/2003, 02:49
Avatar de flavia  
Fecha de Ingreso: noviembre-2002
Mensajes: 269
Antigüedad: 21 años, 4 meses
Puntos: 0
Ayuda!!!!!!!!.... puro codigo y .... lectura BD

Lamentablemente no trabajé nunca con BD en PHP... y no sé cómo hacerlo.
Tengo mi BD en Access y quisiera saber si es posible hacer una conexión a Access desde PHP. Si debo utilizar MySQL, cómo hago para pasar la BD?? Y cómo la actualizo luego?
No sé cómo realizar este pedazo de código por ejemplo: (esta en ASP)


<%
dim tev
tev=Request.QueryString("tipo")
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

dim cx
Set cx = Server.CreateObject("ADODB.Connection")
cx.Open "ATenis","",""

'************************************************* *******************************************
' obtengo todos
dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "SELECT * from Evento WHERE (Tipo LIKE '" & tev & "')Order by Fecha DESC",cx

'************************************************* *******************************************
%>

<table width="74%" border="0" cellspacing="0">
<tr>
<td bgcolor="#000000" colspan="5"><img src="FOTOS/GRAFICA/eventi.gif" width="233" height="39"></td>
</tr>
<% if (rs.eof and rs.bof) then %>
<tr bgcolor="#FFFFFF">
<td align="center" colspan="15"> </td>
</tr>
<% else %>
<tr>
<td bgcolor="#FEECC0" colspan="5"> </td>
</tr>
<tr bgcolor="#FF9900">
<td colspan="5" bgcolor="#FEECC0">&nbsp;</td>
</tr>
<% do while not rs.eof %> <%

eve = rs("IdEvento")
%> <%
dim foto
dim pat
foto=rs("Foto")
quefoto = "Fotos/Eventi/" & foto & ".jpg"

pat=server.mappath("/Fotos/Eventi/")
foto= pat & "/" & foto & ".jpg"

dim service %>
<tr bgcolor="#333366">
<td width="93"><font color="#FFFFFF"><b></b></font></td>
<td width="93"><font color="#FFFFFF"><b><%=rs("Fecha")%></b></font></td>
<td width="2091" colspan="3"><font color="#FFFFFF"><b><%=rs("Titulo")%></b></font></td>
</tr>
<tr bgcolor="#FEECC0">
<td rowspan="5" width="93">&nbsp;</td>
<td rowspan="5" width="93">
<div align="right"><font size="2"><%If rs("Foto") <> "" Then%> <b> <image src="<%=quefoto%>" border="1" align="derecha"></b></font>
<font size="2"></font> <font size="2"></font><font size="2"></font>
<font size="2"><%else%> <b> <image src="Fotos/NoFoto.jpg" width="32" height="32" border="1"></b></font><font size="2"></font>
<font size="2"></font><font size="2"></font><font size="2"> </font><font size="2">
</font> <font size="2"><%End If%></font></div>
</td>
<td height="24" width="2091" colspan="3">
<blockquote>
<p><b><%=rs("Subtitulo")%></b></p>
</blockquote>
</td>
</tr>
<tr bgcolor="#FEECC0">
<td height="2" width="2091" colspan="3" >
<blockquote>
<p><%=rs("Texto")%></p>
</blockquote>
</td>
</tr>
<%
dim sql2
sql = "SELECT * from FotosxEvento WHERE (IdEvento LIKE '" & eve & "')"
' obtengo todas las fotos de un evento
dim rs2
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.open sql,cx
'<a href="Fotos.asp?evento=" & '"& eve &"' & "&titulo=" & '"& rs("Titulo")&"' & "&fecha=" & '"& rs("Fecha") &"'& "'&"'&"">fotos</a></p>
%>
<tr bgcolor="#FEECC0" colspan="3">
<td height="2" width="2091" colspan="3">
<p><%If not rs2.eof then %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="Fotos.asp?evento=<%=eve%>&titulo=<%=rs("Titu lo")%>&fecha=<%=rs("Fecha")%>">Fotos</a><%ELSE%>
&nbsp; <% end if %> </p>
</td>
</tr>
<tr bgcolor="#FEECC0" colspan="3">
<td height="2" width="2091" colspan="3"><%If rs("Link") <> "" Then%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<%=rs("Link")%>"><font size="2"><%=rs("Link")%></font></a>
<%else%>&nbsp; <%End If%> </td>
</tr>
<tr bgcolor="#FEECC0" colspan="3">
<td height="2" width="2091" colspan="3"><%If rs("Link2") <> "" Then%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<%=rs("Link2")%>"><font size="2"><%=rs("Link2")%></font></a>
<%else%>&nbsp; <%End If%> <br>
</td>
</tr>
<% rs.movenext %> <% loop %> <% end if %>
</table>


POR FAVOR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!
GRACIAS!
__________________
Flavia.
  #2 (permalink)  
Antiguo 06/02/2003, 05:08
 
Fecha de Ingreso: febrero-2003
Ubicación: Artés (Barcelona)
Mensajes: 3
Antigüedad: 21 años, 2 meses
Puntos: 0
si estas trabajando bajo windows puedes conectar access con php a través de ODBC.
  #3 (permalink)  
Antiguo 06/02/2003, 07:29
Avatar de flavia  
Fecha de Ingreso: noviembre-2002
Mensajes: 269
Antigüedad: 21 años, 4 meses
Puntos: 0
ah si?

y un ejemplito?
__________________
Flavia.
  #4 (permalink)  
Antiguo 06/02/2003, 10:55
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Un tutorial básico PHP y Mysql .. tiene un capitulo (el 6º creo) q trata sobre como interactuar via ODBC con PHP ...

http://otri.us.es/recursosPHP/manual/index.htm

Otro artículo sobre como trabajar con ODBC para Access en PHP:
http://www.phpbuilder.com/columns/siddarth20000228.php3

Todos hablan de usar un DSN de tu BD access para usarla via ODBC con las funciones nativas de PHP para tal fin ..

Si buscas la "cadena" de conexión OBCD típica q se suele usar en ASP .. busca en este foro . de vez en cuando sale (yo ahora no recuerdo de memoria ..).

Un saludo,
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 14:27.