I am trying to do something very simple: Pass 2 text variables to a php script and insert them into a MySQL db. For some reason however I can’t get the variables to pass (so I just get empty records in my DB).
function ajaxCall(){
$.ajax({
type: "GET",
url: "http://www.*.be/bubblingAjax.php",
cache: false,
data: "colour="+colour+"&size="+size,
dataType: "html",
success: onSuccess
});
return false;
};
And the PHP:
<?php
try
{
$connection = mysql_connect("#");
mysql_select_db("#");
$colour = mysql_real_escape_string($_GET['colour']);
$size = mysql_real_escape_string($_GET['size']);
mysql_query("INSERT INTO bubble (colour, size) VALUES ('$colour', '$size')");
mysql_close($connection);
echo "SUCCESS";
echo $colour;
echo $size;
}
catch(Exception $e)
{
echo $e->getMessage();
}
?>
Anyone willing to take a quick look at it and point out my -probably obvious- mistake? It’s been driving me nuts for over a day.
This has to work:
and the PHP (only changed get to post)
Also to debug, I would suggest using firebug or chrome’s build in inspect tools.