max_
max_

Reputation: 24481

PHP MySQL Query not working

I have a form made in js by my developer, and I have implemented a function where I am sent an email, and the input data from the form is put into a mysql query and then into my database. However the database query doesn't work in the method, neither does any echos or anything. By this I mean that the query is not run, and no echos show up on the page containing this code.

Please can you tell me what is causing this?

Here is the process() method where the error is occuring:

    function process()
    {
       echo "hi";
        $device = mysql_real_escape_string($_POST['Device_Type']);
        $name = mysql_real_escape_string($_POST['Name']);
        $job = mysql_real_escape_string($_POST['DD']);
        $username = mysql_real_escape_string($_POST['Username']);
        $email = mysql_real_escape_string($_POST['Email']);
        $website = $_POST['Website']);
        $UDID = mysql_real_escape_string($_POST['UDID']);
        mysql_connect("localhost", "...", "...");
        mysql_select_db("...");
        mysql_query("INSERT INTO Beta_Testers (`Name`, `Username`, `Email Address`, `Website`, `Job`, `Device_Type`, `UDID`) VALUES ('$name','$username','$email','$website','$job','$device','$UDID')") or die(mysql_error());   
          $msg = "Form Contents: \n\n";
          foreach($this->fields as $key => $field)
                $msg .= "$key :  $field \n ";
          $to = '';
          $subject = 'Beta Form Submission';
          $from = 'Beta Sign up';
          mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");   
       }

Upvotes: 0

Views: 323

Answers (1)

Jon Gauthier
Jon Gauthier

Reputation: 25572

Check the line with $website. You have an extra parenthesis on the end (or perhaps, a missing mysql_real_escape call on the other side).

To check for syntax errors like this in the future, run php -l myfile.php on the command line. Or, during development and testing, make sure you have error_reporting and display_errors configured correctly so that these syntax errors are displayed in the script's output.

Upvotes: 2

Related Questions