Quiz
PHP y MySQL: sesiones, formularios y procedimientos almacenados
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (18)
1Analice el siguiente código y seleccione la instrucción que hace falta para la ejecución correcta
<?php
$_SESSION['usuario']=$_REQUEST['campousuario'];
$_SESSION['clave']=$_REQUEST['campoclave']; ?>
<html> <head> <title>Problema</title> </head>
<body> Se almacenaron dos variables de sesión.<br><br>
<a href="pagina3.php">Ir a la tercer página donde se recuperarán las variables de sesión</a>
</body> </html>- Asession_start();
- Bsetcookie("usuario","diego",0);
- Cif (isset($_COOKIE['valor']))
- Dwhile ($reg=mysql_fetch_array($registros))
2Analice el siguiente código, el mismo que debe permitir el envió de datos seleccionar la línea correcta:
<html> <head> <title>El gran agujero de seguridad</title> </head>
<body> <h2>Agujero de seguridad en register_globals = On</h2>
Contraseña: <input type="password" name="pass">
<input type="submit" value="Enviar">
</form>
<?php if ($pass == "abc_xyz_123") { $login = true; }
if ($login) { echo "<p>Aqui empieza el arma secreta.</p>"; }
?> </body>
</html>- A<form action="<?php echo "33_seguridad.php"; ?>" method="post">
- B<form action="<?php echo "33_seguridad.php"; ?>" metod="post">
- C<form action="<?php echo "33_seguridad.php"; ?>" method=post>
- D<form action="<?php echo "33_seguridad.php"; ?>" method="gets">
3Analice el siguiente código para seleccionar los datos de la tabla dirección, debe de determinar la línea correcta.
<html> <head> <title>MySQL 01 - Consulta a BD (Agenda)</title> </head>
<body> <h1>Mostrar Nombres de la Agenda. BD </h1>
mysql_select_db("agenda", $dp);
$sql = "SELECT * FROM direcciones" ;
$resultado = mysql_query($sql);
while ($row = mysql_fetch_assoc($resultado)) {
echo "$row[Nombre] $row[Apellido]<br>\n"; }
mysql_close($dp); ?> </body> </html>- A<?php $dp = mysql_connect("localhost", "root", "" );
- B<?php $dp = mysql_open("localhost", "root", "" );
- C<?php $dp = mysql_connect("localhost", "", "root" );
- D<?php $dp = mysql_open("root", "usuario", "" );
42. Analice el siguiente código de html que permita el envia de datos mediante un botón y la siguiente etiqueta.
<!DOCTYPE html>
<html lang="es-ES">
<head>
<meta charset="utf-8">
<title>Ejemplo de formulario básico</title>
</head>
<body>
<form>
Nombre:
<br>
<input type="text">
<br>
Edad:
<br>
<input type="number">
<br><br>
<input type="submit" value="Enviar datos">
</form>
</body>
</html>- A<input type="submit" value="Enviar datos"> </form>
- B<input type="submit" text="Enviar datos"> </text>
- C<input type="search" value="Enviar datos"> </input>
- D<input type="submitt" value="Enviar datos"> </form>
5Seleccione la ejecución correcta del procedimiento almacenado para consultar los producto que empiezan con una determinada letra.
USE Northwind
GO
CREATE PROCEDURE paunos @ProductName varchar(50)
AS
SELECT * FROM Products
WHERE Productname LIKE @ProductName+'%'
GO- Aexecute paunos 'A'
- Bexecute paunos A
- Cexecute pauno 'A'
- Dexecute 'A' paunos
63. Del siguiente procedimiento almacenado determinar la ejecución correcta del mismo.
USE Northwind
GO
CREATE PROCEDURE padoss @ProductID int, @ProductName varchar(50) output, @UnitPrice Money output
AS
SELECT @ProductName = ProductName, @UnitPrice = UnitPrice
FROM Products WHERE ProductID = @ProductID
GO- Adeclare @Nombre varchar(50), @Precio Money
Execute pados 10, @Nombre OUTPUT, @Precio OUTPUT
SELECT @Nombre AS Nombre, @Precio AS Precio - Bdeclare @Nombre varchar(50), @Precio Money
Execute pados @Nombre OUTPUT, @Precio OUTPUT,100
SELECT @Nombre AS Nombre, @Precio AS Precio - Cdeclare @Precio Money, @Nombre varchar(50),
Execute pados @Nombre OUTPUT, @Precio OUTPUT - DSELECT @Nombre AS Nombre, @Precio AS Precio
declare @Nombre varchar(50), @Precio Money
Execute pados '100', @Nombre OUTPUT, @Precio OUTPUT
SELECT @Nombre AS Nombre, @Precio AS Precio
- Adeclare @Nombre varchar(50), @Precio Money
7Lea el siguiente enunciado y determine la linea de sql correcta. Consultar el nombre del producto, el número de unidades totales vendidas, del producto que más unidades ha vendido la empresa.
- Ause Northwind
go
select productname, unitsonorder
from products
where unitsonorder= (SELECT MAX(unitsonorder)from products ) - Buse Northwind
go
select productname, unitsonorder
from products
where unitsonorder= (SELECT COUNT(unitsonorder)from products ) - Cuse Northwind
go
select productname, unitsonorder
from products
where unitsonorder= (SELECT AVG(unitsonorder)from products ) - Duse Northwind
go
select productname, unitsonorder
from products
where unitsonorder= (SELECT SUM(unitsonorder)from products)/( SELECT COUNT(unitsonorder)from products)
- Ause Northwind
8Del siguiente enunciado determinar la línea de sql correcta, para consultar los clientes que compraron en el 1996 y 1997
- Aselect * from Customers where CustomerID in (select distinct CustomerID from Orders where Datename(mm,OrderDate) = 'Agosto' and year (orderdate )between ( 1996) AND ( 1997))
- Bselect * from Customers where CustomerID in (select distinct CustomerID from Orders where Datename(mm,OrderDate) = 'Agosto' and year (orderdate )between ( '1996') AND ( ' 1997'))
- Cselect * from Customers where CustomerID in (select distinct CustomerID from Orders where Datename(mm,OrderDate) = Agosto and year (orderdate )between ( 1996) AND ( 1997))
- Dselect * from Customers where CustomerID in (select distinct CustomerID from Orders where Datename(mm,OrderDate) = 'Agosto' and year (orderdate )between ( 1996) or ( 1997))
9Observe la imagen y analice para seleccionar la linea de sql que permite la operación de join correcta entre las tablas de la imagen.

- ASELECT Products.ProductName, [Order Details].ProductID, [Order Details].UnitPrice, [Order Details].Quantity, Customers.CompanyName, Employees.LastName, Employees.FirstName FROM [Order Details] INNER JOIN
Orders ON [Order Details].OrderID = Orders.OrderID INNER JOIN
Customers ON Orders.CustomerID = Customers.CustomerID INNER JOIN
Employees ON Orders.EmployeeID = Employees.EmployeeID INNER JOIN
Products ON [Order Details].ProductID = Products.ProductID where [Order Details].UnitPrice >=50 - BSELECT Products.ProductName, [Order Details].ProductID, [Order Details].UnitPrice, [Order Details].Quantity, Customers.CompanyName, Employees.LastName, Employees.FirstName FROM [Order Details] JOIN Orders ON [Order Details].OrderID = Orders.OrderID JOIN Customers ON Orders.CustomerID = Customers.CustomerID INNER JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID INNER JOIN Products ON [Order Details].ProductID = Products.ProductID where [Order Details].UnitPrice >=50
- CSELECT Products.ProductName, [Order Details].ProductID, [Order Details].UnitPrice, [Order Details].Quantity, Customers.CompanyName, Employees.LastName, Employees.FirstName FROM [Order Details] INNER
Orders ON [Order Details].OrderID = Orders.OrderID INNER
Customers ON Orders.CustomerID = Customers.CustomerID INNER JOIN
Employees ON Orders.EmployeeID = Employees.EmployeeID INNER JOIN
Products ON [Order Details].ProductID = Products.ProductID where [Order Details].UnitPrice >=50 - DSELECT Products.ProductName, [Order Details].ProductID, [Order Details].UnitPrice, [Order Details].Quantity, Customers.CompanyName, Employees.LastName, Employees.FirstName FROM [Order Details] INNER JOIN
Orders ON [Order Details].OrderID = Orders.OrderID INNER JOIN
Customers ON Orders.CustomerID = Customers.CustomerID INNER JOIN
Employees ON Orders.EmployeeID = Employees.EmployeeID INNER JOIN
Products ON [Order Details].ProductID <> Products.ProductID where [Order Details].UnitPrice >=50
- ASELECT Products.ProductName, [Order Details].ProductID, [Order Details].UnitPrice, [Order Details].Quantity, Customers.CompanyName, Employees.LastName, Employees.FirstName FROM [Order Details] INNER JOIN
10Observe la imagen de la base de datos para escoger la linea de sql que permite calcular la sumatoria de un determinado producto.

- ASELECT Products.ProductName, [Order Details].ProductID, sum ([Order Details].UnitPrice) FROM [Order Details] INNER JOIN Products ON [Order Details].ProductID = Products.ProductID group by [Order Details].ProductID,Products.ProductName having [Order Details].ProductID=1 order by Products.ProductName
- BSELECT Products.ProductName, [Order Details].ProductID, sum ([Order Details].UnitPrice) FROM [Order Details] INNER JOIN Products ON [Order Details].ProductID = Products.ProductID group by Products.ProductName having [Order Details].ProductID=1 order by Products.ProductName
- CSELECT Products.ProductName, [Order Details].ProductID, avg([Order Details].UnitPrice) FROM [Order Details] INNER JOIN Products ON [Order Details].ProductID = Products.ProductID group by [Order Details].ProductID,Products.ProductName having [Order Details].ProductID=1 order by Products.ProductName
- DSELECT Products.ProductName, [Order Details].ProductID, ([Order Details].UnitPrice) FROM [Order Details] INNER JOIN Products ON [Order Details].ProductID = Products.ProductID group by [Order Details].ProductID,Products.ProductName having [Order Details].ProductID=1 order by Products.ProductName
11Del siguiente código de sql determinar la consulta para calcular la cantidad de productos ordenados por un vendedor.

- ASELECT Employees.LastName, Employees.FirstName, Orders.EmployeeID, SUM([Order Details].Quantity) AS Total FROM [Order Details] INNER JOIN Orders ON [Order Details].OrderID = Orders.OrderID INNER JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID GROUP BY Employees.LastName, Employees.FirstName, Orders.EmployeeID HAVING (Orders.EmployeeID =5)
- BSELECT Employees.LastName, Employees.FirstName, Orders.EmployeeID, MAX([Order Details].Quantity) AS Total FROM [Order Details] INNER JOIN Orders ON [Order Details].OrderID = Orders.OrderID INNER JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID GROUP BY Employees.LastName, Employees.FirstName, Orders.EmployeeID HAVING (Orders.EmployeeID =5)
- CSELECT Employees.LastName, Employees.FirstName, Orders.EmployeeID, COUNT([Order Details].Quantity) AS Total FROM [Order Details] INNER JOIN Orders ON [Order Details].OrderID = Orders.OrderID INNER JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID GROUP BY Employees.LastName, Employees.FirstName, Orders.EmployeeID HAVING (Orders.EmployeeID =5)
- DSELECT Employees.LastName, Employees.FirstName, Orders.EmployeeID, AVG([Order Details].Quantity) AS Total FROM [Order Details] INNER JOIN Orders ON [Order Details].OrderID = Orders.OrderID INNER JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID GROUP BY Employees.LastName, Employees.FirstName, Orders.EmployeeID HAVING (Orders.EmployeeID =5)
12Observar el diseño de la base de datos y determinar el código de sql para contar la cantidad de libros para cada editorial.

- Aselect nombre as editorial, count(*) as existencia
from editoriales join libros on editoriales.codigo=libros.codigoeditorial group by nombre; - Bselect nombre as editorial, count(*) as existencia from editoriales join libros
on libros.codigo=editoriales.codigoeditorial group by nombre; - Cselect nombre as editorial, contar(*) as existencia from editoriales join libros on editoriales.codigo=libros.codigoeditorial group by nombre;
- Dselect nombre as editorial, count(*) as existencia from editoriales join libros
on editoriales.codigo=libros.codigoeditorial group by libros;
- Aselect nombre as editorial, count(*) as existencia
13Observar el diseño de la base de datos y determinar el código de sql para eliminar los libros de la editorial ‘Gaceta’

- Adelete libros from libros join editoriales on libros.codigoeditorial = editoriales.codigo where editoriales.nombre='Gaceta';
- Bdelete libros from libros join editoriales on editorials.codigoeditorial = libros.codigo where editoriales.nombre='Gaceta';
- Cdelete editoriales from libros join editoriales on libros.codigoeditorial = editoriales.codigo where editoriales.nombre='Gaceta';
- Ddelete editoriales from libros join editoriales on editoriales.codigoeditorial = libros.codigo where editoriales.nombre='Gaceta';
14Observar el diseño de la base de datos y determinar el código de sql subir el precio en un 20 por ciento al editorial Gaceta como también de la editorial Apares

- Aupdate libros set precio=precio+(precio*0.1) from libros join editoriales on libros.codigoeditorial=editoriales.codigo where nombre='Gaceta' or nombre = 'Apares';
- Bupdate libros set precio=precio+(precio*0.1) from libros join editoriales on libros.codigoeditorial=editoriales.codigo where nombre='Gaceta' and nombre = 'Apares';
- Cupdate libros set precio=precio+(precio*0.1) from libros inner editoriales on libros.codigoeditorial=editoriales.codigo where nombre='Gaceta' or nombre = 'Apares';
- Dupdate editoriales set precio=precio+(precio*0.1) from libros join editoriales on libros.codigoeditorial=editoriales.codigo where nombre='Gaceta' or nombre = 'Apares';
15Determinar el código de sql para crear una clave primaria en una tabla, analize el código de creación de la tabla libroxs.
create table libroxs( codigo int not null, titulo varchar(40), autor varchar(30),
editorial varchar(15) );- Aalter table libroxs add constraint PK_libroxs_codigo primary key(codigo);
- Balter table libroxs sum constraint PK_libroxs_codigo primary key(codigo);
- Calter table libroxs add constraint PK_libroxs_codigo primary (codigo);
- Dalter table libroxs add constraint PK_libroxs_codigo primary key(libroxs);
16Determinar el código de sql para crear una clave foránea de las siguientes tablas, observe el diagrama.

- Aalter table libros add constraint FK_libros_codigoeditorial foreign key (codigoeditorial) references editoriales(codigo);
- Balter table editoriales add constraint FK_libros_codigoeditorial foreign key (codigoeditorial) references libros(codigo);
- Calter column libros add constraint FK_libros_codigoeditorial primary key () references editoriales(codigo);
- Dalter column libros add constraint FK_editorales_codigo foreign key (codigo) references libros(codigoeditorial);
17Del siguiente código en php determinar la línea que falta presentar los elementos del array.
<html>
<head>
<title>Problema</title>
</head>
<body>
<?php
$nombres[]="juan";
$nombres[]="pedro";
$nombres[]="ana";
{
echo $nombres[$f];
echo "<br>";
}
?>- Afor($f=0;$f<count($nombres);$f++)
- Bfor($f=count($nombres);<= 0;$f--)
- Cfor($f=0;$f<count($nombres[]);$f++)
- Dfor($f=0;$f<count($nombres);$f--)
18Del siguiente código en php determinar la línea correcta de conexión de la base de datos.
<html>
<head>
<title>Problema</title>
</head>
<body>
<?php
mysqli_query($conexion,"delete from alumnos") or
die("Problemas en el select:".mysqli_error($conexion));
echo "Se efectuó el borrado de todos los alumnos.";
mysqli_close($conexion);
?>
</body>
</html>- A$conexion=mysqli_connect("localhost","root","","base1") or die("Problemas con la conexión");
- B$conexion=mysqli_connect("root","localhost","","base1") or die("Problemas con la conexión");
- C$conexion=mysqli_connect("localhost","base1","","root") or die("Problemas con la conexión");
- D$conexion=mysqli_connec("localhost","root","","base1") or die("Problemas con la conexión");
Information
- Description
- Quiz on Untitled, created by DANIEL RUBEN RIVAS SALTOS on 29/10/2019.
- Language
- Español
- Views
- 32
- Rating
- No ratings yet Rate this quiz