JackTheRussel
Programmer
Hi.
I have program where I have lots of SQL-commands.
Now I would like to write some functions because then I should't write so much code, but I have few problems.
Example. I have function like this.
And I call it here
And It works perfectly.
But how I can use this function again when I have two values like here:
THIS FUNCTION IS NOT OK ANYMORE
So what can I do ?
Can I use this function again or do I have to
give up for using functions in this case?
I have program where I have lots of SQL-commands.
Now I would like to write some functions because then I should't write so much code, but I have few problems.
Example. I have function like this.
Code:
sub delete_id {
$sth = $db_conn->prepare($sql_string);
$sth->execute($id);
$sth->finish();
}
And I call it here
Code:
$sql_string="DELETE from table where id=?";
&delete_id($id);
And It works perfectly.
But how I can use this function again when I have two values like here:
Code:
$sql_string="DELETE from table where id=? AND name=?";
&delete_id($id, $name);
THIS FUNCTION IS NOT OK ANYMORE
Code:
sub delete_id {
$sth = $db_conn->prepare($sql_string);
$sth->execute($id); #Missing $name
$sth->finish();
}
So what can I do ?
Can I use this function again or do I have to
give up for using functions in this case?