Connecting to a mysql database through a class

Thread Solved

Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster

Connecting to a mysql database through a class

 
0
  #1
Oct 5th, 2009
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.
  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
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster
 
0
  #2
Oct 6th, 2009
ps:
  1. private $con;
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 97
Reputation: sureronald is an unknown quantity at this point 
Solved Threads: 16
sureronald sureronald is offline Offline
Junior Poster in Training
 
1
  #3
Oct 6th, 2009
How about adding a die statement to assist in debugging like so
  1. $this->con=mysql_connect($server,$name,$pass) or die(mysql_error());

happy times!
Catch me here!
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster
 
-1
  #4
Oct 6th, 2009
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.
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 609
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster
 
0
  #5
Oct 6th, 2009
Someone needs to create a decent php debugger! SOLVED!
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC