Error only on last row

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Stela
Forum Commoner
Posts: 46
Joined: Tue Aug 12, 2008 12:38 pm

Error only on last row

Post by Stela »

Hi…

I'm making a mysql_fetch_array and the results are all OK, the MySQL is all OK, but I receive this error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /htdocs/public/www/Site/PHP/PesquisasEventos.php on line 243

ONLY before the last row!

Can this be a problem on PHP? But if so, why I receive all the rows results OK?

Thanks!
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Error only on last row

Post by Mark Baker »

If it was a bug in PHP itself, I'd have expected other people to have encountered it before now.
What's the code that you're using to loop through the result set?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Error only on last row

Post by aceconcepts »

When you receive a MySQL resource error it's due to an error with your query or query syntax. Double check your query or post more info.
Stela
Forum Commoner
Posts: 46
Joined: Tue Aug 12, 2008 12:38 pm

Re: Error only on last row

Post by Stela »

Weird, the message just stopped to appear.

I have sure that the MySQL was right, I tested it directly on PHPmyAdmin and it gave me the right result.

Here's one of the Querys

if ($searchJuntaFreguesia)
{
$query = mysql_query("SELECT tabClientes.* FROM tabConfirmacoes JOIN tabClientes ON (tabClientes.idCliente = tabConfirmacoes.idCliente) WHERE JuntaFreguesia='$searchJuntaFreguesia' AND tabConfirmacoes.idEvento = '$searchIdEvento' ");
functQuery($query);
}



I'm using this Loop

function functQuery($goQuery)
{
while ($myrow = mysql_fetch_array($goQuery))
{



Thanks for the replies.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Error only on last row

Post by jackpf »

Try putting "or die(mysql_error());" after the query.....
Stela
Forum Commoner
Posts: 46
Joined: Tue Aug 12, 2008 12:38 pm

Re: Error only on last row

Post by Stela »

But the error message doesn't appear now, is it going to make any effect now?

Should "or die…" be put on all querys?
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Error only on last row

Post by aceconcepts »

mysql_error() is an error reporting function that will return any MySQL errors if they exist regarding the query you use it on. During production these error reporting tools should be off unless you want all your users seeing techy messages.
Stela
Forum Commoner
Posts: 46
Joined: Tue Aug 12, 2008 12:38 pm

Re: Error only on last row

Post by Stela »

:lol:

Thanks for the explanation aceconcepts.
Post Reply