Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object expected while calling a function from onClick???

Status
Not open for further replies.

SuaveRick

Programmer
Apr 12, 2004
142
CA
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>
 
Don't post the same question in multiple forums! Look at your post in the PHP forum for the answer.

Lee
 
My bad Lee, I was unsure where to post it so I thought I post is in both places.

Thanks for the reply, this can be deleted if a mod comes accross it.
 
SuaveRick
Just click on the <Inappropriate post?
If so, Red Flag it!> link at the bottom of your first post and ask management to delete the thread

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top