Código HTML:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Les dejo los codigos de las 3 páginas involucradas, aunque yo creo que quizas el del problema es el index. pero ahí van.
index_mat.php
Código PHP:
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "../login_docente.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<link href="../css/estilo.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include("../includes/menu_docente.php"); ?>
</body>
</html>
Código PHP:
<head>
<link href="../css/estilo.css" rel="stylesheet" type="text/css" />
</head>
<div id="contenedor">
<?php
$conn = mysql_connect("localhost","usuario","contraseña");
mysql_select_db("basededatos");
$archivo = $_FILES["archivito"]["tmp_name"];
$tamanio = $_FILES["archivito"]["size"];
$tipo = $_FILES["archivito"]["type"];
$nombre = $_FILES["archivito"]["name"];
$titulo = $_POST["titulo"];
if ( $archivo != "none" )
{
$fp = fopen($archivo, "rb");
$contenido = fread($fp, $tamanio);
$contenido = addslashes($contenido);
fclose($fp);
$qry = "INSERT INTO archivos_mat VALUES (0,'$nombre','$titulo','$contenido','$tipo')";
mysql_query($qry) or die("Error: ".mysql_error());
?>
<?php
if(mysql_affected_rows($conn) > 0){
print "Se ha guardado el archivo en la base de datos.</br>
<a href='index_mat.php'>Volver</a>";
}else
print "NO se ha podido guardar el archivo en la base de datos.";
}
else
print "No se ha podido subir el archivo al servidor";
?>
</div>
Código PHP:
<?php require_once('../Connections/uploadfiles.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;
}
}
if ((isset($_GET['idElim'])) && ($_GET['idElim'] != "")) {
$deleteSQL = sprintf("DELETE FROM archivos_mat WHERE id=%s",
GetSQLValueString($_GET['idElim'], "int"));
mysql_select_db($database_uploadfiles, $uploadfiles);
$Result1 = mysql_query($deleteSQL, $uploadfiles) or die(mysql_error());
}
mysql_select_db($database_uploadfiles, $uploadfiles);
$query_consulta_todo = "SELECT id, nombre, titulo, tipo FROM archivos_mat ORDER BY id ASC";
$consulta_todo = mysql_query($query_consulta_todo, $uploadfiles) or die(mysql_error());
$row_consulta_todo = mysql_fetch_assoc($consulta_todo);
$totalRows_consulta_todo = mysql_num_rows($consulta_todo);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<link href="../css/estilo.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function verifica(){
var ver = confirm('¿Desea Eliminar?');
if(ver){
return true;
}else{
return false;
}
}
</script>
</head>
<body>
<div id="contenedor">
<a href="index_mat.php">Volver Atrás</a>
<table border="1" cellpadding="0" cellspacing="0" class="tb_archi" align="center">
<tr>
<td>Nombre de archivo</td>
<td>Descripción</td>
<td> </td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_consulta_todo['nombre']; ?></td>
<td><?php echo $row_consulta_todo['titulo']; ?></td>
<td><a onclick="return verifica()"href="listar_archivos_admin.php?idElim=<?php echo $row_consulta_todo['id']; ?>">Eliminar</a></td>
</tr>
<?php } while ($row_consulta_todo = mysql_fetch_assoc($consulta_todo)); ?>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($consulta_todo);
?>