Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
Getting data from MySQL - Resource id #3???
Old 06-18-2004, 11:36 AM Getting data from MySQL - Resource id #3???
Unknown.

Posts: 1,693
Trades: 0
Ive tryed using the following code to get data from the MySQL table...

Code:
<?php

$connection=mysql_connect("localhost","USERNAME","PASSWORD"); 
    $db=mysql_select_db("darkWkyr",$connection); 

$check_name = "SELECT Name FROM profiles WHERE id=1";
$users_name = mysql_query($check_name);


echo "Name : $users_name";

?>
But instead of displaying the name which should be 'JAmes' it displays 'Resource id #3'...

Whys this??? I have made an error in the code???

Thanks

-James
Dark-Skys99 is offline
View Public Profile
 
 
Register now for full access!
Old 06-18-2004, 12:08 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Yes, yes you have

When you get the value from mysql_query, what it gives you (as you can see) is a resource ID. You then use this ID for other things. To get actual values from a resource, you've got to use the other mysql functions.

PHP Code:
$conx mysql_connect('localhost''USERNAME''PASSWORD') or die('Error while connecting to db server');
mysql_select_db('darkWkyr'$conx) or die('Error while selecting db');

$result mysql_query("SELECT Name FROM profiles WHERE id=1"$conx);

$users_name mysql_fetch_row($result);
$users_name $users_name[0]; // mysql_fetch_row returns an array. we only want the Name so we just set it excluseively.

echo "Name : $users_name"
See these:
http://ca3.php.net/manual/en/functio...etch-array.php
http://ca3.php.net/manual/en/functio...-fetch-row.php
http://ca3.php.net/manual/en/functio...etch-assoc.php
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
View Public Profile
 
Old 06-18-2004, 02:12 PM
Unknown.

Posts: 1,693
Trades: 0
Thanks

-James
Dark-Skys99 is offline
View Public Profile
 
Closed Thread     « Reply to Getting data from MySQL - Resource id #3???
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.16816 seconds with 12 queries