944,210 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 485
  • PHP RSS
Oct 5th, 2009
0

Connecting to a mysql database through a class

Expand Post »
I have done this a million times before.
I dont understand why this is not working through the use of a class.
It is telling me that the variable is "undefined" hence contains a NULL value which is a load of *((^&$#.
Anyways my code(sections of it) is below, any help much appreciated.
php Syntax (Toggle Plain Text)
  1. private con;
  2. $this->con = mysql_connect(server, name, pass);

Obviously the initialization statement is in a method which is called via the constructor. Now something is wrong when it plan as day that con is being given a value, I dont understand why it saying it is not. Anyways any idea where to look and how to fix much appreciated.

Thanks, Regards X
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
Oct 6th, 2009
0
Re: Connecting to a mysql database through a class
ps:
PHP Syntax (Toggle Plain Text)
  1. private $con;
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
Oct 6th, 2009
1
Re: Connecting to a mysql database through a class
How about adding a die statement to assist in debugging like so
php Syntax (Toggle Plain Text)
  1. $this->con=mysql_connect($server,$name,$pass) or die(mysql_error());

happy times!
Reputation Points: 11
Solved Threads: 18
Junior Poster
sureronald is offline Offline
139 posts
since May 2008
Oct 6th, 2009
-1
Re: Connecting to a mysql database through a class
I think I have figured out the problem while away from the computer.
I think it has to do using the mysql_connect within classes.
Anyone got any examples? Thanks, Regards X

PS: Ill test that when I get back to my computer, thanks.
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
Oct 6th, 2009
0
Re: Connecting to a mysql database through a class
Someone needs to create a decent php debugger! SOLVED!
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: php gd functions are missing
Next Thread in PHP Forum Timeline: Interactive Timetable - Assign timeslots





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC