Reply to Re: Assign mysql record values to gloabl variabel

Your name:

Reply:


Posted by Rik on 07/11/06 13:58

Julian Moorhouse wrote:
> Hi,
>
> I've been struggle with the code below.
> I've tried mysql_fetch_assoc and various other functions, but can't
> seem to get it to work.
> The code works as far as that point though.
>
> global $first_name;
> global $last_name;
> global $password;

If you want to make them of use inside the function, you have to declare
themn global inside the function...

> function get_acct_rec($email){
>
> $conn = db_connect(HOST, USER, PASS, DB, PORT);
>
> $sql = "SELECT * FROM `clients` WHERE `email` = '" . $email . "';";
>
> $c_result = mysql_query($sql, $conn) or die("Failed to execute query
> at line " . __LINE__ . ": " . db_error($conn));

What's the output if you return mysql_num_rows() here? It might be a problem
in the database (such as fieldnames, no matching records etc.).

> while ($row = mysql_fetch_assoc($c_result)) {
> $first_name = $row['first_name'];
> $last_name = $row['last_name'];
> $password = $row['password'];
> echo $row['first_name'];
> }

Seems OK, but won't do a thing besides echoing first_name, see the previous
remark about globals.

Grtz,
--
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

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