Reply to Re: Little script error

Your name:

Reply:


Posted by brian.swan on 03/04/07 18:16

On Mar 4, 11:43 am, "Mikro" <i...@elektroonika.com> wrote:
> Hi!
>
> My problem is at the end of script. When "if (!empty($bensiin_2["id"]))" is
> emtpty (id doesn't exist) then else doesn't echo. Maybe the problem is in
> html code?
>
> {
> $peavik=("SELECT * FROM soidup_info order by id");
> $paevik = mysql_query($peavik);
> while($paevik_2 = mysql_fetch_array($paevik))
> {echo"
> <table border=1 width=100% >
> <tr>
> <td width=81>"; ?><A
> onclick="window.open('xxx.php?raha=<? echo $paevik_2["id"];
> ?>','','width=480,height=190,scrollbars=no')"
> href="javascript:;"><span class=link><? echo" ".date("d-m-Y",
> strtotime($paevik_2["kuup"]))." ";?></span></td>
> <? echo"
> <td width=250>".$paevik_2["marsruut"]."</td>
> <td width=200>".$paevik_2["pohjus"]."</td>
> <td width=153>".$paevik_2["juht"]."</td>
> <td width=80 align=center>".$paevik_2["alg"]."</td>
> <td width=80 align=center>".$paevik_2["lopp"]."</td>";
>
> $bents=("SELECT * FROM soidup_bensiin where u_id=".$paevik_2["id"]."");
> $bensiin = mysql_query($bents);
> while($bensiin_2 = mysql_fetch_array($bensiin)) {
> if (!empty($bensiin_2["id"]))
> {
> echo"<td align=center>".$bensiin_2["kogus"]."L</td></tr>"; }
> else {echo" <td align=center>pole midagi</td> </tr>"; }
>
> }
>
> }
> }

Try doing a print_r( $bensiin_2 );. That should output everything in
the current array. Also, you are not checking for the number of rows
or any errors being returned by MySQL. This is a large boo-boo. It
could be that no rows are returned at all so the condition would never
get reached.

Hope this helps,
Brian Swan
http://www.usedboatyard.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация