Storing javascript variable in php

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Rosarie
Forum Newbie
Posts: 1
Joined: Tue Mar 09, 2004 6:38 am

Storing javascript variable in php

Post by Rosarie »

Hi, I'm wondering is it possible to store a javascript variable in php? I need to store the global variable 'realCount' into my database - is the php able to recognise the javascript variable or should I change it?? Thanks

if (realCount<9)
{
var str="";
for(i=0;i<numMoves;++i)
{
if (i) str+=",";
str+=histo;

<?
$dbHost = "******";
$dbUser = "rmh2";
$dbPass = "******";
$dbDatabase = "2004_solitaire";

// Connect to DB

$li = mysql_connect($dbHost, $dbUser, $dbPass) or die("Could not connect");
mysql_select_db($dbDatabase, $li) or die ("could not select DB");

$scores_str = ""; // $scores_str is the string to append entries to

$boardtype = "English 12";
$score = realCount;
$bestscore = "7";
$names = "";

$scores_query = "insert into scores
values('$boardtype', '$score', '$bestscore', 0)";


mysql_query($scores_query);
$res = mysql_affected_rows();

// Close MySQL Connection
mysql_close($li);



?>
}
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Rememer: all JavaScript is done on client-side and all PHP is done on server-side. I suggest you to read the Frames, JavaScript, and PHP Overview tutorial.

Regards,
Scorphus.
Post Reply