Really Basic Php Scripting Question

liunx

Guest
This should be a simple question for anyone with an understanding of php, but the answer is eluding me... <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/ph34r.gif" style="vertical-align:middle" emoid=":ph34r:" border="0" alt="ph34r.gif" /> <br /><br />I am installing SMePoll, which is a really simple script for polling on a Web site. I'm all set up with it. The poll appears on a page called vote.php.<br /><br />I want to place this poll on my index page. So how do I include the script located in a file called vote.php on my index page? <br /><br />Obviously my index page needs to be a .php page. I do know that much <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />What line of php code do I use on my index page to call up vote.php and insert the content (i.e. polling box) into that place on my index page?<br /><br />Any help would be appreciated!! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/notworthy.gif" style="vertical-align:middle" emoid=":notworthy:" border="0" alt="notworthy.gif" /><!--content-->
Hello TOWebstress,<br />what you would need to do is use a include statement like this one <br />You would copy this line into your index.php file where you want the poll to appear. <br />Change where it says YOUR_PATH to the location of your vote file <br />if it is in a folder under the public_html folder <br />if not simple remove the YOUR_PATH/ from the line and you should be good to go <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?php include $_SERVER['DOCUMENT_ROOT']."YOUR_PATH/vote.php"; ?><!--c2--></div><!--ec2--><br /><br /><br />let us know if you need help<br /><br />RobertM<!--content-->
Wow, you're fast! Thank you very much Robert!<br /><br />I wasn't too far off in my attempts, actually. Your code did successfully link it, but I'm still having problems. The vote.php is dependent upon a couple other files (ip.txt and data.txt) and it can't seem to find those. It gives me lines of error that say:<br /><br />Warning: file(ip.txt): failed to open stream: No such file or directory in /home/[myaccountname]/public_html/poll2/vote.php on line 35<br /><br />Warning: Invalid argument supplied for foreach() in /home/[myaccountname]/public_html/poll2/vote.php on line 37<br /><br />Warning: file(data.txt): failed to open stream: No such file or directory in /home/[myaccountname]/public_html/poll2/vote.php on line 67<br /><br />Would it matter that the index page that I'm going to put this on is in a secured section of my site? That is, the index page is password-protected, but the polling script pages are not.<br /><br />Thank you very much again!!!<!--content-->
TOWebstress, <br />can you send me the script via message if you do not want to post it here? <br /><br />Also did you veryify that that path to those files are correct ?<br /><br />and third if you can send a link that would help as well <br /><br /><br />RobertM<!--content-->
Hi <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> <br /><br />You might also create an index.html page in an unprotected folder and try it to verify that the probem is the with the protected folder.<br />And if the poll can see the needed files.<br />This will tell you if the files need to be in the same folder or below it.<!--content-->
 
Back
Top