Forums
This topic is locked
PHP User Comments System
Posted 10 Feb 2008 10:55:57
1
has voted
10 Feb 2008 10:55:57 Aaron Rossiter posted:
I followed the User Comments tutorial to the letter. I've searched everything and can't find a solution. When I tested to see if the add comments table would come up in a page I received the following error message:Warning: require_once(\home\MyUserName\public_html\includes\dbConnection.php) [function.require-once]: failed to open stream: No such file or directory in /home/MyUserName/public_html/TheRefsBlog.php on line 214
Fatal error: require_once() [function.require]: Failed opening required '\home\MyUserName\public_html\includes\dbConnection.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/MyUserName/public_html/TheRefsBlog.php on line 214
I guess I'm not even getting to the dbConnection file but I see nothing wrong with the code pointing to it. Any suggestions? If there are no specific suggestions just a few possible reasons for this error message would be a big help.
Replies
Replied 10 Feb 2008 16:07:08
10 Feb 2008 16:07:08 Alan C replied:
Hi Aaron,
I've had issues with DW putting in a line that starts Virtual . . .
in some cases that doesn't work and I get an error message, it works if I change the Virtual to include
something else I just thought of - have you actually uploaded the connections folder, that's something else that I've missed doing <img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>
I've had issues with DW putting in a line that starts Virtual . . .
in some cases that doesn't work and I get an error message, it works if I change the Virtual to include
something else I just thought of - have you actually uploaded the connections folder, that's something else that I've missed doing <img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>
Replied 11 Feb 2008 07:29:15
11 Feb 2008 07:29:15 Aaron Rossiter replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi Aaron,
I've had issues with DW putting in a line that starts Virtual . . .
in some cases that doesn't work and I get an error message, it works if I change the Virtual to include
something else I just thought of - have you actually uploaded the connections folder, that's something else that I've missed doing <img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I tried your suggestions. No luck. I had already uploaded the connections folder. The tutorial instructed the reader to insert the following code to link to the connections folder:
<?php require_once("C:\webserver\includes\dbConnection.php" ?>
I modified that to conform to my server. Changed it to ("home\MyUserName\public_html\includes\dbConnection.php" ?>. It should work but it's not. I did delete all html in the new Dreamweaver php file before writing the dbConnection file. I also checked the link provided in the tutorial to download code and the link took me to a page of ads. Is the tutorial possibly unreliable? Here's the link to the download code.
www.garethdp.com/writing/articles/dmxzone/code/usercomments/
Any suggestions are appreciated. If someone knows of another way to add user comments to more than just one page of my website, specific to each page, I would appreciate that too.
Hi Aaron,
I've had issues with DW putting in a line that starts Virtual . . .
in some cases that doesn't work and I get an error message, it works if I change the Virtual to include
something else I just thought of - have you actually uploaded the connections folder, that's something else that I've missed doing <img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
I tried your suggestions. No luck. I had already uploaded the connections folder. The tutorial instructed the reader to insert the following code to link to the connections folder:
<?php require_once("C:\webserver\includes\dbConnection.php" ?>
I modified that to conform to my server. Changed it to ("home\MyUserName\public_html\includes\dbConnection.php" ?>. It should work but it's not. I did delete all html in the new Dreamweaver php file before writing the dbConnection file. I also checked the link provided in the tutorial to download code and the link took me to a page of ads. Is the tutorial possibly unreliable? Here's the link to the download code.
www.garethdp.com/writing/articles/dmxzone/code/usercomments/
Any suggestions are appreciated. If someone knows of another way to add user comments to more than just one page of my website, specific to each page, I would appreciate that too.
Replied 11 Feb 2008 18:16:27
11 Feb 2008 18:16:27 Alan C replied:
Hello again,
had a look at that link but it looked line something else, maybe a search . . .
anyway I think this might be a path issue,
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> <?php require_once("C:\webserver\includes\dbConnection.php" ?>
I modified that to conform to my server. Changed it to ("home\MyUserName\public_html\includes\dbConnection.php" ?>.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
this sounds like my problem when accessing files from php, sometimes you need the full path and others you need the www path - by that I mean the full path is what you have in your example, whereas the www path (my name for it) is the path from the root of your site, so in this instance it would be just /includes/dbConnections.php
another thought, you can get to your files by 'relative' addressing too, so, let's say you script that is executing is in /my_script.php
to get to /includes/dbConnections.php you could ask for ../includes/dbConnections.php
the .. takes you up a level of directory, then /includes takes you into that directory - can get messy, much better to use addresses from the site route, BUT in some cases your hosting package may restrict you from doing that, which is what happens on my server, I have to put the relative paths in the include statements, if you are still having issues after trying that I'll dig out some actual code that works and post it, I'm on a pc at the moment and all my development stuff is on my mac so i'd have to re-type it <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
I had great problems sorting out the path for functions such as getimageszie() and eventually got my head around it, now I have a little bit of code at the head of the script that works out the full path and www path and keeps them handy.
Edited by - sitemaster on 11 Feb 2008 18:22:21
had a look at that link but it looked line something else, maybe a search . . .
anyway I think this might be a path issue,
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> <?php require_once("C:\webserver\includes\dbConnection.php" ?>
I modified that to conform to my server. Changed it to ("home\MyUserName\public_html\includes\dbConnection.php" ?>.<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
this sounds like my problem when accessing files from php, sometimes you need the full path and others you need the www path - by that I mean the full path is what you have in your example, whereas the www path (my name for it) is the path from the root of your site, so in this instance it would be just /includes/dbConnections.php
another thought, you can get to your files by 'relative' addressing too, so, let's say you script that is executing is in /my_script.php
to get to /includes/dbConnections.php you could ask for ../includes/dbConnections.php
the .. takes you up a level of directory, then /includes takes you into that directory - can get messy, much better to use addresses from the site route, BUT in some cases your hosting package may restrict you from doing that, which is what happens on my server, I have to put the relative paths in the include statements, if you are still having issues after trying that I'll dig out some actual code that works and post it, I'm on a pc at the moment and all my development stuff is on my mac so i'd have to re-type it <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
I had great problems sorting out the path for functions such as getimageszie() and eventually got my head around it, now I have a little bit of code at the head of the script that works out the full path and www path and keeps them handy.
Edited by - sitemaster on 11 Feb 2008 18:22:21