MySQL - Problema con conexión MySql ...Ayuda !!!

 
Vista:
Imágen de perfil de Stephan

Problema con conexión MySql ...Ayuda !!!

Publicado por Stephan (2 intervenciones) el 26/04/2017 18:51:54
intento iniciar approva para colegios en mi hosting y me arroja el siguiente error del archivo LOG

[26-Apr-2017 15:41:33 UTC] PHP Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/ipssalud/public_html/ganjudaica.com/app/approva/instalacion/index.php on line 65


esa linea hace referencia a esto:
1
$retval = mysqli_query($mysqli,$sql) or die(mysqli_error());


el problema esta que me dice que me hace falta un parametro y no tengo ni idea de cual puede ser.

esto se encuentra en la carpeta approva/instalacion/index.php y es para crear la BD que ya esta creada previamente. Aca dejo mas codigo para que se puedan hacer una idea, Gracias por ayudarme, esto es muy frustrante.



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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
/*
This file is part of APPROVA (Sistema de Evaluación por Proyectos y Estándares de Aprendizaje).

APPROVA (Sistema de Evaluación por Proyectos y Estándares de Aprendizaje) is developed by Ram&oacute;n Castro P&eacute;rez. You can get more information at http://www.siestta.org

APPROVA (Sistema de Evaluación por Proyectos y Estándares de Aprendizaje) is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

APPROVA (Sistema de Evaluación por Proyectos y Estándares de Aprendizaje) is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You cand find a copy of the GNU General Public License in the "license" directory.

You should have received a copy of the GNU General Public License along with APPROVA; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
 
//forzamos codificación utf-8
header('Content-Type: text/html; charset=UTF-8');
 
echo '<h3>Instalación inicial de la Plataforma de Evaluación para Colegios ...</h3>';
//config.php
require('../config.php');
//functions.php
require('../functions.php');
//connect
$mysqli = new mysqli(DB_SERVER,DB_MYSQL_USER,DB_MYSQL_PASSWORD);
 
/*
$dbhost = 'localhost';
$dbuser = 'approva';
$dbpass = 'xxxxxxxxx';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);

if(! $conn ) {
die('No se pudo conectar al servidor de base de datos: ' . mysqli_error());
}
*/
 
 
//si venimos de dar de alta
 
if(isset($_POST['username'])){
 
//conexión dataBase
$con_mysql=mysqli_connect(DB_SERVER,DB_MYSQL_USER,DB_MYSQL_PASSWORD,DB_DATABASE);
if (!$con_mysql)
{
die("Connection error: " . mysqli_connect_error());
}
 
$username=$_POST['username'];
$password=sha1($_POST['password']);
$sql="insert into user values(NULL,'$username','$password')";
$result=mysqli_query($con_mysql,$sql) or die(mysqli_error());
if($result){
header("Location:../login.php?alta=si");
}else{
echo 'Hubo algún problema al proceder al registro inicial de usuario';
}
}
 
//fin dar de alta
 
$sql = 'CREATE Database ipssalud_approva';
////////////// esta es la linea /////////////
$retval = mysqli_query($mysqli,$sql) or die(mysqli_error());
////////////// esta es la linea /////////////
 
if(! $retval ) {
die('No se pudo crear la base de datos: ' . mysqli_error());
}
 
echo "La base de datos ipssalud_approva se ha creado";
echo '<br/>';
 
//conexión a la base de datos
mysqli_select_db( $mysqli,'ipssalud_approva' );
 
 
///////////////////////////////////////////////////creación de tablas
 
//agrupamientos
$sql="CREATE TABLE `agrupamientos` (
`id` int(11) NOT NULL auto_increment,
`agrupamiento` varchar(225) NOT NULL,
`curso` varchar(225) NOT NULL,
`materia` varchar(225) NOT NULL,
`nivel` varchar(225) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla agrupamientos creada';
echo '<br/>';
}
 
//alumnado
$sql="CREATE TABLE `alumnado` (
`id` int(11) NOT NULL auto_increment,
`agrupamiento_id` int(11) NOT NULL,
`alumno` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla alumnado creada';
echo '<br/>';
}
 
//asistencia
$sql="CREATE TABLE `asistencia` (
`id` int(11) NOT NULL auto_increment,
`alumno_id` int(11) NOT NULL,
`tipo` set('f','r','j') NOT NULL,
`fecha` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla asistencia creada';
echo '<br/>';
}
 
//calificaciones
$sql="CREATE TABLE `calificaciones` (
`id` int(11) NOT NULL auto_increment,
`alumno_id` int(11) NOT NULL,
`proyecto_id` int(11) NOT NULL,
`proyecto` varchar(255) NOT NULL,
`calificacion` decimal(4,2) NOT NULL,
`fecha` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla calificaciones creada';
echo '<br/>';
}
 
//diario
$sql="CREATE TABLE `diario` (
`id` int(11) NOT NULL auto_increment,
`sesion` date NOT NULL,
`agrupamiento_id` int(11) NOT NULL,
`diario` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla diario creada';
echo '<br/>';
}
 
//estándares
$sql="CREATE TABLE `estandares` (
`id` int(11) NOT NULL auto_increment,
`agrupamiento_id` int(11) NOT NULL,
`estandar` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla estándares creada';
echo '<br/>';
}
 
//horario
$sql="CREATE TABLE `horario` (
`id` int(11) NOT NULL auto_increment,
`franja` varchar(255) NOT NULL,
`dia` int(11) NOT NULL,
`agrupamiento_id` int(11) NOT NULL,
`agrupamiento` varchar(255) NOT NULL,
`espacio` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla horario creada';
echo '<br/>';
}
 
//proyectos
$sql="CREATE TABLE `proyectos` (
`id` int(11) NOT NULL auto_increment,
`agrupamiento_id` int(11) NOT NULL,
`estandar_id` int(11) NOT NULL,
`proyecto` varchar(255) NOT NULL,
`fecha` date NOT NULL,
`num` int(11) NOT NULL,
`peso` decimal(5,2) NOT NULL,
`ccl` set('0','1') NOT NULL,
`cmct` set('0','1') NOT NULL,
`cd` set('0','1') NOT NULL,
`caa` set('0','1') NOT NULL,
`csyc` set('0','1') NOT NULL,
`siep` set('0','1') NOT NULL,
`cec` set('0','1') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla proyectos creada';
echo '<br/>';
}
 
//usuario
$sql="CREATE TABLE `user` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$result=mysqli_query($mysqli,$sql) or die(mysqli_error());
if($result){
echo 'Tabla usuario creada';
echo '<br/>';
}
 
 
echo '<hr>';
 
 
mysqli_close($mysqli);
 
//fin creación de tablas
 
//presentamos formulario para insertar usuario y clave y ya, de paso, loguearnos
 
echo '<h1>Registro en la Plataforma de Evaluación</h1>';
 
echo '<h2>Introduzca el nombre de usuario y la contraseña con la que accederá a la plataforma</h2>';
 
echo '<p><big><b>Una vez introduzca sus datos, quedará registrado su nombre de usuario y contraseña y podrá utilizarlos para acceder a la plataforma</b></big></p>';
 
echo '<form method="post" action="index.php" id="login_form">';
 
echo '<ul>';
echo '<li>Nombre de usuario que va a usar para acceder: <input name="username" type="text" id="username" value="" size="10" maxlength="8" /></li>';
echo '<li>Clave que va a usar para acceder: <input name="password" type="text" id="password" value="" size="10" maxlength="8" /></li>';
echo '</ul>';
echo '<input class="button" name="Submit" type="submit" id="submit" value="Alta de usuario" />';
 
echo '</form>';
 
?>
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
sin imagen de perfil
Val: 953
Oro
Ha mantenido su posición en MySQL (en relación al último mes)
Gráfica de MySQL

Problema con conexión MySql ...Ayuda !!!

Publicado por leonardo_josue (414 intervenciones) el 26/04/2017 22:18:32
Hola Stephan:

Esto es un error de PHP más que de MySQL, por lo tanto no es correcto que preguntes en este foro... hay muchos foristas (me incluyo entre ellos) que no sabemos nada de PHP, pero sabemos algo de MySQL... es una política del foro que no incluyas código de ningún lenguaje de programación, sólo SQL, ojo con eso para la próxima.

Hay un foro específico para PHP en el cuál será más factible que te puedan ayudar:

http://www.lawebdelprogramador.com/foros/PHP/index1.html

Por lo pronto, y sin ser experto en la materia, revisé tu código y creo que el problema está en que el objeto $mysql que estás mandando a la función NO LO TIENES DECLARADO... entiendo que la función mysqli_query recibe como parámetros la conexión a la BD's y la consulta SQL que quieres ejecutar, sin embargo, en la parte donde creo que declaras la conexión utilizas otro nombre de objeto:

1
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);

por lo tanto, si estoy en lo correcto, la sentencia que marca error debería quedar más o menos así:

1
]$retval = mysqli_query($conn, $sql) or die(mysqli_error());

haz la prueba, y si continuas con problemas postea en el foro de PHP, no en este.

Saludos
Leo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Stephan

Problema con conexión MySql ...Ayuda !!!

Publicado por Stephan (2 intervenciones) el 27/04/2017 20:55:54
Muchas gracias por tu respuesta y tendre en cuenta las recomendaciones para el foro en las proximas consultas sobre BD, realmente aprecio que hayas tomado tu tiempo para ayudarme lo voy a probar y si no me funciona posteare en el foro de PHP, gracias y bendiciones.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar