PHP - Mysql y Mysqli con php

 
Vista:
Imágen de perfil de Guillermo

Mysql y Mysqli con php

Publicado por Guillermo (1 intervención) el 10/05/2014 07:30:21
Hola: este es mi primera consulta: tengo este codigo y necesito pasarlo a mysqli, pero escapa a mi comprension espero me puedan ayudar:

------------ codigo ---------------
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
<?php include('Connections/conecta.php'); ?>
<?php
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_conecta, $conecta);
$query_pgNombres = "SELECT * FROM corredora ORDER BY corredora.pg_nombres";
$pgNombres = mysql_query($query_pgNombres, $conecta) or die(mysql_error());
$row_pgNombres = mysql_fetch_assoc($pgNombres);
$totalRows_pgNombres = mysql_num_rows($pgNombres);
 
mysql_free_result($pgNombres);
?>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr bgcolor="#CCCCCC">
    <td>Id</td>
    <td>Nombres</td>
    <td>Apellidos</td>
    <td>Direccion</td>
    <td>Tel. Fijo</td>
    <td>Tel. Cell</td>
    <td>E-mail</td>
    <td>Tipo Vivienda</td>
    <td>Habitacion</td>
    <td>Baño</td>
    <td>Cocina</td>
    <td>Living</td>
    <td>Comedor</td>
    <td>Cochera</td>
    <td>Jardin</td>
    <td>Patio</td>
    <td>Comentarios</td>
    <td>Trato</td>
    <td>Modalidad</td>
    <td>Costo Mensual</td>
    <td>Costo Anual</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><?php echo $row_pgNombres['pg_cod']; ?></td>
    <td><?php echo $row_pgNombres['pg_nombres']; ?></td>
    <td><?php echo $row_pgNombres['pg_apellidos']; ?></td>
    <td><?php echo $row_pgNombres['pg_direccion']; ?></td>
    <td><?php echo $row_pgNombres['pg_telefono_fijo']; ?></td>
    <td><?php echo $row_pgNombres['pg_telefono_cell']; ?></td>
    <td><?php echo $row_pgNombres['pg_email']; ?></td>
    <td><?php echo $row_pgNombres['pg_vivienda_tipo']; ?></td>
    <td><?php echo $row_pgNombres['pg_habitacion']; ?></td>
    <td><?php echo $row_pgNombres['pg_banos']; ?></td>
    <td><?php echo $row_pgNombres['pg_cocina']; ?></td>
    <td><?php echo $row_pgNombres['pg_living']; ?></td>
    <td><?php echo $row_pgNombres['pg_comedor']; ?></td>
    <td><?php echo $row_pgNombres['pg_estacionamiento']; ?></td>
    <td><?php echo $row_pgNombres['pg_jardin']; ?></td>
    <td><?php echo $row_pgNombres['pg_patio']; ?></td>
    <td><?php echo $row_pgNombres['pg_comentarios']; ?></td>
    <td><?php echo $row_pgNombres['pg_trato']; ?></td>
    <td><?php echo $row_pgNombres['pg_modalidad']; ?></td>
    <td><?php echo $row_pgNombres['pg_costo_mes']; ?></td>
    <td><?php echo $row_pgNombres['pg_costo_ano']; ?></td>
    <td><p>Eliminar</p>
    <p>Modificar</p></td>
  </tr>
</table>

------------- conexion -------------------------
1
2
3
4
5
6
7
8
9
10
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conecta = "localhost";
$database_conecta = "pgpropiedades";
$username_conecta = "guille";
$password_conecta = "nena1521";
$conecta = mysql_connect($hostname_conecta, $username_conecta, $password_conecta) or trigger_error(mysql_error(),E_USER_ERROR);
?>
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