javascript and php and Database

admin

Administrator
Staff member
I am able to assign the value of a javascript variable to a php variable by doing the following:

var tempID = document.form1.name1.value;
var variable1 = document.form1.name2.value;
var query = "UPDATE tablename set Column1 = '"+variable1+"' where ID = '"+tempID+"'";
<?$ID=tempID?>
<?$var1=variable1?>
<?$q=query?>


I can output the values of $ID and $var and $q by doing the following:

document.write(<?=$ID?>);
document.write("<br>");
document.write(<?=$var1?>);
document.write("<br>");
document.write(<?=q?>);


The above works. The problem is that I want to run a query using mysql_query($q) but nothing happens.

Has anyone had success in being able to access a database. I have tried to include the connection file I use in my normal php file like:


include "dbconnect.php";


Does anyone have any suggestions?

Mike@spb
 
Back
Top