A thought - if he's getting the 'not a valid resource' from just the
code he posted, then his problem is with the $connessione variable, and
not the query itself. Check to make sure the connection is up at
all/etc. and *it* is a valid resource. Generally (well, in the simple
case - which is the general case) you only have the one database
connection, and don't need to bother passing it around.
Also, make sure you're using resources in the right places later - many
times people will use the result ($query) as if it contains the rows
returned, instead of being a resource identifier to get the rows.
cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.
Hutchins, Richard wrote:
Marco,
Have you tried echoing out the sql statement to the browser before it gets
sent to the database? That would show you the exact query string and give
you a chance to see where the error might reside.
$sql="select distinct des_riga, count ( des_riga ) as freq from k_riga
where id_tabella=" . $id_tabella . " and id_colonna=" . $id_colonna .
" group by des_riga order by des_riga";
echo $sql //ADD THIS LINE
// COMMENT THIS OUT FOR NOW $query=mysql_query ($sql, $connessione);
Rich
-----Original Message-----
From: Marco Strullato [mailto:marco.strullato@xxxxxxxxx]
Sent: Tuesday, August 09, 2005 9:44 AM
To: php-db@xxxxxxxxxxxxx
Subject: mysql not valid resource
Hi all, I have a problem with mysql:
this code produce a not valid mysq resource.
$sql="select distinct des_riga, count ( des_riga ) as freq from k_riga
where id_tabella=" . $id_tabella . " and id_colonna=" . $id_colonna .
" group by des_riga order by des_riga";
$query=mysql_query ($sql, $connessione);
$id_tabella, $id_colonna and $connessione has the correct value...
The same query runs perfectly if I exec it directly on the db.
Do you have any suggestions?
Marco
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php