What the heck, this is the simplest thing and I can't get it to work, I've used the onClick event a hundred times but what is it about this time??
When I call a function from a buton's onClick event I get an error in IE saying Object expected... I can't figure out what's going on here, maybe you guys can. I have some PHP in here but I'm pretty sure it's the HTML that's the problem:
<html>
<body>
<head>
<?
include('database_functions.inc');//holds the db_connect() function
db_connect('localhost','rick','','test');
function insertrow2($table,$values)
{
//setup the insert statement to be run
$query="insert into $table values ('";
foreach($values as $v)
{
$query=$query+",\'".$v."\'";
};
$query=$query+");";
$result = mysql_query($query) or die(mysql_error());
print mysql_affected_rows()." rows inserted";
}
print "<input type='button' value='insert' onclick=\"insertrow2('users','justin')\">";
mysql_close();
?>
</head>
</body>
</html>
When I call a function from a buton's onClick event I get an error in IE saying Object expected... I can't figure out what's going on here, maybe you guys can. I have some PHP in here but I'm pretty sure it's the HTML that's the problem:
<html>
<body>
<head>
<?
include('database_functions.inc');//holds the db_connect() function
db_connect('localhost','rick','','test');
function insertrow2($table,$values)
{
//setup the insert statement to be run
$query="insert into $table values ('";
foreach($values as $v)
{
$query=$query+",\'".$v."\'";
};
$query=$query+");";
$result = mysql_query($query) or die(mysql_error());
print mysql_affected_rows()." rows inserted";
}
print "<input type='button' value='insert' onclick=\"insertrow2('users','justin')\">";
mysql_close();
?>
</head>
</body>
</html>