I am working through some internet examples and was wondering how to get the below script to work... I can get the example to work just fine when separated. Please help...
This give me an error: Call to a member function on a non-object
function process_data($values){
$sql = "INSERT INTO tb_activities SET activity = '".$values["activity"]."'";
if ($result = $connector->query($insertQuery)){
echo '<center><b>Activity has been added to the database!</b></center><br>';
}else{
exit('<center>Sorry, there was an error saving the Activity to the database</center>');
}
}
This works fine:
function process_data($values){
$sql = "INSERT INTO tb_activities SET activity = '".$values["activity"]."'";
$result = mysql_query($sql);
if (!$result) {
error('A database error occurred in processing your '.
'submission.\\nIf this error persists, please '.
'contact [email]you@example.com[/email].');
} else {
echo "You did it!";
}
}
This works fine when not in the process function:
$sql = "INSERT INTO tb_activities SET activity = '".$values["activity"]."'";
if ($result = $connector->query($insertQuery)){
echo '<center><b>Activity has been added to the database!</b></center><br>';
}else{
exit('<center>Sorry, there was an error saving the Activity to the database</center>');
}