Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to send SMS to people whose contacts lies in my database of MySQL. Connection is established correctly, but the problem is that when i use header function for calling the API URL only SMS is sent to 1st contact. Then the page is redirected to new page and loop stops. I am attaching the script check this and let me know.
PHP
<?php <br mode="hold" /?>$con=mysql_connect("localhost","root","");
if(!$con)
        {
            die('Could not connect:'.mysql_error());
        }
          mysql_select_db("gtu_results",$con);

$query="select sem_6.`first_name`,sem_6.`middle_name`,sem_6.`last_name`,sem_6.`enrollment_no`,sem_6.`email_id`,sem_6.`contact_no`,student_marks.`WAD`,
student_marks.`TOC`,student_marks.`SE`,student_marks.`Info_Sec`,student_marks.`OSD`,student_marks.`CG` 
from sem_6 inner join student_marks on sem_6.`enrollment_no`=student_marks.`enrollment_no`";

$result=mysql_query($query);
$n=mysql_num_rows($result);

for($i=0;$i<$n;$i++)						
{
    $row=mysql_fetch_array($result);
    extract($row);

$name= "Name :".$row['first_name']." ".$row['middle_name']." ".$row['last_name']."%0A";

$msg = $name."Enroll No.: ".$row['enrollment_no']."%0A"."SE : ".$row['SE']."%0A"."WAD : ".$row['WAD']."%0A".
"OSD : ".$row['OSD']."%0A"."CG : ".$row['CG']."%0A"."IS : ".$row['Info_Sec']."%0A"."TOC : ".$row['TOC']."%0A";
$mob=$row['contact_no'];

header("Location: http://203.88.133.98/MoreSms.aspx?uid=<user_id>&pwd=<password>&mobiles=$mob&message=$msg ");
//    Problem might be somewhere arround here
}

?>
Posted
Updated 7-Jul-12 20:36pm
v3

1 solution

you need to use
PHP
urlencode
function to encode all data before passing to other pages. Also its better to use
PHP
file_get_contents
to make the api call.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900