user516883
user516883

Reputation: 9388

Calling stored procedure in mysql in PHP script

I have a php script that is being called by an ajax post. I am getting the error
Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\Escape\SendTestimony.php on line 9

Here is the paramaters

$name = $_POST['name'];   

$message = $_POST['message'];

Here is line 9 where the error occurs. Thanks for any help.

mysql_query("CALL sp_CreateTestimony("$name.", "$message.")");

EDIT ADDED JQUERY AJAX CALL

 var parameters = {
                    'name': $('#cf_name').val(),
                    'message': $('#cf_message').val()
                }; //Use JSON to pass parameters into ajax calls  
                parameters = JSON.stringify(parameters); 


                //Make ajax call to post to database
                $.ajax({
                    type: 'POST',
                    url: '../Escape/SendTestimony.php',
                    datatype: 'json',
                    data: parameters,
                    success: function (result) {
                    alert(result);
                        $('#ValidateTest').html('Thank-you!').css({ 'color': 'green' }).show();
                    },
                    error: function(jqXHR, textStatus, errorThrown) {alert(textStatus + ":" + errorThrown);}
                });

Upvotes: 1

Views: 1842

Answers (2)

Roman
Roman

Reputation: 3843

you should add dots before variables and single quotes around them:

mysql_query("CALL sp_CreateTestimony('".$name."', '".$message."')");

Upvotes: 3

user516883
user516883

Reputation: 9388

stringify was the problem. I removed that and it fix the problem.

Upvotes: 0

Related Questions