Reputation: 2377
Right now I have this:
session_start()
$_SESSION['title'] = $_POST['title'];
I store a variable from jquery to be preserved in the php session, my question now is ...using mysql_query()...how would I store the SESSION variable in the database? I've been trying to find out a proper way to do this without getting an empty value
the full query:
mysql_query("INSERT INTO titles (content, type, url, title)
VALUES ('$content','7',$url',".mysql_real_escape_string($_SESSION['title'])."')");
here is the jquery :
var title = $(".hidden").text();
$.post("tosqltwo.php", { title: title} );
var url = $(".hide").text();
$(".button").click(function() {
var content = $(this).siblings().outerHTML();
$.ajax({
type: "POST",
url: "tosqltwo.php",
data: {
content: content, url: url
}
});
});
I am able to get the content, url and type. The title remains empty
Upvotes: 0
Views: 760
Reputation: 50982
You can store session variable like any other variable, as zerkms said
mysql_query("INSERT INTO titles (title) VALUES ('".mysql_real_escape_string($_SESSION['title'])."')");
in your case
mysql_query("INSERT INTO titles (content, type, url, title) VALUES ('".mysql_real_escape_string($content)."','7','".mysql_real_escape_string($url)','".mysql_real_escape_string($_SESSION['title'])."')");
Upvotes: 2