![]() |
connect database using oop
my head.php
PHP Code:
PHP Code:
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /web/head.php on line 15 why is it myql_close() seem not functioning.im a newbie of OOP..and im tried to connect to database using OOP.just practicing |
You're getting the error because you're trying to access a property of the class ($this->conneciton) even though it has not yet been set.
Firstly, you should declare your $connection property as a member of the class: Code:
class mysql { Code:
function Connect($host, $name, $pass, $db){ |
Typed this up quickly... just an example of some things i noticed that may help you.
This is in PHP4, since that's what it looked like you were using.. But I left some comments for php5 usage. Disclaimer: I didnt actually test the code, i just typed it. but no syntax errors, and everything looks like it should work. Again, just an example. PHP Code:
|
@author of topic-
Although there's not much ACTUAL errors in your code, except the ones that the ppl above me pointed out, your code is not very nice. And eventhough my db class isn't the best, you can still check it out and see if you get any inspiration: http://www.talkphp.com/showthread.php?t=1134 |
thanks karl...the warning is gone now..and thanks dschreck for letting me understand the flow of the codes..more power guyz
|
| All times are GMT. The time now is 01:04 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0