Hey guys, Trying to do something is very simple: pass 2 text variables to a php script and paste them into MySQL db. For some reason, however, I cannot pass variables (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 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 who wants to take a quick look at him and point out my obvious mistake? It turned me on for a day!
Thank!
source
share