plutomed Posted August 12, 2007 Share Posted August 12, 2007 Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /home/plutomed/public_html/new/functions.php on line 20 Here is my function that connects: function connect_db($user, $pass, $db) { $con = mysql_connect("localhost", $user, $pass) or die(mysql_error()); $db_selected = mysql_select_db($db) or die(mysql_error()); } And the query function: function referer() { connect_db("uname", "pass", "db"); //query mysql_close($con); } Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/ Share on other sites More sharing options...
NArc0t1c Posted August 12, 2007 Share Posted August 12, 2007 What exactly is " this " ? Try putting the function as an variable. Explanation: function referer() { $connect = connect_db("uname", "pass", "db"); //query mysql_close($connect); } Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321703 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Author Share Posted August 12, 2007 Nope that didn't work and all I am doing is changing my site a bit Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321706 Share on other sites More sharing options...
chocopi Posted August 12, 2007 Share Posted August 12, 2007 is it because you have $con in a different function and it isnt carried over to the other function unless you set it to a gobal. this is just a guess seeing as I don't like functions so I don't use them ~ Chocopi Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321712 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Author Share Posted August 12, 2007 How do ya set it to global? Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321732 Share on other sites More sharing options...
cooldude832 Posted August 12, 2007 Share Posted August 12, 2007 why close it if you might run more queries on the page? Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321737 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Author Share Posted August 12, 2007 Good point I guess I'm just used to doing it Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321741 Share on other sites More sharing options...
cooldude832 Posted August 12, 2007 Share Posted August 12, 2007 good idea is on the end of a page make a function called endofpage and basicaly close up everything in it. Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321744 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Author Share Posted August 12, 2007 Brill. idea thanx Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321747 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Author Share Posted August 12, 2007 I was going to create the function end(); but I noticed it is already used is there anyway I could use it still? Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321749 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Author Share Posted August 12, 2007 Can you? Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321889 Share on other sites More sharing options...
teng84 Posted August 12, 2007 Share Posted August 12, 2007 you can you use it as many times you want but yo cant create as many times you want Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321893 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Author Share Posted August 12, 2007 end(); is a predefined function, can I still create my one function called end like this: function end() { //code } Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321894 Share on other sites More sharing options...
teng84 Posted August 12, 2007 Share Posted August 12, 2007 i told you if there is an existing function user or predefine u cant recreate it Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321895 Share on other sites More sharing options...
plutomed Posted August 12, 2007 Author Share Posted August 12, 2007 Oh ok thanx Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321924 Share on other sites More sharing options...
teng84 Posted August 12, 2007 Share Posted August 12, 2007 Quote Link to comment https://forums.phpfreaks.com/topic/64538-solved-warning-mysql_close-supplied-argument/#findComment-321925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.