Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shouldn't this work?

Status
Not open for further replies.

zinja

MIS
Nov 14, 2002
149
US
I am trying to get a value from a table and am using the following query. The company_name is a string (varchar). What am I doing wrong?

Code:
$companyname = mysql_query ("SELECT company_name FROM pmr_users WHERE login = '" . $loginid . "'" );

LJ Wilson

My personal saying - Just remember, it can always get worse, and usually will.
 
mysql_query() does not return a value. It returns a handle to the resultset containing the value. This handle is similar to the filesystem handle fopen() returns in that you need additional functions to access the data through the handle.

You'll need one of the mysql_fetch_*() functions. Look at the example code here:



Want the best answers? Ask the best questions! TANSTAAFL!
 
mysql_query returns a resource handle.

to get the result you then need to do something like

Code:
$row = mysql_fetch_assoc($result);
print_r ($row);

read up on the mysql functions in the excellent online php manual
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top