Page 1 of 1

SMS API HELP

Posted: Fri Sep 04, 2009 3:49 pm
by php_new_guy_09
A

Re: SMS API HELP

Posted: Fri Sep 04, 2009 4:44 pm
by requinix
So what's the problem? What's your question?

Re: SMS API HELP PLEASE............................

Posted: Sat Sep 05, 2009 4:11 am
by php_new_guy_09
b

Re: SMS API HELP

Posted: Sat Sep 05, 2009 4:35 am
by John Cartwright
We're not here to do the work for you. Again, what specifically are you having trouble with?

Re: SMS API HELP

Posted: Sat Sep 05, 2009 4:48 am
by php_new_guy_09
I do not have any knowledge of php or mysql, I have a little knowledge of sql in ms access, and a little experience of programming in vb, so im pretty useless, I downloaded xampp on a laptop yesterday however incurred problems, i would just like to know if the code i posted will work and if not, where have i made mistakes.

Re: SMS API HELP

Posted: Sat Sep 05, 2009 5:08 am
by requinix
php_new_guy_09 wrote:i would just like to know if the code i posted will work and if not, where have i made mistakes.
Well, no, it won't work.

Code: Select all

<?php
 
$uname = "youremailaddress";
$pword = "yourpassword";
$database="my database";
$sender = $_REQUEST['sender'];
$content = $_REQUEST['content'];
$from = " php_new_guy_09";
$selectednums = $sender;
$message = AUTOREPLY CONTENT;
$message = urlencode($message);
 
mysql_connect(localhost,$username,$password); // localhost is not a constant. where's $username? $password?
mysql_select_db($database);
INSERT INTO  log (sender,content) VALUES ('$sender','$content'); // not php code
$query="SELECT $sender, $content FROM log "; // horrible, horrible idea - see below
$result=mysql_query($query);
 
$content ^ sunrise // not a php statement. what is this supposed to be?
SELECT '$content', FROM autoreplymsg WHERE content ='sunrise'
ORDER BY RAND()
LIMIT 1 // not php code, invalid sql
 
$data = "uname=".$uname."&pword=".$pword."&message=".$message."&from=". $from."&selectednums=".$selectednums."&info=".$info."&test=".$test; 
 
$ch = curl_init('http://www.txtlocal.com/sendsmspost.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); 
curl_close($ch);
 
mysql_close();
 
?>
I would like to draw attention to

Code: Select all

$query="SELECT $sender, $content FROM log ";
$sender and $content are coming from user input. You are letting them put whatever they want into your SQL query. I don't have to explain why that's bad, right?

Re: SMS API HELP

Posted: Sat Sep 05, 2009 5:31 am
by php_new_guy_09
Line 13: Wouldn’t my hostname need to replace ‘localhost’

Line 13: is suppose to read ‘$uname’ and ‘$pword’

Line 19: is suppose to mean where the string $content matches the keyword sunrise

Line 22: is suppose to mean select only one result

Line 19/22: I’m not sure where I got that from, I will find out the correct code for that.

Thanks a lot, you have put me on the right tracks, I am now going to make some corrections and look into Line 16.

THANKS A LOT AGAIN