944,135 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 475
  • PHP RSS
Nov 9th, 2009
0

php classes

Expand Post »
i have a class called sqlConn.php within the same directory as hiuser.php
how do i call that class.

PHP Syntax (Toggle Plain Text)
  1. include('sql_Conn.php');
  2.  
  3. $sql = new sql_Conn;
does not work i get

Warning: include(sql_Conn.php) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 10

Warning: include() [function.include]: Failed opening 'sql_Conn.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 10

Fatal error: Class 'sql_Conn' not found in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 12
Similar Threads
Reputation Points: 7
Solved Threads: 0
Junior Poster
mrjoli021 is offline Offline
170 posts
since Mar 2007
Nov 9th, 2009
0
Re: php classes
Click to Expand / Collapse  Quote originally posted by mrjoli021 ...
i have a class called sqlConn.php within the same directory as hiuser.php
how do i call that class.

PHP Syntax (Toggle Plain Text)
  1. include('sql_Conn.php');
  2.  
  3. $sql = new sql_Conn;
does not work i get

Warning: include(sql_Conn.php) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 10

Warning: include() [function.include]: Failed opening 'sql_Conn.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 10

Fatal error: Class 'sql_Conn' not found in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 12
is the file sql_Conn.php in the same directory as the file you are including it from? Also check that you have not inadvertantly made an error in the filename of the physical file in the directory. 1 more thing is it is not a good idea to have upper case letters in filenames as some servers are case sensitive and others are not and PHP will always check the case you ask it too
Last edited by leviathan185; Nov 9th, 2009 at 6:17 pm.
Reputation Points: 19
Solved Threads: 15
Junior Poster
leviathan185 is offline Offline
105 posts
since May 2009
Nov 10th, 2009
0
Re: php classes
hey u mentioned ur file name to be sqlConn.php and in include statement u r calling sql_Conn.php Is it a typo or may b this is the source of ur error
You need to include the file with same name... though u can create an object for that class with the name u desire
PHP Syntax (Toggle Plain Text)
  1. include('sqlConn.php');
  2.  
  3. $sql = new sql_Conn; // assuming the name of class in that file to be sql_Conn
This should work..


Click to Expand / Collapse  Quote originally posted by mrjoli021 ...
i have a class called sqlConn.php within the same directory as hiuser.php
how do i call that class.

PHP Syntax (Toggle Plain Text)
  1. include('sql_Conn.php');
  2.  
  3. $sql = new sql_Conn;
does not work i get

Warning: include(sql_Conn.php) [function.include]: failed to open stream: No such file or directory in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 10

Warning: include() [function.include]: Failed opening 'sql_Conn.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5/lib/php') in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 10

Fatal error: Class 'sql_Conn' not found in /Applications/MAMP/htdocs/TestSite/hiUser.php on line 12
Last edited by venkat0904; Nov 10th, 2009 at 1:26 am.
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009

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: Newbie question: PHP form not writing to MySQL database
Next Thread in PHP Forum Timeline: PHP-MySQL Upload Videos to Remote folder





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


Follow us on Twitter


© 2011 DaniWeb® LLC