Page 1 of 1

Why isn't this working?

Posted: Mon Jun 20, 2005 4:34 pm
by brad62
I'm trying an sms service that Ifound.
A company is recieving the sms from the user and send them to my web page and the number and text is added to my web page url:
http://www.site.com/message_in.php?sms=test&nr=123

I want the number and sms to be added to my database, but my script won't add the info.
Can anyone see what's wrong in my script here?

Code: Select all

error_reporting(0); 

require_once('Connections/connect.php'); 

$nr = $_REQUEST["nr"]; 
$sms = @urldecode($_REQUEST["sms"]); 

sqlconnect(); 

$query = "INSERT INTO `nu_sms` (`nr`, `sms`) VALUES ('".$nr."', '".$sms."')"; 
mysql_query($query); 

mysql_close(); 

echo "Your message have been added";

Posted: Mon Jun 20, 2005 4:49 pm
by Burrito
choose a better name for your title next time..."why isn't this working" is pretty vague and usually won't get a lot of attention:

syntactically your php looks fine, as far as I can see anyway.

you might try having it throw a mysql error if the query doesn't work which could tell you the potential problem.

Code: Select all

mysql_query($query)
  or die(mysql_error());

Posted: Mon Jun 20, 2005 7:21 pm
by nhan
and also try to echo the query, it helps me a lot when im having some problems with my code...

:)

Posted: Tue Jun 21, 2005 1:00 am
by timvw
Might want to have a look at http://www.php.net/mysql_real_escape_string too.

Posted: Tue Jun 21, 2005 2:04 am
by Syranide
another note is not to url_decode strings, as they are automatically interpreted as what they should be. (logically)