Url error

Hi

All

I am trying to send the message from a below url. I am taking the values from database like phno and text message. but i am getting the error.
Below is the code.
<?php
include(“config.php”);

$query=mysql_query("select s_no,phno,smstext from smstest where sent is null or sent=‘’ ");
while($res=mysql_fetch_array($query))
{
$sno=$res[‘s_no’];
$phone=$res[‘phno’];
$message=$res[‘smstext’];

$url1 = ‘http://my.watchadz.com./sendsms.php?username=POP TECH&password=people&sender=TTT&mobile=’;
$urlPID = $phone;
$url2 = “&message=”;
$urlmsg=urlencode($message);
$url3=“&type=1”;
$url = $url1.“”.$urlPID.“”.$url3.“”.$url2.“”.$urlmsg;

$fp = fopen($url, ‘r’);
echo " <br> " ;
$content = ‘’;

    while ($l = fread($fp, 1024)) $content .= $l;
    fclose($fp);
    echo $content;
mysql_query("update smstest set sent='1'  where s_no='$sno' ");


  }

But i am not able to sent the message.

and it is showing the message as( variable password not valid)

please help me out to resolve this issue.

Thanks
MD.Samiuddin

?>

It might be falling over at this line

$fp = fopen($url, 'r');

because $url has a space in the query string from $url1. Try to urlencode $url to handle the space in the query string.

thanks for your reply

but iam gettng the error
Warning: fopen(http%3A%2F%2Fmy.watchadz.com.%2Fsendsms.php%3Fusername%3DPOP+TECH%26password%3Dpeople%26sender%3DTTT%26mobile%3D9160919293&type=1&message=hi+test): failed to open stream: No such file or directory in /var/www/mts/mtsproject/phpforms/sms.php on line 27
Warning: fread() expects parameter 1 to be resource, boolean given in /var/www/mts/mtsproject/phpforms/sms.php on line 31 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/mts/mtsproject/phpforms/sms.php on line 32

Yes you are right webdev1958 $url has a space in the query string from $url1. He has to urlencode $url to handle the space in the query string.

How about doing this, replace the space with %20


$url1 = str_replace(' ', '%20', $url1);

replaced the line: $fp = fopen($url, ‘r’);

with $fp = fopen($url, ‘w+’);

I’z a dot in ur URLz, screwin dem upz. (it’s 5 AM. lolcats humor is funny.)