Fatal error: Uncaught exception 'PDOException'

Gae58

Utente Attivo
26 Mar 2012
84
0
0
salve,

mi trovo in difficoltà, ho creato delle pagine in php e localmente con PHPMyAdmin mi funziona tutto bene.
Posto il tutto sul sito, server Linux e solo per alcune pagine mi ritornano errori che non mi fanno proseguire, lo stesso quando effettuo la ricerca, non trova il dato anche se presente.
Inizialmente pensavo dipendesse dall'uso del PDO, in quanto togliendolo da una funzione mi ritorna il dato, però se fosse vero, dovrebbe ritornarmi l'errore in tutte le pagine, ma ciò non succede.

Qualche consiglio?

grazie

gaetano
 

Gae58

Utente Attivo
26 Mar 2012
84
0
0
Quando apro la pagina l'errore è questo:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2053 '
Da tene presente che le pagine sono tutte uguali come codice

L'errore è sul richiamo della seconda riga (uso il PDO)
$cQry = cQuery( $Conn, $cSql, $aPara );
while ($Campo = $cQry->fetch()) {

Le versioni di PHP e di MySql sono diverse
 

Gae58

Utente Attivo
26 Mar 2012
84
0
0
Ho riscritto una parte della pagina ed adesso funziona tutto bene,

Però rimane il problema sul ritorno del valore da una funzione:

Dalla pagina richiamo una funzione per sapere da quante righe totali è composta la tabella (per poter calcolare il N° di pagine)
$RigheTo = RigheTo( 'AssegnazioniTipo');

questa la funzione:
Function RigheTo( $Tab ) {
$nRet = 0;
$cSql = "SELECT * FROM ".$Tab;
$Conn = Connetti( $PDO );
$cQry = null;
$cQry = cQuery( $Conn, $cSql, $aPara );
$nRet = $cQry->rowCount();
Disconnetti( $PDO, $Conn );
return $nRet;
}

$nRet mi dovrebbe restituire il numero delle righe, ma mi ritorna zero senza indicarmi l'errore.
Il cQuery richiama l'execute

grazie
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
due cose:
1. quando scrivi del codice usa i tag adeguati (formattiazione post, II° riga, ultime tre iconcine, nell'ordine CODE HTML PHP)
2. da dove salta fuori la variabile $aPara? cioè dove la valorizzi?
 

Gae58

Utente Attivo
26 Mar 2012
84
0
0
scusami hai ragione è la seconda volta che mi capita.

$aPara è l'array che valorizzo quando devo passare i dati per l'INS o la Variazione

In questo caso con la select la setto a null ad inizio pagina.

Mi hai fatto sorgere un dubbio quando in una pagina web uso il require per il caricamente della pagina, legge le var ad inizio pagina o serve solo per richiamare le func che ho all'interno?

Però non mi ritorna nemmeno il warning per indicarmi che $aPara non é stata dichiarata
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
non me ne intendo molto di pdo, però tu scrivi una function (la effe minuscola !!) ora le variabili estrerne alla function non sono conosciute al suo interno e viceversa (tranne che non siano globali)
es
PHP:
<?php
function somma($a){
	$somma=$a+$b;
}
$b=9999;
echo somma(5);//output 5 se non errore di variabile indefinita alla riga 3
echo $somma; //output NULL
?>
 

Gae58

Utente Attivo
26 Mar 2012
84
0
0
scusami con return non mi dovrebbe riportare il valore di :
PHP:
$nRet = $cQry->rowCount();
é
PHP:
$cQry->rowCount()
che non riconosce

se invece uso:
PHP:
$dB = DbScelta( 'dgt', $Conn );
$cQry =  mysql_query( $cSql );
$nRet = mysql_num_rows($cQry);

mi ritorna il valore giusto

è qui che non capisco
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
ribadisco, secondo me l'errore non è in $nRet = $cQry->rowCount(); ma allariga
$cQry = cQuery( $Conn, $cSql, $aPara ); in cui la variabile $aPara non è definita
prova a mettere

PHP:
<?php
function RigheTo( $Tab ) {
	$nRet = 0;
	$cSql = "SELECT * FROM ".$Tab;
	$Conn = Connetti( $PDO );
	$cQry = null;
	var_dump($aPara);
	$cQry = cQuery( $Conn, $cSql, $aPara );
	$nRet = $cQry->rowCount();
	Disconnetti( $PDO, $Conn );
	return $nRet;
}
?>
e posta cosa riporta (secondo me NULL), del resto se usi l'altro sistema (done non utilizzi qualla variabile) funziona

p.s.
ricordati di racchiudere il codice negli appaositi tag, si legge meglio
 

Gae58

Utente Attivo
26 Mar 2012
84
0
0
si hai ragione, na dev'essere null in quanto parametri non ne passo.

Mi sa che devo calcolare il numero delle righe senza PDO.

Però questo è un problema in quanto devo cambiare molte righe di codice perchè nell'importazione faccio la ricerca del dato col PDO

QUalche altro suggerimento?

grazie

Gaetano
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao
non so potresti provare così se puoi
PHP:
<?php
function RigheTo( $Tab,  $aPara) {
	$nRet = 0;
	$cSql = "SELECT * FROM ".$Tab;
	$Conn = Connetti( $PDO );
	$cQry = null;
	$cQry = cQuery( $Conn, $cSql, $aPara );
	$nRet = $cQry->rowCount();
	Disconnetti( $PDO, $Conn );
	return $nRet;
}
?>
oppure visto che la function ti serve solo per avere il numero di record

PHP:
<?php
function RigheTo( $Tab) {

	$cSql = mysql_query("SELECT * FROM ".$Ta;

	return mysql_num_rows($cSql);
}
?>
poi dopo puoi usare le pdo
 
Discussioni simili
Autore Titolo Forum Risposte Data
T [PHP] aiuto....Fatal error: Uncaught Error:non riesco a capire PHP 1
G Fatal error: Uncaught Error: Call to undefined method UserController PHP 0
U Campo vuoto data errore Fatal error: PHP 2
I Fatal error: Query Failed! SQL: SELECT * INTO OUTFILE PHP 1
L [PHP] Fatal error: Call to a member function prepare() on null in PHP 0
D [PHP] Fatal error: Class 'COM' not found in C:\..... PHP 6
C [PHP] Errore "Fatal error: Call to undefined function getTotalUsers()" PHP 2
J [PHP] Recoverable fatal error: PHP 4
J [PHP] fatal error PHP 1
C PHP errore Fatal Error: Allowed Memory Size of ... Bytes Exhausted PHP 7
U [PHP] Fatal error: Call to a member function Query() PHP 1
Antoyosh Fatal error con Wordpress WordPress 5
O Fatal error: Call to undefined function testNome() in C:\xampp\...\...\index.php on line 51 PHP 4
JackIlPazzo Fatal error: Call to a member function execute() on a non-object PHP 2
filippino Fatal error: Cannot redeclare (function) PHP 2
JackIlPazzo PHP: Fatal error: Call to a member function bind_param() on a non-object PHP 0
P Fatal error: Call to undefined method SMTP::setTimeout() PHP 4
C errore su wordpress _ fatal error PHP 1
S [RISOLTO] Fatal error in Upload Multiplo di immagini PHP 2
M fatal error: Call to undefined function gdrcd_filter() PHP 6
F Fatal error: t3import not found object Joomla 0
Mauro Guardiani Fatal error HTML e CSS 2
T Fatal error: Call to a member function show_crom() on a non-object PHP 1
T Fatal error: Cannot access empty property PHP 2
F Fatal error: Call to undefined function PHP 9
L Fatal error: Call to undefined method Paging::listaPagine() PHP 2
LaKanka Fatal error upload immagini PHP 19
L Fatal error: Call to undefined function virtual() in C:\Inetpub\wwwroot\... PHP 1
S 404 Error " Page not Find" Error SEO e Posizionamento 0
L Error Code: 1215. Cannot add foreign key constraint MySQL 3
M HTTP Status 500 - Internal Server Error. Java 0
A Uncaught Error: jQuery 1
F Uncaught (in promise) Error: 3000ms timeout exceeded Javascript 0
W ADODB.Recordset error '800a0bb9' Classic ASP 2
D error text in table HTML e CSS 11
W Microsoft OLE DB Provider for Visual FoxPro error '80040e14' Function name is missing ). Classic ASP 0
W Parse error: syntax error, unexpected '$result' (T_VARIABLE) PHP 4
W Errore di run-time di Microsoft VBScript error '800a0035' Impossibile trovare il file Classic ASP 0
G Upload file error Apache 0
A Server Apache immagine not found (ERROR 404) Apache 5
T MySQL ERROR 1064 MySQL 1
T [PHP] ...Parse error che non c'è... PHP 7
V [MySQL] You have an error in your SQL syntax MySQL 1
G PHPMailer: SMTP error Gmail PHP 8
G [WordPress] [PHP] Parse error: syntax error, unexpected '$x332cbce1' WordPress 2
I [PHP] Login Facebook SDK returned an error: No URL set! PHP 0
bubino8 [PHP] Query syntax error PHP 6
momeraths [WordPress] cURL error: problema aggiornamento/installazione plugin WordPress 4
A [PHP] FPDF error: Some data has already been output, can't send PDF file PHP 5
otto9due Error anomalo durante invio dati $.ajax Ajax 20

Discussioni simili