Page 1 of 1
PHP FUnction
Posted: Fri Jun 24, 2005 9:38 pm
by jackie111
i want to write my mysql connection code to a FUNCTIONS, when i need to open mysql connection, i just need to call it, how to write it? i am not familiar with php, thanks for all your help.
Jackie
Posted: Fri Jun 24, 2005 11:13 pm
by Burrito
You've come to the right place for help. But rather than hand feed it to you, I'll give you a short function sample that you can play with and learn from.
Code: Select all
function name($arg1,$arg2=TRUE){
// do whatever you want in here
mysql_connect("localhost",$arg1,$password)
or die(mysql_error();
// maybe echo something
echo "connected";
// you can return things in a function
if($arg2)
return 4+4;
}
play around with that some and do some tweaking and see what you come up with. If you need more help, you know where to find us

Posted: Sat Jun 25, 2005 9:01 am
by dethron
it seems the problem is solved

so why dont you add a [SOLVED] tag to your subject

Posted: Sat Jun 25, 2005 3:39 pm
by Ambush Commander
Word of warning, the $password variable is just hanging out there, and you're going to have to define it yourself.
Posted: Sat Jun 25, 2005 4:58 pm
by Burrito
Ambush Commander wrote:Word of warning, the $password variable is just hanging out there, and you're going to have to define it yourself.
*heh guess that's what I get for trying to make someone think things through...was trying something new here
1) in response to dethron: this isn't [SOLVED]...I'd think far from it, it's a start to try and throw some bread crumbs out to make jackie work a little bit and learn in the process.
2) in response to AC (see *)
next time I guess I'll just go back to providing more thorough answers

Posted: Sat Jun 25, 2005 8:37 pm
by jackie111
thanks so much, i will check it right now.