how can I exeute a URL inside php code?

A

Anonymous

Guest
hi,
I have a URL, how can I execute it inside my php code without needs to put it in echo command ???
 
What do you mean by "execute a URL"? A URL is a pointer to a file on a web server --you can retrieve a URL, or you can link to a URL, but generally you don't "execute" URLs.
 
I ean that I dont want the URL as hyperlink, I want the URL to be opened once the line of the code reaches the URL , without requiring any action fro the user.
 
If I have this code:
Code:
	$res=mysql_query($sql);
    $num_result = mysql_num_rows($res);
for($i=0;$i<$num_result;$i++)         //loop to send sms message to all members of selected committee
{
   $record=mysql_fetch_array($res);     //to retrive a mobile phone number form members table .
   $mobile = $record["Member_mobil_phone"];
 
  echo "<a href='http://www.halwanisms.com/bulk/post_Univ.asp?UserId=****&password=*****&number=$mobile&Text=$msg_content&sender=lemo&type=2\'> to: $mobile </a>"; echo " <br>";
  }
I added this insted of echo"<ahref....</a>
Code:
 //header('Locaion:http://www.halwanisms.com/bulk/post_Univ.asp?UserId=****&password=*****&number=$mobile&Text=$msg_content&sender=lemo&type=2\')
but, my problem is: I am in a loop, I want to send a bulk of numbers to a URL. I dont ant the URL to be opened in every loop round, I want to collect all the numbers and then send them to the URL in one time.
HOW CAN I DO SUCH THING. Also when I added the header function , there is an error occured, I dont know why?? so until now, I could not perform the correct function from the program . :eek: :eek: :shock:

Also, I chnged the double coutes to single coutes.
thank you..
 
I think you need to write Javascript in combination with php...


create a array of urls to be opened.. in javascript...


and for onload event of html.... use the for loop and open windows with those urls....

Code:
window.open (url[i])
 
I think you need to refine your terminology a bit. First, stop using the word "execute". It doesn't mean anything in this context. Here are your options:

  • You can make the user's browser go to a page. This is called a redirect.
  • You can retrieve the contents of a URL (which is the same as retrieving the URL in the browser, except that PHP recieves the contents and you can manipulate them with PHP).
  • You can include a URL, which is essentially the above except you're sending it directly to the user.
  • You can print a link to a URL, which a user can then click on in their browser.

These are the only things you can do with PHP. You say "I want to send a bulk of numbers to a URL", but you cannot "send" anything to a URL. You can only retrieve a URL. You can pass parameters to the server via GET (e.g. http://www.site.com/script.php?parameter=value), and perhaps this is what you're thinking of, but you shouldn't think of it as "sending" anything to the URL.

If you're getting an error, you need to post the exact error including line numbers, plus the code that it refers to.
 
thank you.
swirlee, you said:" You can pass parameters to the server via GET ". EXACTLY that what I want, but I dont want the URL page to be opened each time I send these parameters.

The link that you gave me does not opened.
Can you copy and paste the content that you think it will help me... :-D
thank you again
 
swirlee, I thought the example you put in the previous replay is a link, but I anderstood now.
Any way, I am not getting an error, I am passing the parameters in the URL exactly as you have mentioned in your replay.
But the statement which send the parameters in the URL which is "echo" or "header" are in a loop, I dont want a page appears to me in every loop round, nor a page appears with links.
I want to send the parameters only without a page appears.
or store the parameters (which are fetched from the database) in any way the send them one time.
 
So basically you want to send a number of requests to a web server, in a loop? Well, there's plenty of ways to do this.. you can use sockets, or one of the many HTTP classes at PEAR or PHPClasses.org, or you can use PHP's built-in cURL library.
 
Back
Top