php-windows Digest 6 Jun 2002 08:31:41 -0000 Issue 1178

Topics (messages 14093 through 14102):

Retrieving data from a URL in PHP
        14093 by: Anthony Ritter
        14094 by: Scott Hurring
        14095 by: Scott Hurring

Re: CSV. Parsing a defined row?
        14096 by: Shrock, Court

Extension naming problems...
        14097 by: Michael Davey

Re: newbie problem with quotes
        14098 by: Steve Yates

Re: notice:undefined variable
        14099 by: Steve Yates

Postnuke, PHP and Windows ISA servers
        14100 by: Mike

Re: [PHP] PHP version 4.2 and above
        14101 by: Opere, James

?eregi?
        14102 by: Nikolai Jeliazkov

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
The code that follows is from Welling and Thomson's book on PHP and mysql
(page 372)

I've tried it on Apache/ MS Windows 98 / PHP and I get the following line:

"No quote available."

My questions...

1. Why can't I retrieve the present stock quote?

and

2. What does the variable

$quote

represent in the script?

I cannot find what the variable -or array - $quote has been assigned to.
Please see:

echo $quote[1];

below

Thanking all in advance.
Tony Ritter
......................................................................


<html>
<head>
<title>Stock Quote from NYSE</title>
</head>
<body>
<?
$symbol="IBM";
echo "<h1>Stock Quote for $symbol</h1>";
$theurl="http://finance.yahoo.com/q?s=ibm&d=v1";;
if (!($fp=fopen($theurl, "r")))
 {
  echo "Could not open the URL";
  exit;
 }
$contents= fread($fp, 1000000);
fclose($fp);
$pattern="(\\\$[0-9]+\\.[0-9]+)";
if (eregi($pattern,$contents,$quote))
 {
  echo "$symbol was sold at:  ";
  echo $quote[1];
 }
else
 {
  echo "No quote available.";
 }
echo "<br>"."This information retrieved from<br>"."<a
href=\"$theurl\">$theurl</a><br>"."on ".(date("l jS F Y g:i a T"));
?>
</body>
</html>






--- End Message ---
--- Begin Message ---
You get that message when it doesn't match the
pattern  "(\\\$[0-9]+\\.[0-9]+)" in the returned
data.

$quote is set by eregi(); 

