/    Sign up×
Community /Pin to ProfileBookmark

mysql query question

<?php
$conn = mysql_connect(“localhost”,””,””);
$db = mysql_select_db(“dbzwars”);
$sql = ‘SELECT * FROM users’;
$result = mysql_query($sql);
print $result;
?>

im trying to print all the information in the database
with that it prints
Resource id #2

does anyone have a clue what im doing wrong

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@pyroJun 02.2004 — You'll need to loop through the results. Something like this:

[code=php]<?php
$conn = mysql_connect("localhost","","");
$db = mysql_select_db("dbzwars");
$sql = 'SELECT * FROM users;';
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
echo $row['name'];
}
?>[/code]
Copy linkTweet thisAlerts:
@daveyauthorJun 02.2004 — with that code nothing appears
Copy linkTweet thisAlerts:
@Paul_JrJun 02.2004 — [i]Originally posted by davey [/i]

[B]with that code nothing appears [/B][/QUOTE]

Unless you have a field in your table called &#8220;name&#8221; then no, it will not show anything. You have to subsitute [font=courier]$row["name"][/font] with the names of the fields whose values you wish to display on the page.
×

Success!

Help @davey spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...