0

Hullo,
I am working on a php application that is meant to respond to user requests to create accounts. For instance; whoever wants to create an account has to send a text with "Login" as the message content.
Only problem is that the mysql queries are not being executed. Can anyone help?
Here is the code I am using;

<?php
# PHP Responder Script
$msg      = $_GET["msg"];
$sender   = $_GET["sender"];
$receiver = $_GET["receiver"];
$operator = $_GET["operator"];

#$command = trim(strtolower($msg));
#
# Create response SMS messages
#
if($msg == 'Login')
{
include('includes/connect.php');
$passw = "pass123";
$password2=md5($passw);

$create_user = "INSERT INTO authentication VALUES('','Farmer','','2','$sender','$password2','1')";
$result = mysql_query($create_user);

if($result)
{
$messages = "Dear User, Your username is: ".$sender." "."Password is: ".$passw.". Thank you for registering with us";
#
# Uncomment this line to send a response message
#
echo "{GSMSMS}{}{}{"."$sender"."}{".trim($messages)."}";
}
}
?>
3
Contributors
14
Replies
34
Views
4 Years
Discussion Span
Last Post by Webville312
0

Well what's the error messages?
Turn php error reporting on if you haven't already. Is is getting through the if statements (do some echos)
are the correct number of fields being inserted into the db, are the fields in order, are they the same datatypes etc etc.

Also learn to format/indent your code properly.

Edited by iamthwee

0

It does not show any error. It just does not send the messages.
The fields are in order, and I just do not understand why it is not working.
Sorry about the code indenting thingi.

0

does $msg equal 'Login', make sure all upper lower case match.

what's happening in connect.php, is it affecting it?

why is there an empty entry after Farmer?

0

Yes, the message content is 'Login'
Farmer, is the individual who sends the text message.
The 'connect.php' includes the connection string.

When I removed the select query from the code, the message was replied. However, I want the user's details to be inserted into the database, before it is sent to the user.

0

I have isolated the problem, and I just realised that the script is unable to connect to the database.

Any more ideas ...

0

Yes, I added a checker that determines if there is a connection to the database, and I am receiving th error message. Implying that the connection to the database is not being made. Here is the code I am working with at the moment;

<?php
# PHP Responder Script
$msg = $_GET["msg"];
$sender = $_GET["sender"];
$receiver = $_GET["receiver"];
$operator = $_GET["operator"];

#$command = trim(strtolower($msg));
#
# Create response SMS messages
#
if($msg == 'Login')
{
    $link = mysql_connect('localhost','root','');
    mysql_select_db('agriculture_advisory',$link);

    if($link)
    {
        $selects = "SELECT firstName FROM authentication";
        mysql_query($selects);
        $results=mysql_query($selects);
        while($row=mysql_fetch_array($results))
        {
            $nut = $row['fistName'];
        }
        $messages = "Nutrition Tips:"."".$nut.""."THANK YOU FOR USING PATIENT MONITOR";
        #
        # Uncomment this line to send a response message
        #
        echo "{GSMSMS}{}{}{"."$sender"."}{".trim($messages)."}";
    }
    else
    {
        $message = "Unable to connect to database";
        #
        # Uncomment this line to send a response message
        #
        echo "{GSMSMS}{}{}{"."$sender"."}{".trim($message)."}";
    }
}
?>

At the moment, when I send a text message, I recieve the responce as "Unable to connect to database"
I dunno what to do ...

Edited by pritaeas: Realigned code.

0

Change 14 and 15:

$link = mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('agriculture_advisory', $link) or die(mysql_error());

Remove line 20.

0

I thought the same thing. However, when an SMS comes in, the message is logged into the database. I see that it is received; however, the script is just not sendiong out a responce ... I dunno why.

Is it something that I am missing out?? or is it my database connection?

0

I tried almost everything, but failed, so I used the crude way of inserting the message I want to send into the ozekimessage out and it seems to be responding now.

Thanx for all your comments.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.