|
Posted by Satyam on 10/07/05 11:14
I rarely use the @ sign. It is what I call 'balistic programming'. You
know, a shell, once it leaves the cannon, is not controlled in any way, you
just hope it will get where you want to go.
Instead you should check for errors and recover from them as gracefully as
possible..
You will see in a lot of examples in the PHP manual that most database
operations are followed by the following code segment:
..... SQL operation .... or die('your own text to help you locate the
error' . mysql_error());
This will help you locate and know which is the error.
In your case, the mysql_query function has had an error and has returned
FALSE instead of a resource handle. FALSE, being an invalid argument to
Fetch. The error is not really where it pops, but has happened before,
either at the Query or even before, when you openned the database. Either
of those statements followed by propper error detection would tell you all
you need to know to fix it.
But don't just ignore the error, the @ sign should be used sparingly, if at
all.
Satyam
"Drewcore" <drewsph@gmail.com> wrote in message
news:1facbc1c05042500471c808295@mail.gmail.com...
just put a @ symbol before the function calll, eg
while ($myrow = @mysql_fetch_row($result)) {
etc
On 4/25/05, Mark Sargent <powderkeg@snow.email.ne.jp> wrote:
> Hi All,
>
> get the following error when calling data from mysql,
>
> *Warning*: mysql_fetch_row(): supplied argument is not a valid MySQL
> result resource in */var/www/html/phpmysqltable.php* on line *36
> *
> Below are snippets of my code,
>
> Line 22: $result = mysql_query("SELECT product_name,
> product_model_number, product_serial_number FROM Products",$db);
> Line 36: while ($myrow = mysql_fetch_row($result)) {
> printf("<tr><td>%s %s</td><td>%s</td><td>%s
> %</td></tr>\n",
> $myrow[1], $myrow[2], $myrow[3]);
>
> I'm following a webmonkey.com tut for php/mysql.
> http://webmonkey.wired.com/webmonkey/99/21/index3a.html
> Cheers.
>
> Mark Sargent.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
dc .. drewcore.com
[Back to original message]
|