Sto adattando uno script di freephp e ho un file php con due funzioni così
function reg_register($data){
//registro l'utente
global $_CONFIG;
if (reg_utente_esistente($data['user'],$data['password'])== UTENTE_NUOVO){
$id = reg_get_unique_id();
mysql_query("INSERT INTO ".$_CONFIG['table_utenti']."(Nome, Cognome, indirizzo, email, User, pwd, temp, regdate, uid) VALUES ('".$data['name']."','".$data['surname']."','".$data['indirizzo']."','".$data['email']."','".$data['username']."','".$data['password']."','1', '".time()."','".$id."')");
//Decommentate la riga seguente per testare lo script in locale
//echo "<a href=\"http://localhost/Articoli/autenticazione/2/scripts/confirm.php?id=".$id."\">Conferma</a>";
if(mysql_insert_id()){
return REG_SUCCESS;
return reg_send_confirmation_mail($data['mail'], $_CONFIG["mail"], $id);
}else return REG_FAILED;
} else return UTENTE_ESISTENTE;
}
function reg_utente_esistente($user,$pwd) {
global $_CONFIG;
$result=mysql_query("SELECT * FROM ".$_CONFIG['table_utenti']."WHERE User='".$user."' AND Pwd='".$pwd."'");
echo (mysql_num_rows($result));
return "";
}
Il file include un config.inc in cui c'è
<?php
$_CONFIG['host'] = "localhost";
$_CONFIG['user'] = "root";
$_CONFIG['pass'] = "bianca";
$_CONFIG['dbname'] = "db"
$_CONFIG['table_utenti'] = "PI_UTENTI";
$_CONFIG['table_sessioni'] = "PI_SESSIONI";
$_CONFIG['expire'] = 60;
$_CONFIG['URL_ROOT']="http://www.tuosito.com"; //terminare con lo slash
$_CONFIG['mail']="noreply@pippo.net"; //indirizzo e-mail che risulta mittente della mail di richiesta di conferma
######################################
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('USER_ESISTENTE',false);
define('USER_NUOVO',true);
##########################################
$conn = mysql_connect($_CONFIG['host'], $_CONFIG['user'], $_CONFIG['pass']) or die('Impossibile stabilire una connessione');
mysql_select_db($_CONFIG['dbname']);
?>
Quando provo a lanciare mi da errore nella riga del prino file alla riga n cui c'è
echo (mysql_num_rows($result));
dicendo
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/vhost/portaleitalia/include/reg.lib.php on line 20
Ma che cos'è sbagliato? Ho provato di tutto ma non capisco...![]()