All this stuff is in the php documentation:
http://php.net/eregi

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -----Original Message-----
> From: Anthony Ritter [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 4:53 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Retrieving data from a URL in PHP
> 
> 
> The code that follows is from Welling and Thomson's book on 
> PHP and mysql
> (page 372)
> 
> I've tried it on Apache/ MS Windows 98 / PHP and I get the 
> following line:
> 
> "No quote available."
> 
> My questions...
> 
> 1. Why can't I retrieve the present stock quote?
> 
> and
> 
> 2. What does the variable
> 
> $quote
> 
> represent in the script?
> 
> I cannot find what the variable -or array - $quote has been 
> assigned to.
> Please see:
> 
> echo $quote[1];
> 
> below
> 
> Thanking all in advance.
> Tony Ritter
> ......................................................................
> 
> 
> <html>
> <head>
> <title>Stock Quote from NYSE</title>
> </head>
> <body>
> <?
> $symbol="IBM";
> echo "<h1>Stock Quote for $symbol</h1>";
> $theurl="http://finance.yahoo.com/q?s=ibm&d=v1";;
> if (!($fp=fopen($theurl, "r")))
>  {
>   echo "Could not open the URL";
>   exit;
>  }
> $contents= fread($fp, 1000000);
> fclose($fp);
> $pattern="(\\\$[0-9]+\\.[0-9]+)";
> if (eregi($pattern,$contents,$quote))
>  {
>   echo "$symbol was sold at:  ";
>   echo $quote[1];
>  }
> else
>  {
>   echo "No quote available.";
>  }
> echo "<br>"."This information retrieved from<br>"."<a
> href=\"$theurl\">$theurl</a><br>"."on ".(date("l jS F Y g:i a T"));
> ?>
> </body>
> </html>
> 
> 
> 
> 
> 
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message ---
To illustrate what's wrong with the code from the book,
this code works: 


$symbol="ibm";
echo "<h1>Stock Quote for $symbol</h1>\n";
$theurl="http://finance.yahoo.com/q?s={$symbol}&d=v1";;
if (!($fp=fopen($theurl, "r")))
 {
  echo "Could not open the URL";
  exit;
 }
$contents= fread($fp, 1000000);
fclose($fp);

if (preg_match("/(<b>[0-9]+\.[0-9]+<\/b>)/",$contents, $quote))
 {
  echo "$symbol was sold at:  ";
  echo $quote[1];
 }
else
 {
  echo "No quote available.";
 }

echo "<br>"."This information retrieved from<br>"."<a
href=\"$theurl\">$theurl</a><br>"."on ".(date("l jS F Y g:i a T"));


---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

> -----Original Message-----
> From: Anthony Ritter [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 4:53 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Retrieving data from a URL in PHP
> 
> 
> The code that follows is from Welling and Thomson's book on 
> PHP and mysql
> (page 372)
> 
> I've tried it on Apache/ MS Windows 98 / PHP and I get the 
> following line:
> 
> "No quote available."
> 
> My questions...
> 
> 1. Why can't I retrieve the present stock quote?
> 
> and
> 
> 2. What does the variable
> 
> $quote
> 
> represent in the script?
> 
> I cannot find what the variable -or array - $quote has been 
> assigned to.
> Please see:
> 
> echo $quote[1];
> 
> below
> 
> Thanking all in advance.
> Tony Ritter
> ......................................................................
> 
> 
> <html>
> <head>
> <title>Stock Quote from NYSE</title>
> </head>
> <body>
> <?
> $symbol="IBM";
> echo "<h1>Stock Quote for $symbol</h1>";
> $theurl="http://finance.yahoo.com/q?s=ibm&d=v1";;
> if (!($fp=fopen($theurl, "r")))
>  {
>   echo "Could not open the URL";
>   exit;
>  }
> $contents= fread($fp, 1000000);
> fclose($fp);
> $pattern="(\\\$[0-9]+\\.[0-9]+)";
> if (eregi($pattern,$contents,$quote))
>  {
>   echo "$symbol was sold at:  ";
>   echo $quote[1];
>  }
> else
>  {
>   echo "No quote available.";
>  }
> echo "<br>"."This information retrieved from<br>"."<a
> href=\"$theurl\">$theurl</a><br>"."on ".(date("l jS F Y g:i a T"));
> ?>
> </body>
> </html>
> 
> 
> 
> 
> 
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
--- End Message ---
--- Begin Message ---
do you mean?

// load your csv
$fp = fopen('your.csv', 'r');

while(($line = fgetcsv($fp, 4096)) && $line[0] != $_GET['id']);

// the loop terminated...possible outcomes are a match or EOF, in which
// case $line will be boolean and not an array
if (is_array($line)) {
  // you matched the correct line, now use the contents of $line array
} else {
  // a match was not found; do the appropriate thing
}

-----Original Message-----
From: FrankThiel
To: [EMAIL PROTECTED]
Sent: 6/5/02 6:38 AM
Subject: [PHP-WIN] CSV. Parsing a defined row?

Hello, i couldnīt find an answer in the NewsArchive.

How can i parse a CSV file, and show a defined row taken from an url.
I have got this link www.something.com/something.php?id=234
the CSV example:

id,article,category
233,art1,cat1
234,art2,cat2
235,art3,cat3

I do know how i can parse a whole file with fgetcsv, but not how to
parse an
explicit line.

THX for help.

Frank Thiel





-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Can anyone tell me exactly which three extensions these are?

extension=php_db.dll
extension=php_dba.dll
extension=php_dbase.dll

>From what I can see in the manual, they could all refer to the three same
things :-)

regards,

Mikey


--- End Message ---
--- Begin Message ---
"Prachi Shroff" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> the link just says
> javascript:window.open(
> Why would that happen?

>   R'twick Niceorgaw <[EMAIL PROTECTED]> wrote: echo "
href=\"javascript:window.open(\"addfossilpage.php?me=$folder_id\",\"width=43
> 0\",\"height=450\" )\">";

    Count your quotes...your string is

href="javascript:window.open("

At that second quote your string ends.  Use single quotes inside the
doubles, or single quote the entire string and get rid of the slashes.
Something like:

echo 'href="javascript:window.open("addfossilpage.php?me=' . $folder_id .
'","width=43 0","height=450" )">';

 - Steve Yates
 - I drank WHAT!? - Socrates

/ Taglines by Taglinator - www.srtware.com /



--- End Message ---
--- Begin Message ---
"Marius Venter" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Security Alert! The PHP CGI cannot be accessed directly.
> This PHP CGI binary was compiled with force-cgi-redirect enabled.

    I forget your earlier post...if you have PHP on a Windows server I
believe you can safely enable this option in php.ini.

 - Steve Yates
 - I don't work long hours.  They are all 60 minutes, just like everyone
else's.

/ Taglines by Taglinator - www.srtware.com /




--- End Message ---
--- Begin Message ---
I am a secondary student who runs VBulletin forum from my house. I am the
administrator and everytime I connect to it from school, the schools ISA
server caches my username and password. I was wondering if there was a PHP
fix to this type of situation. People in my school who use the forums are
being able to post stuff under my name from around the campus. Any insight
appreciated.

Thanks!

Mike T.
www.fvforces.net



--- End Message ---
--- Begin Message ---
I'm working on a windows2000 platform and i need to use php version >=4.2
for my graphics.How do i go about solving the problem of gd that can be
supported by the above php version? The gd in phpdev 4(php version 4.06)
cannot be supported by the bove php version.

-----Original Message-----
From: Miguel Cruz [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 23, 2002 10:20 AM
To: Opere, James
Cc: PHP Windows Discussion List; PHP General Discussion List
Subject: Re: [PHP] PHP version 4.2 and above


On Wed, 22 May 2002, Opere, James wrote:
> I have aproblem with php >= 4.2.I'm working on graphics but when i install
> php4.2, i get an error that it doesn't support GD library.
> Is there anybody who has any idea as to how it can be possible to use the
> above versions and still run my scripts successfully?
> 
> Currently i'm using phpdev4 which with php 4.06 which does not support
> global variables but support the GD library for Graphics.

Any version supports the GD library if you install it that way. But 
without knowing your platform it's hard to guess what you might have to do 
in order to get things going.

miguel
--- End Message ---
--- Begin Message ---
Can anybody help me!!!

In my Windows2000 machine I use Apache 3.24 and PHP 4.0.6 and all is OK.
But when I transfer my code to work machine (Apache/1.3.22 (Unix)  (Red-Hat/Linux) 
mod_ssl/2.8.5 OpenSSL/0.9.6b DAV/1.0.2 PHP/4.0.6 mod_perl/1.26)
the following script returns FALSE.

<?php
define(COUNTRY_OPTION, preg_quote('value="') . '(.*)' . preg_quote('">') . '(.*)' . 
preg_quote('</option>'));
$aaa = "<option value=\"100\">ANTIGUA AND BARBUDA</option>";
echo (eregi(COUNTRY_OPTION,$aaa,$regs))?"TRUE":"FALSE";
exit;
?>

--- End Message ---

Reply via email to