Reply to Re: newbie help with mysql_fetch_array

Your name:

Reply:


Posted by Rik Wasmus on 01/14/08 18:31

On Mon, 14 Jan 2008 19:22:04 +0100, <sixstringsin@yahoo.co.in> wrote:

> ##in the mysql query below, i am selecting a few fields from the masks=

> table:-
>
> $mask_query =3D "SELECT mask_id, mask_name, mask_dynamic FROM masks
> where mask_project =3D $project_id AND mask_parent =3D $phase_id";
>
> ##next i am storing the return value to a variable (on executing the
> script, I donot get any mysql error so i assume the query ran fine:-
>
> $mask_res =3D mysql_query($mask_query) or die("can't run query
> [$mask_query]: ".mysql_error());
>
> ##now i intend to print the field called mask_name on the browser:-
>
> $tc_array =3D mysql_fetch_array($mask_res, MYSQL_ASSOC);
> $tc_name =3D $tc_array["mask_name"];
> print "mask Name:".$tc_array['mask_name'] . " ";
>
>
> ##However, what is printed is the string mask Name, followed by a
> blank. The mask_name field from the db is ##not retrieved. Where am i
> going wrong? Appreciate any help!

var_dump() & print_r() are your friends when determining what a variable=
=

actually holds. Maybe there's no matching rows (check with =

mysql_num_rows()), or mask_name is indeed blank, maybe even something =

else (mask name =3D '<p>' for instance wouldn't show up in a browser giv=
en =

content-type text/html, as it would assume this to be an HTML tag).
-- =

Rik Wasmus

[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

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