By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

Simple Issue With cURL

P: 6
i am in the closing stages of an sms application that will send different sms messages to different phone numbers. I will be using an sms gateway and my research led me to use cURL to implement the smpp api of the company that has the gateway. I was doing a test run of cURL on my localhost to see if all went smoothly before i implemented on the application(i wanted it to insert values into a table), but it was not working. I turned error reporting on and this is what i got:

Expand|Select|Wrap|Line Numbers
  1.  Notice: Use of undefined constant link - assumed 'link' in /srv/www/htdocs/sms/sms_connect.php on line 6 Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /srv/www/htdocs/sms/load.php on line 9 Notice: Undefined variable: ch in /srv/www/htdocs/sms/load.php on line 32 Warning: curl_close() expects parameter 1 to be resource, null given in /srv/www/htdocs/sms/load.php on line 32
  2.  
My original code is:
Expand|Select|Wrap|Line Numbers
  1. include 'sms_connect.php';
  2. $sql="select name from sms";
  3. $result=mysqli_query($link,$sql);
  4. while($row=mysqli_fetch_assoc($result))
  5. {
  6.    $name=$row['name'];
  7.    $url = "http://localhost/sms/index.php?name=".$name;
  8.    // create a new cURL resource
  9.    $ch = curl_init();
  10.  
  11.    // set URL and other appropriate options
  12.    curl_setopt($ch, CURLOPT_URL, $url);
  13.    curl_setopt($ch, CURLOPT_HEADER, 0);
  14.  
  15.    // grab URL and pass it to the browser 
  16.    curl_exec($ch); 
  17. }
  18. // close cURL resource, and free up system resources
  19. curl_close($ch);
  20.  
Thanks..
Oct 10 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.