Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Which Function Do I Need To Read The Page Through Http?


I need read the html page through http and extract the links from it. Which function is better to use for this purpose: fopen() + fread(), file_get_contents(), or fsockopen()?




View Complete Forum Thread with Replies

Related Forum Messages:
File(), Not Able To Read Http://....
Running FC5 with and yumed with latest updates. I'm trying to read HTTP respons as file, using func file(). Tried example from Manual, and others. I can read local text file, but when changing aredress to http://localhost/ , it doesnt work. Tried fopen() as well, without any luck. the variable: allow_url_fopen , in PHP.INI says On.

View Replies !
Pass The Variable From 1st Page And Read It With Other Name On 2nd Page
I am new to this and learning slowly, but I was hoping someone could give me some quick advice on how to create a variable on one page and have it passed to another to be read as an ID for a mySQL database.

I want to pass the variable "varRevID" from one page and have it read as "reviews_id" on the other.

My database is pulling from just the first record and I would liek to designate from the pointing page which record to pull from.

View Replies !
The PHP Die() Function, HTTP Packets, And Mozilla And XML
I'm writing an XML application at the moment and I'm trying to implement
exception handling - particularly fatal exceptions.

currently if a fatal exception is raised, I create error data in XML
format and then send the well-formed XML result document to the user
agent. I'm also careful to set the mime type to text/xml or
application/xml (I'm not sure how/if browsers treat them differently)
Immediately after sending this XML document to the browser, I call the
die() function to terminate script execution and make sure nothing is
sent after the end of the XML document. This helps to ensure that the
document is well-formed when the user agent finishes loading it.

This works a treat in IE. IE would display errors if it was not well-formed.

In mozilla (netscape7, firebird, etc.) I get blank (grey) window content
area. When viewing the source, I see a well-formed XML document. If I
don't use the die() function, then Mozilla renders it properly. Are
there any special requirements for how HTTP messages are terminated?
Could this be what die() is breaking?

View Replies !
Is It Possible To Read ASP.NET Web Page In PHP?
Is it possible to read another web page in PHP?
If is ASP.NET, the code would be
------------
WebRequest req=WebRequest.Create("http://www.microsoft.com");
WebResponse res=req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
String Output=sr.ReadToEnd();
Response.Write("The content is : " + Output);
--------

View Replies !
Read A Web Page
i want to store(read) the contents of a "web page" into a file. how can i do it in PHP. Please help me. The web page contains a table. i want to fetch & store the contents of that table into a file.

View Replies !
Function To Read Email
I looking for function to fetch my email and add it to my vBulletin ( support forum ) automaticly so any one have this function ? I Need email subject & date & sender & body only.

View Replies !
Making A Function To Read XML
I'm looking for a good guide to newbies about XML and PHP.I have tried making a function to read XML but i was unable to get it to work. :/ Im also looking for a nice manual or code example that handles creation off XML sheets.

View Replies !
Stripping Http:// Form A Url When Displaying To A Page...
Hi I'm trying to display URL's in my link exchange like google does.

Here is the function to display the Link, Description and URL:

View Replies !
Read A Web Page And Then Display
I'd like to read a webpage, the parse it and display a small part of
it. Here is what I've tired. It isn't working.

<?php
$handle = fopen("http://www.yahoo.com/", "r");
$contents = fread($handle, filesize($filename));
echo $contents;
?>

View Replies !
Q: Read Text With VBA From A PHP Web-page
I created a page on our intranet that shows a number and that
increases for every time the page is opened. It is similar to a
visitors-counter.
When I look at the page with Internet Explorer it works just fine.

Now I want to read this web-page from a MS-Word macro and include the
number as a company wide unique id in my MS-Word document.
Unfortunately, the PHP script doesn't update the counter when I call
it from my MS-Word macro.

How can I force PHP to update my counter when I call it from a VBA
macro?

I am using the following code:

View Replies !
Read An HTML Page
It may sound kind of crazy, but I'm trying to see if there's a way php code can 'read' contents of a static HTML page and store the contents into a variable. Is it possible? If so, how?

View Replies !
Load Page Then Read
Is there a way to completely load the page of its HTML elements then read all those elements into a string? For example, I have a PHP page that get its HTML content from the database. I want that page to completely loads, ie., get the content from the database, then write all of that page's text and html elements into a string so I can modify it (ie. remove all the links) to display it in another page.

View Replies !
Read Previous Page Url
I have a query regarding browser url.Let me narrate the exact scenario which i need. I would like to expire my session when a person enters different url in the navigator bar other than my url and comes back to my url. For example if i visit example.com and then i type gmail in the same navigator bar and then move back to my url example.com through browserback button then i have to end the session of my client i mean he has no more access to my site. The same scenario is there for icicibank.com. I wanna the code using php and javascript.

View Replies !
Read Page To Variable
I have tried tons of functions but none works the way I want. I have a page foo.php. Then in that I set a couple of variables. Now, if I include foo.inc.php that file can use all of these variables. Code:

View Replies !
Code To Read A Web Page
How can I read another web page in php. I tried:

$url = 'http://www.yahoo.com'
$contents = file_get_contents($url);
echo $contents;

but I get an error: The specified CGI application misbehaved by not returning a complete set of HTTP headers.

View Replies !
How To Read Value Which Is Encrypted By PASSWORD() Function
I have a problem while reading a password value in mySQL database by using PHP. I input value using PASSWORD("pass"). I can see in the database, the value is encrypted. But I failed to select the value.

SELECT * FROM table_name
WHERE user_name = "username"
AND password = PASSWORD("pass");

I failed to read the record. I also tried function md5(). And I had the same problem.
Is there anyone could help me out with this problem? I want the text field password in mySQL database to be encrypted. And I want to be able to read it later.

View Replies !
Javascript Function Can't Read Variables Set By Php
I've basically copied this code ad verbatim from a book to
test...what I have is an index.html page that refers to "map_data.php"
and "map_functions.js"...

map_data.php draws some coordinates from a database and outputs them
into an array called markers. However, when I load up the index.html
page, it says "markers" is undefined...

Here's the code in map_data.php:

var markers = [
<?php while($row = mysql_fetch_assoc($result)): ?>
<?= $joiner ?>
{
'latitude': <?= $row['latitude'] ?>,
'longitude': <?= $row['longitude'] ?>,
'lawyer': <?= $row['lawyer']?>,
'city': <?= $row['city']?>,
'business_name': '<?= addslashes($row['business_name'])?>',
'address': '<?= addslashes($row['address'])?>'
}
<?
$joiner = ','
?>
<?php endwhile; ?>
];

View Replies !
Function Like File() But Will Read Lines X Through Y Only?
file() works great, until you start looking at file that are very large,
say 134MB.

Is there any function that will return an array for each line of a file,
but only for lines given as parameters?

A function like file("/path/to/file",100,230) which would return lines 100
through 230 as an array.

View Replies !
Read A Php Session Value Into A Javascript Function
need to read a php session value into a javascript function does anyone know how to do this.

View Replies !
Mail() Function Problem - Works In Shell Scripts, But Not In Http
I have a redhat 9 linux machine running apache 2.0.47, mysql 4.0.15,
and php 4.3.4. I have been puzzled by this mail() problem for quite a
while, could someone please give me some hint on this?

I configured sendmail with a relay so that all outgoing mails go
through our organization's exchange mail server:
DSexchange.domain.com. The php.ini file specified the path to
sendmail: "sendmail_path= /usr/sbin/sendmail -t -i".

I can send email out from shell by doing ">mail lsun91125@yahoo.com".
I also tested a shell script using php mail() function:
----------------------------------------------------
#!/usr/local/php/bin/php -q
<?php
$sent=mail("lsun91125@yahoo.com", "php email", "test this");
print "Send=$sent
";
?>
----------------------------------------------------
This works fine too.

But when I tested the following script on the web, the email cannot be
sent out. The browser returned with "Send=". There is nothing in the
mail queue either.
----------------------------------------------------
<?php
$sent=mail("lsun91125@yahoo.com", "php email", "test this");
print "Send=$sent
";
?>
----------------------------------------------------

View Replies !
Read Data From External Page?
I have tried to think of a solution to this problem, but i can't find it. My question is: If possible, how do you from your own page confirm that a form has been send from an external page?

View Replies !
Page Not Read By Conditional When In Sub Folder
I'm using some php conditionals in included footer.

I identify some pages at the top with -

$page='alt_footer'

then have a conditional in the footer.php, like -

if ($page!='alt_footer') {

All works great, but if I put the page in a sub directory (making path adjustments for the includes), it is not recognized as having $page='alt_footer'

All path relationships between the page (in sub folder) and the includes (in folder at same level as sub folder) work fine, just the conditional (from the include to the page) is not recognized.

View Replies !
Use File() Function To Read A Variable Name, Not A Literal Name.
I know I can use the file() function to read a file into an array by
providing a literal file name between single quotes:

$lines = file('literal_file_name');

But, what if I want file() to use a variable name?

$variable_file_name = "literal_file_name";
$lines = file($variable_file_name);

Of course, that example won't work. But what will?

View Replies !
Write A Function That Will Read In A Text Document
I'm trying to write a function that will read in a text document containing various bespoke tags which I then expand into the appropriate HTML. I've done most of them but was wondering if someone could help me with this particular one .. I'm guessing I should be using preg_replace but can't seem to get it to work.

I have a variable called $rec_id which is an integer. The following is the conversion I want to perform: Code:

View Replies !
Can't Read Remote Web Page From Local Apache/PHP
I'm trying to read the contents of any Web page on another
host. I'm finding that...

echo file_get_contents( 'http://www.php.net' );

.... works fine if I upload the PHP script to my Web host, and run it
there. But if I run it on my PC, which is running Apache 1.3.33
(Win32) and PHP 5.0.5, then it always times out, and gives me the error
message...

[error] PHP Warning: file_get_contents(http://www.php.net) [<a
href='function.file-get-contents'>function.file-get-contents</a>]:
failed to open stream: A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to
respond.

I get the exact same results using...

$fh = fopen( 'http://www.php.net', 'r' ) or die( $php_errormsg );
while (! feof($fh)) {
$page .= fread($fh,1048576);
}
fclose($fh);
echo $page;

Anyone know what could cause this to happen?

View Replies !
Read Txt File And Pass Each Line As Variable In A Function
I'm designing a website that is update several times a week with a new gallery of images.

Each set of images is stored in it's own directory with a page that generates a gallery and textually describes the images in the directory. I want to create a page that reads from a list of the image directories and dynamically generates a link to each gallerey, 10 to a page.

something like this:

directorylist.txt

index.php reads directorylist.txt, places the first gallery listed at the top of the page, then 9 more links to the next 9 galleries. At the bottom of this page, links to the pages that contain galleries 11-20, 21-30, etc.

I have already created functions that take the gallery ID and generate the links, I just can't seem to figure out how to read from the text file, then generate the links in my main pages.

View Replies !
Need Function To Read File And Send To Browser Anonymously
I need to write a script which reads a file on the server and then outputs it through php by sending all the necessary headers and then the data.

I recently found just the thing but cannot locate the site now! Basically I want visitors to visit download.php?id=1, look up which file has an id of 1 and send it to the browser. This'll let me count downloads and keep anonymous the original filename.

View Replies !
Php Function To Read Local Python Script Output, Not Code
On my server python has to run in the wwwroot/cgi-bin folder, but php can run anywhere. My site is going to be written in python but I don’t want my user to see the url as mysite/cgi-bin/... .

So for example my homepage, index.php should contain a simple php script that will get my python page from the cgi-bin directory and display it. However when I try to use SSI or fopen/file_get_contents/readlink and commands like these it just displays the python code. Where as when I visit the python page in my browser it runs it and displays the output for me.

My question is what php function can I use to execute my python page and return the output, not the code itself. (I think my hosting provider has disallowed certain powerful commands like system() etc. Does this make it impossible?). As the very least can’t my php script pretend to be a www user and ‘visit’ the python page to read the output?

View Replies !
Make Text String Read From Right To Left In Imagettftext() Function
I want to write a text string from right to left instead of from left to right with the imagettftext (); function

I read in teh manual that the angle variable controls this, it says that 0 angle means left to right, so I tried 180, 360 but nothing happens What angle do I need to put it to get it to write it right to left. Code:

View Replies !
Read The Page Of The Site & Rerturn The Contents Of MEMBERS_URL & MEMBERS_NUMBER
a line on my site reads MEMBERS_URL="my2ndsite.com" MEMBER_NUMBER="12345" . Im Trying to read the page of the site & rerturn the contents of MEMBERS_URL & MEMBERS_NUMBER, but i cant get it to work can anyone suggest where ive gone wrong please PHP Code:

$myfile = file("http://www.mysite.com");
foreach ($myfile as $row=>$data) {
if (preg_match('/MEMBERS_URL="(.*?)" MEMBERS_NUMBER="(.*?)"/',$data)) {
echo $data[1];
echo $data[2];
}
}

View Replies !
When A Search Engine Spiders A Page Does It Read The Raw Code Or The Parsed Html?
When a search engine spiders a page does it read the raw code or the parsed html? I ask as I want to confirm if any text retrieved from a database is 'read' not the php code that gets the data.

View Replies !
Warning: File_get_contents(http://someurl) [function.file-get-contents]: Failed To Open Stream: Connection Refused In /dirc
I have used the function file_get_contents to retrieve html content from a website. My code works fine in localhost but after uploading it to the server, the following error appears:

Warning: file_get_contents(http://someurl) [function.file-get-contents]: failed to open stream: Connection refused in /dirc/code.php on line 13

View Replies !
Warning: Fopen(http://localhost/.. ?HTTP Wrapper Does Not Support Writeable Conn
I am able to create a pdf using php and ezpdf, its works fine, and display the pdf document in the current server page.

But here are two things i wish to do, first store the pdf and than open, if possible in a new popup window?

When i tried this function below, it gives me an error

Error:
Warning: fopen(http://localhost/pdf/files/tmp1/yasmina.pdf) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections. in C:Program FilesxampphtdocspdfpdfClassesAndFonts_009ecertificate.php on line 139
Could not open file to save PDF. Code:

View Replies !
Server HTTP Sends Or Streaming HTTP?
I was wondering if you guys had any ideas to constantly
stream a webpage in case an announcement was posted
or possibly pushing onto the browser information.

What I basically want is for a user browsing my website
to be notified of any new announcements. I thought
about checking everytime he changes pages but then
I realized that I want them to be notified as long as
they have the page open even if it's minimized. So it
would at best be a method to use php force send a msg
after someone posts an announcement.

View Replies !
Questions About HTTP Headers Sent With PHP In HTTP Authentication
Here is an example from the PHP Manual

<?php

if ((!isset($_SERVER['PHP_AUTH_USER'])) || (1==1)) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button'
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</
p>";
}
?>

Questions.

1. This is a status code not a header, right? = header('HTTP/
1.0 401 Unauthorized');

2. According to the change log in the PHP manual, starting with 4.4.2
and 5.1.2 the header function now prevents more than one header to be
sent at once as a protection against header injection attacks. Does
this mean if I make multiple header calls the headers will be sent in
multiple response messages to the browser? Is this allowed? Can a
server send multiple response messages to one request?]

3. If you hit the "cancel" button on the browser user name/password
request dialog (as alluded to in the code snippet above), what message
does the browser send to the server.

View Replies !
Add A 301 Redirect To Move All Access From Http://a.com To Http://www.a.com
I'm currently using the following .htaccess code:

RewriteEngine on
RewriteBase /
ReWriteRule .htaccess [F]
RewriteRule ^([a-zA-Z0-9/-]+)$ index.php?url_path=$1

And I'd like to add a 301 redirect to move all access from http://example.com to http://www.example.com. How can I do it, keeping the current rewrite rule?

View Replies !
Readfile("http://.") Is Slowing Down My Page Downloads
The problem is that the page load slows down tremendously and I need to reconsider how this is done. Here are a few questions:

1. Is it better to use cURL or readfile?

2. Can cURL be set up in such a way that it performs non blocking downloads?

3. Is there an HTML tag I can wrap my readfile in so that a my readfile can happen concurrently to page load? Similar to what happens when <img> or <script> tags are executed?

AJAX is not the answer for me because I need the content from the readfile to be visible to Search Engine Robots.

View Replies !
Calling A Function Or Page To Another Page
I have two pages that are part of a user registration script. For simplicity's sake I will call one registration.php and the other validate.php What I basically would like to do is instead of going from registration.php to validate.php, I would like to call the script from validate.php and use it without leaving registration.php

The following code is a portion of the validate.php code. Here are my questions regarding this page. 1). If I want to call it or include it in registration.php should I make it a function? If so, how would I do that. 2) Can I call the validate page or function through an a href statement? (see registration.php code) PHP Code:

View Replies !
Error: Warning: Main(http://app.feeddigest.com/digest3/ODC9FIC36I.html) [function.main]: Failed To Open Stream: No Route To Host
I have a client which is seeing the following error from this code in WordPress:

<?php
include ('http://app.feeddigest.com/digest3/ODC9FIC36I.html');
?>

Error:
Warning: main(http://app.feeddigest.com/digest3/ODC9FIC36I.html) [function.main]: failed to open stream: No route to host in /hsphere/local/home/user/mydomain.com/wp-content/themes/anaconda/page.php on line 18

Warning: main(http://app.feeddigest.com/digest3/ODC9FIC36I.html) [function.main]: failed to open stream: No route to host in /hsphere/local/home/user/mydomain.com/wp-content/themes/anaconda/page.php on line 18

Warning: main() [function.include]: Failed opening 'http://app.feeddigest.com/digest3/ODC9FIC36I.html' for inclusion (include_path='.:/usr/local/lib/php') in /hsphere/local/home/user/mydomain.com/wp-content/themes/anaconda/page.php on line 18.

View Replies !
Email With Attachment - Annot Be Accessed. The File May Be Read-only, Or You May Be Trying To Access A Read-only Location.
It is a basic email with an attachment. The email and attachment are getting sent and received ok. When the recipient tries to open the attachment, the right application opens (eg. Excel) but then throws up an error. I am using base64 encoding. For example:

.xls file with base64 encoding:
'testing.xls' cannot be accessed. The file may be read-only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding.

.pdf file with base64 encoding:
There was an error opening this document. The file is damaged and could not be repaired.
so the file isn't being decoded right. I have tested on Yahoo and Outlook. PHP Code:

View Replies !
Fgetcsv Returns False In Dynamic Read Vs. Hard-coded Read ??
I am working with directories in PHP for the first time. I have code
that I've changed multiple times to try different things. I would think
this is pretty standard fare so I'm not sure why I can't seem to get it
right.

What I would like to see happen:

The code opens the directory and loops through the files, opening them
and processing them.

What is happening:

If I hard code the name of one particular file (it is always the same
file) in my test setting, fgetcsv does not return false and the code
runs fine. The file is parsed and all is well. However, if I let the
code open a directory and then loop through the files, this one
particular txt file does not work. For debug purposes, I have it
displaying each file name and it can display the name, it just won't
process it.

I've even tried setting a for loop and hard coding each file name
(since right now I know the names - I won't in the future) and the file
is processed. It is only when it is set to my $file var dynamically
rather than being hard coded.

Here is the code:
$handle_dir = opendir('../directory_name');
/* loop over the directory. */
$countfile=0;
while (false !== ($file = readdir($handle_dir))) {
$countfile++;
$filevalues = "";
//Skip the first two files that where found because they are
"." and ".."
if ($countfile 2) {
//echo $file;
//begin loop through each file name
$handle = fopen($file, "r");
echo "Filename is: $file<BR>";//at this point the
code can print the file name
if (false == ($filevalues =
fgetcsv($handle,6021,','))){
echo 'problems<br>'//for one particular file,
this always displays
}

View Replies !
Read File - Limit The Number Of Lines To Read
How can I open a file and then limit the number of lines I want to read? say I have a text file and I only want to read line one to get the title of the text within?

View Replies !
Read (and ONLY Read) A Multi-sheets Excel File With PHP.
I want to read (and ONLY read) a multi-sheets Excel file with PHP.
I found so many scripts on the net that I finally don't know what to choose
so... could experimented users help me to directly find the one that I need
?

Here are the two obvious things the script must match :
- free
- can read multi-sheets Excel files

View Replies !
Trapping A File Error: Failed To Open Stream: HTTP Request Failed! HTTP/1.1 404 Not Foundin
php
Warning: file(http://shop1.outpost.com/product/5053975)
[function.file]: failed to open stream: HTTP request failed! HTTP/1.1
404 Not Foundin

I am just trying to put some code around this to trap it.

View Replies !
Read Contents Of An External XML Page And Then Parse Its Contents
I have a URL that generates an XML page. I'm trying to read its contents and parse the information. But, I keep receiving these error messages: Code:

View Replies !
How To Read Up To A Point And Assign The Read Value To An Array.
Open a text file which will look something like this:

QuoteLink 1 http://www.blahblah.com/1651561
Link 2 http://www.etc.com/34324
Link 3 http://www.sdfkjsdf.com/12343423

basically its a "Link n" text followed by a URL text in the format of "http://www.page.com/random numbers"

What I would like the php script to do is to read "Link n" text and output it with the a http link to the URL which follows it. That is it should look something like this in the output:

Link 1
Link 2
Link 3

I have learned how to read a text file with php so far but I have no idea how to make it read up to a point and assign the read value to an array.

View Replies !
Function That Will Refresh A Page
Is there a php function that will refresh a page, similar to JavaScripts location.reload()? I read somewhere that location.reload isn't supported in all browsers, so I want a php function that will be supported on most browsers.

View Replies !
How To Go To Previsous Page And Do Function
i don't know how to write when i click a submit button, i can do a
function and go back to previous page.

eg, when i click "No" button, the system will do deletefunction(), and
go back to previous page. I only know if the button is
<input type ="button" name="submit" value="No"
OnClick="javascript:history.go(-1)" ><br> i can go to previous page.
But how can i do deletefunction()?

View Replies !
Function Be Called From A Different Page
Can a function be called from a different page?

View Replies !
Use ?id=3 To Call A Function In The Same Page? :S
i have a script which displays information from a mysql table (index.tcos) and then creates a link using the rows id on clicking this link i want it to delete that row from the table so what i need is a way of saying Code:

View Replies !
Function On Page Close
How do i setup a timestamp that rights to mysql on website page close? Can i add a function based on page closure or do i have to add a session time out mechanism?

View Replies !
Running Php Function AFTER Page Is Delivered
One of my websites is composed of all static pages.

I've got a php include that I have inserted at the end of the pages to do tracking and other housekeeping, but it doesn't output anything to the page itself.

Unfortunately this still forces me to put all the pages through the php interpretor.

Is there any clever way I can use apache (possibly a module in htaccess?) to simply execute the php script AFTER any html page is delivered to a user, therefore keeping their access speedy and a side benefit of truly keeping the pages static, complete with etags, content-length and "last modified"?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved