Resource id #2

When i try to view the data from a mysql database using php, then the only thing that is in my browser is:
Resource id #2

I've got this php script:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">


Title here!


<?php
mysql_connect("localhost","root","");
mysql_select_db("php");
$query = "select * from users";
$result = mysql_query($query);
print("$result");

?>



Comments

  • the $result is a datastructure that holds the data. it won't print a table. you have to look inside the result to see the data. to do this, you can pull a row from the table out at a time in an array form.

    echo "";
    while($my_row = mysql_fetch_array($result)){
    echo "";
    for($i<0; $i<count($my_row);$i++){
    echo "<td>" . $myrow[$i] . "";
    }
    echo "";
    }
    echo "
    ";

    : When i try to view the data from a mysql database using php, then the only thing that is in my browser is:
    : Resource id #2
    :
    : I've got this php script:
    : <!doctype html public "-//W3C//DTD HTML 4.0 //EN">
    :
    :
    : Title here!
    :
    :
    : <?php
    : mysql_connect("localhost","root","");
    : mysql_select_db("php");
    : $query = "select * from users";
    : $result = mysql_query($query);
    : print("$result");
    :
    : ?>
    :
    :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion