By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

show webpage result

P: n/a
I am trying to get a webpage to show its results (a single line) in an image's "alt" tag.

Here's my code:

<img src=medal.gif height=16 width=16 align=absmiddle alt="<? $rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r");echo "$rank";?>">

All I get is "Resource id #2". What am I doing wrong? :/
Jul 17 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
*** Eep² wrote/escribió (Mon, 05 Jul 2004 10:43:46 GMT):
<img src=medal.gif height=16 width=16 align=absmiddle alt="<?
$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r"
);echo "$rank";?>">

All I get is "Resource id #2". What am I doing wrong? :/


http://www.php.net/fopen

Description
resource fopen ( string filename, string mode [, bool use_include_path [,
resource zcontext]])

As you can see, the function returns a resource, not a string. Once you
have the resource, you can use it to access the remote file with fgets():

http://www.php.net/fgets

fgets -- Gets line from file pointer
Description
string fgets ( resource handle [, int length])

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #2

P: n/a
Cool. Thanks. :)

<?
$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep",r);
while (!feof($rank)) {
$rank1 = fgets($rank);
echo $rank1;
}
fclose($rank1);
?>

Now to get rid of the extra line in the tooltip...

Alvaro G Vicario wrote:

*** Eep² wrote/escribió (Mon, 05 Jul 2004 10:43:46 GMT):
<img src=medal.gif height=16 width=16 align=absmiddle alt="<?
$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r"
);echo "$rank";?>">

All I get is "Resource id #2". What am I doing wrong? :/


http://www.php.net/fopen

Description
resource fopen ( string filename, string mode [, bool use_include_path [,
resource zcontext]])

As you can see, the function returns a resource, not a string. Once you
have the resource, you can use it to access the remote file with fgets():

http://www.php.net/fgets

fgets -- Gets line from file pointer
Description
string fgets ( resource handle [, int length])

Jul 17 '05 #3

P: n/a
Eep² wrote:
Cool. Thanks. :)

<?
$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep",r);
while (!feof($rank)) {
$rank1 = fgets($rank);
echo $rank1;
}
fclose($rank1);


You want fread(). Check other file functions as well.

Berislav

--
If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.
Jul 17 '05 #4

P: n/a
Eep² wrote:
I am trying to get a webpage to show its results (a single line) in an image's "alt" tag.

Here's my code:

<img src=medal.gif height=16 width=16 align=absmiddle alt="<?$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r");echo "$rank";?>">

All I get is "Resource id #2". What am I doing wrong? :/


Try file_get_contents()
http://www.php.net/file_get_contents
fopen() returns a file descriptor;

If you want to use fopen()
you have to, eg, fread(); fgets(); fclose();
HTH
Jul 17 '05 #5

P: n/a
file_get_contents() only work with PHP5 though, not all server are migrated
to PHP5, also PHP5 is not marked as stable yet. Not to use on a production
server.

Savut
http://www.savut.com

"X2OO3" <me@privacy.net> wrote in message
news:40*********************@news.telepac.pt...
Eep² wrote:
I am trying to get a webpage to show its results (a single line) in an
image's "alt" tag.

Here's my code:

<img src=medal.gif height=16 width=16 align=absmiddle alt="<?
$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r");echo
"$rank";?>">

All I get is "Resource id #2". What am I doing wrong? :/


Try file_get_contents()
http://www.php.net/file_get_contents
fopen() returns a file descriptor;

If you want to use fopen()
you have to, eg, fread(); fgets(); fclose();
HTH

Jul 17 '05 #6

P: n/a
"Savut" <we***@hotmail.com> wrote in message
news:Us**************@news20.bellglobal.com...
file_get_contents() only work with PHP5 though, not all server are migrated to PHP5, also PHP5 is not marked as stable yet. Not to use on a production
server.


No, it's been available since 4.3.0. You have file_put_contents() in mind I
think.
Jul 17 '05 #7

P: n/a
"Eep²" <no@spam.com> wrote in message news:40***************@spam.com...
I am trying to get a webpage to show its results (a single line) in an image's "alt" tag.
Here's my code:

<img src=medal.gif height=16 width=16 align=absmiddle alt="<? $rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r");e
cho "$rank";?>">
All I get is "Resource id #2". What am I doing wrong? :/


If your intention is to show a tooltip, the attribute you want to set is
"title" not "alt". Only IE shows the alt texts as tooltips.
Jul 17 '05 #8

P: n/a
Huh? I've been using "alt" for YEARS to show image tooltips in ALL web browsers. <shrug>

Anyway, thanks to Alvaro I've got it working now.

Chung Leong wrote:

"Eep²" <no@spam.com> wrote in message news:40***************@spam.com...
I am trying to get a webpage to show its results (a single line) in an

image's "alt" tag.

Here's my code:

<img src=medal.gif height=16 width=16 align=absmiddle alt="<?

$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r");e
cho "$rank";?>">

All I get is "Resource id #2". What am I doing wrong? :/


If your intention is to show a tooltip, the attribute you want to set is
"title" not "alt". Only IE shows the alt texts as tooltips.

Jul 17 '05 #9

P: n/a
Cool; that works, too--and it less code. Thanks. :)

<?
$rank=file_get_contents("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep",r);
echo $rank;
?>

X2OO3 wrote:

Eep² wrote:
I am trying to get a webpage to show its results (a single line) in an image's "alt" tag.

Here's my code:

<img src=medal.gif height=16 width=16 align=absmiddle alt="<? $rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r");echo "$rank";?>">

All I get is "Resource id #2". What am I doing wrong? :/


Try file_get_contents()
http://www.php.net/file_get_contents

fopen() returns a file descriptor;

If you want to use fopen()
you have to, eg, fread(); fgets(); fclose();

Jul 17 '05 #10

P: n/a
I don't think it works in Konquirer or Safari.

"Eep²" <no@spam.com> wrote in message news:40***************@spam.com...
Huh? I've been using "alt" for YEARS to show image tooltips in ALL web browsers. <shrug>
Anyway, thanks to Alvaro I've got it working now.

Chung Leong wrote:

"Eep²" <no@spam.com> wrote in message news:40***************@spam.com...
I am trying to get a webpage to show its results (a single line) in an

image's "alt" tag.

Here's my code:

<img src=medal.gif height=16 width=16 align=absmiddle alt="<?

$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r");e cho "$rank";?>">

All I get is "Resource id #2". What am I doing wrong? :/


If your intention is to show a tooltip, the attribute you want to set is
"title" not "alt". Only IE shows the alt texts as tooltips.

Jul 17 '05 #11

P: n/a
Huh? Never heard of 'em. "alt" is a basic <img> tag option anyway so for those obscure browsers not to support it is just pathetic. <shrug>

Chung Leong wrote:

I don't think it works in Konquirer or Safari.

"Eep²" <no@spam.com> wrote in message news:40***************@spam.com...
Huh? I've been using "alt" for YEARS to show image tooltips in ALL web

browsers. <shrug>

Anyway, thanks to Alvaro I've got it working now.

Chung Leong wrote:

"Eep²" <no@spam.com> wrote in message news:40***************@spam.com...
> I am trying to get a webpage to show its results (a single line) in an
image's "alt" tag.
>
> Here's my code:
>
> <img src=medal.gif height=16 width=16 align=absmiddle alt="<?
$rank=fopen("http://mersenne.org/cgi-bin/primenet_user.pl?UserID=eep","r");e cho "$rank";?>">
>
> All I get is "Resource id #2". What am I doing wrong? :/

If your intention is to show a tooltip, the attribute you want to set is
"title" not "alt". Only IE shows the alt texts as tooltips.

Jul 17 '05 #12

P: n/a
On Mon, 05 Jul 2004 21:35:17 GMT, Eep² <no@spam.com> wrote:
Huh? I've been using "alt" for YEARS to show image tooltips in ALL web
browsers. <shrug>


title is designed to do that. IE uses alt too, but it's nonstandard. Many,
many browsers don't tooltip alt, and that's correct behavior.
Jul 17 '05 #13

P: n/a
*** Eep² wrote/escribió (Wed, 07 Jul 2004 16:28:57 GMT):
Huh? Never heard of 'em. "alt" is a basic <img> tag option anyway so for
those obscure browsers not to support it is just pathetic. <shrug>


ALT is defined by web standards as a way to provide ALTernative
descriptions to images so browsers that won't display them for any reason
(lynx, Google bot, slow connections, screen readers...). All browsers I
know support it. The worst support is probably found in Internet Explorer:
this ALT content that should never be shown if the image is actually
displayed... is shown as an annoying tooltip! So I agree with you: Internet
Explorer is rather pathetic.

Just use TITLE when you need tooltips, all browsers support it (even
Internet Explorer). It's definitively better for many reasons, esp. because
you can make your page accesible without crowing it with unnecessary
tooltips saying things like "Spacer image" or "Company logo".

--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #14

P: n/a
On Thu, 8 Jul 2004 08:42:54 +0200, Alvaro G Vicario
<al******************@telecomputeronline.com> wrote:
*** Eep² wrote/escribió (Wed, 07 Jul 2004 16:28:57 GMT):
Huh? Never heard of 'em. "alt" is a basic <img> tag option anyway so for
those obscure browsers not to support it is just pathetic. <shrug>


ALT is defined by web standards as a way to provide ALTernative
descriptions to images so browsers that won't display them for any reason
(lynx, Google bot, slow connections, screen readers...). All browsers I
know support it. The worst support is probably found in Internet
Explorer:
this ALT content that should never be shown if the image is actually
displayed... is shown as an annoying tooltip! So I agree with you:
Internet
Explorer is rather pathetic.

Just use TITLE when you need tooltips, all browsers support it (even
Internet Explorer). It's definitively better for many reasons, esp.
because
you can make your page accesible without crowing it with unnecessary
tooltips saying things like "Spacer image" or "Company logo".


Why would that make sensible alt text to begin with? alt text replaces the
image, it doesn't describe it.
Jul 17 '05 #15

P: n/a

"Neal" <ne*****@yahoo.com> wrote in message
news:op**************@news.individual.net...
On Thu, 8 Jul 2004 08:42:54 +0200, Alvaro G Vicario
<al******************@telecomputeronline.com> wrote:
*** Eep² wrote/escribió (Wed, 07 Jul 2004 16:28:57 GMT):
Huh? Never heard of 'em. "alt" is a basic <img> tag option anyway so for those obscure browsers not to support it is just pathetic. <shrug>


ALT is defined by web standards as a way to provide ALTernative
descriptions to images so browsers that won't display them for any reason (lynx, Google bot, slow connections, screen readers...). All browsers I
know support it. The worst support is probably found in Internet
Explorer:
this ALT content that should never be shown if the image is actually
displayed... is shown as an annoying tooltip! So I agree with you:
Internet
Explorer is rather pathetic.

Just use TITLE when you need tooltips, all browsers support it (even
Internet Explorer). It's definitively better for many reasons, esp.
because
you can make your page accesible without crowing it with unnecessary
tooltips saying things like "Spacer image" or "Company logo".


Why would that make sensible alt text to begin with? alt text replaces the
image, it doesn't describe it.


With Internet Explorer although an image may be displayed, if you hover the
cursor over it the ALT text is displayed as a tooltip. So you get both the
image and the text at the same time.

--
Tony Marston

http://www.tonymarston.net

Jul 17 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.