So I'm trying to write a script where I can populate a database with phone numbers and then have the script go down the list and text them all. The service I'm using "Nexmo" has a test function where you can input the number into a URL and then execute the URL to send the text. I got my database setup and I got the URL to except information from the database but I have two issues.
My script only grabs the first database entry, I need it to go down a list by ID.
I need tp script to repeat itself so that it will grab the next entry in the database and send the next text until it has exhaustes all possible DB entries.
As an example..script runs...URL is populated with DB entry 1 and executes. Text is sent. Process repeats until there is no more entries in the database but it to fill in the link with.
I believe I have most of the code and am just missing one small link somewhere, I'm posting it below with the sensitive information removed.
Thanks for taking the time to read this, or help me out.
<?php
ini_set('max_execution_time', 1300);
$dbhost = "localhost";
$dbname = "data_base";
$dbuser = "dbusername";
$dbpass = "passy";
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($dbname);
$sql = "SELECT * FROM ha_n ORDER BY `id` ASC";
$res = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($res);
$phone_fill = $row['phone_numbers'];
$url = 'https://rest.nexmo.com/sms/json?api_key=5555555555&api_secret=555555555555&from=5555555555&to='.$phone_fill.'&text=Welcome+to+Nexmo';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec ($ch);
curl_close ($ch);