Grazie luke ^^ risolto, ora il problema è un altro, se clicco sul prodotto e quindi mi porta alla pagina prodotto_macchine.php?action=prodotto&id=1 mi da il seguente errore:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
questa è la pagina prodotto_macchine.php:
Codice PHP:
<?php
include_once("include/configp.php");
?>
<html>
<head>
</head>
<body>
<?php
if(isset($_GET['id'])){
// recupero dalla querystring l'ID dell'immagine da visualizzare
$id_vis = $_GET['id'];
// verifico la presenza dell'immagine sul DB
$query = "SELECT * FROM macchine WHERE Id = '$id_vis'";
$res = @mysql_query($query) or die (mysql_error());
$n_img = @mysql_num_rows($res);
// se l'id specificato esiste procedo con la visualizzazione
if($n_img == 1 )
{
// recupero i dati dell'immagine selezionata
$f = mysql_fetch_array($res) or die (mysql_error());
$id = $f['id'];
$nome = stripslashes($f['nome']);
$figura = stripslashes($f['foto']);
$allegato1 = stripslashes($f['allegato']);
$descrizione = stripslashes($f['descrizione']);
// stampo a video l'imagine e le relative informazioni
echo $nome . "
";
echo "<img src=\"" .$macchine.$figura. "\" border=\"0\">";
echo "
" . $descrizione . "
";
echo "<a href=\"".$macchine.$allegato1."\">download allegato1</a>
";
}
}
?>
Il problema secondo me è lo script per il login che va in conflitto con questo dei prodotti.
Allora questa è la pagina completa:
Codice PHP:
<?php
include_once("include/config.php");
include_once("include/auth.lib.php");
include_once("include/configp.php");
list($status, $user) = auth_get_status();
if($status == AUTH_LOGGED & auth_get_option("TRANSICTION METHOD") == AUTH_USE_LINK){
$link = "?uid=".$_GET['uid'];
}else $link = '';
?>
<html>
<head>
<title>Pagina tre</title>
</head>
<body>
<div> <?php
switch($status){
case AUTH_LOGGED:
?>
[b]Sei loggato con il nome di <?=$user["name"];?> [url="logout.php<?=$link?>"]Logout[/url][/b]
<?php
break;
case AUTH_NOT_LOGGED:
?>
<form action="login.php<?=$link?>" method="post">
<table cellspacing="2">
<tr>
<td>Nome Utente:</td>
<td><input type="text" name="uname"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="passw"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="action" value="login"></td>
</tr>
</table>
</form>
<?php
break;
}
?></div>
<?php
// recupero i dati dal DB
$query = "SELECT * FROM macchine ORDER By Id";
$res = mysql_query($query) or die (mysql_error());
// numero delle immagini presenti nel DB
$n_img = mysql_num_rows($res);
while ($f=@mysql_fetch_array($res)){
$id = $f['id'];
$nome = stripslashes($f['nome']);
$descrizione = stripslashes($f['descrizione']);
?>
<div>
Contenuto visibile a tutti:
<?php
//stampiamo
echo "<a href=\"?action=prodotto&id=".$id."\">";
echo $nome . "</br>" ;
echo "</a>" ;
}
@mysql_close($cn);
?>
</div>
<div>
<?php
$action = isset($_GET["action"]) ? $_GET["action"] : null;
switch ($action) {
case "prodotto": $inc = "prodotto_macchine.php";
break;
default: $inc = 'default.php';
break;
}
include ($inc);
@mysql_close($cn);
?>
File config per il login:
Codice PHP:
<?php
error_reporting(E_ALL);
$_CONFIG['host'] = "62.149.150.145";
$_CONFIG['user'] = "Sql517192";
$_CONFIG['pass'] = "3bc0e7ce";
$_CONFIG['dbname'] = "Sql517192_2";
$_CONFIG['table_sessioni'] = "sessioni";
$_CONFIG['table_utenti'] = "utenti";
$_CONFIG['expire'] = 60;
$_CONFIG['regexpire'] = 24; //in ore
$_CONFIG['check_table'] = array(
"username" => "check_username",
"password" => "check_global",
"name" => "check_global",
"surname" => "check_global",
"indirizzo" => "check_global",
"occupazione" => "check_global",
"mail" => "check_global"
);
function check_username($value){
global $_CONFIG;
$value = trim($value);
if($value == "")
return "Il campo non può essere lasciato vuoto";
$query = mysql_query("
SELECT id
FROM ".$_CONFIG['table_utenti']."
WHERE username='".$value."'");
if(mysql_num_rows($query) != 0)
return "Nome utente già utilizzato";
return true;
}
function check_global($value){
global $_CONFIG;
$value = trim($value);
if($value == "")
return "Il campo non può essere lasciato vuoto";
return true;
}
//--------------
define('AUTH_LOGGED', 99);
define('AUTH_NOT_LOGGED', 100);
define('AUTH_USE_COOKIE', 101);
define('AUTH_USE_LINK', 103);
define('AUTH_INVALID_PARAMS', 104);
define('AUTH_LOGEDD_IN', 105);
define('AUTH_FAILED', 106);
define('REG_ERRORS', 107);
define('REG_SUCCESS', 108);
define('REG_FAILED', 109);
$conn = mysql_connect($_CONFIG['host'], $_CONFIG['user'], $_CONFIG['pass']) or die('Impossibile stabilire una connessione');
mysql_select_db($_CONFIG['dbname']);
?>
e file configp dei prodotti:
Codice PHP:
<?php
// Connessione al DB
$host = '62.149.150.145';
$user = 'Sql517192';
$pass = '3bc0e7ce';
$data = 'Sql517192_2';
$cn = @mysql_connect($host,$user,$pass) or die (mysql_error());
$sl = @mysql_select_db($data) or die (mysql_error());
$macchine = 'macchine/';
?>
Le tabelle sono sullo stesso database, come mai mi da questo errore?