Why isn't this working?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brad62
Forum Newbie
Posts: 4
Joined: Mon Jun 20, 2005 4:32 pm

Why isn't this working?

Post 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";
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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());
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

Post by nhan »

and also try to echo the query, it helps me a lot when im having some problems with my code...

:)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Might want to have a look at http://www.php.net/mysql_real_escape_string too.
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

another note is not to url_decode strings, as they are automatically interpreted as what they should be. (logically)
Post Reply