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
PHP FUnction
Moderator: General Moderators
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.
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 
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;
}- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
*heh guess that's what I get for trying to make someone think things through...was trying something new hereAmbush Commander wrote:Word of warning, the $password variable is just hanging out there, and you're going to have to define it yourself.
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