--- java4ll_cs <[EMAIL PROTECTED]> wrote:
> i have two servers,database server and web server, both are appach
> server i try to connet to db by php
>
> <?
>
> $db=mysql_connect("db server ip");
As seen on http://us2.php.net/mysql_connect the mysql_connect() function
typically also has a
MySQL user name and corresponding password. If no user name is specified, the
assumed user name
is the same as the webserver user ("apache" or "nobody" are two common
examples).
> $name="dbname";
> mysql_select_db($name , $db);
If you have only one database connection, the second argument is not necessary.
> $query=" select username from login where password ='sql'";
> $result=mysql_query($query);
> echo "<p>user name ".$result."</p>";
>
> ?>
>
> this is output
>
> username Resource id #3
>
> what is this???
The "$result" is just a location in memory where the results of the query are
stored. You will
have to use one of the mysql_fetch*() functions to retrieve the data.
if ($data = mysql_fetch_assoc($result))
{
extract($data);
echo "user = $user"; // or whatever your field name is called
}
James
_____
James D. Keeline
http://www.Keeline.com http://www.Keeline.com/articles
http://Stratemeyer.org http://www.Keeline.com/TSCollection
http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Spring Semester January-June 2006. Two new class topics.
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/