Jetmatt777 Posted February 2, 2008 Share Posted February 2, 2008 Okay. I am not the greatest nor smartest at PHP, I'm a n00b at it basically. I threw this code together to write contents to a file:HTML page to input data: <head><script language="javascript">function First() {document.getElementById("2").disableddocument.getElementById("2").checked=false }function Second() {document.getElementById("1").disableddocument.getElementById("1").checked=false }</script></head><form action='add_verse_compile.php' method="post">Book: <SELECT name='book'> <OPTION value=''>--Select--</OPTION> <OPTION value='Genesis'>Genesis</OPTION> </SELECT><br>Chapter: <input type='text' name='chapter' maxlength='3' size='2'><br>Verse: <input type='text' name='verse_num' maxlength='3' size='2'><br>Verse Contents: <br><textarea name='verse' rows='5' cols'45'></textarea><br>First Verse of Chapter <input type='checkbox' name='type' onclick='First()' id='1'>Last Verse of Chapter <input type='checkbox' name='type' id='2' onclick='Second()'><br><input type='submit' value='Add Verse'></form> PHP Page to compile/write to the .txt file( I know I'm inserting HTMl into the txt file, but I use these files in a php include so it doesn't matter, the HTML goes through and is outputted as normal HTML) <?php $book = $_POST['book']; $chapter = $_POST['chapter']; $verseid = $_POST['verse_num']; $versecontents = $_POST['verse'] $beg = $_POST['beg']; $end = $_POST['end']; $txt = $book ."/". $chapter ."/". $verseid .".txt" $file = fopen("$txt","w+");echo fwrite($file,"<h4>$beg</h4><br>$versecontents<br>$end<br><a href='#' onclick='Prev()'>Previous Verse</a> <a href='#' onclick='Next()'>Next Verse</a>");fclose($file);?><?php echo $_POST['book']?> <?php echo $_POST['chapter']?>:<?php echo $_POST['verse_num']?> was successfully added to the database. When I load the php script, all I get is a blank page, nothing, not a PHP error, just a blank page. Please Help me.-Matt Link to comment Share on other sites More sharing options...
jhecht Posted February 3, 2008 Share Posted February 3, 2008 At the very top of the page add this line :error_reporting(E_ALL); Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 3, 2008 Author Share Posted February 3, 2008 Still doesn't work....Blank Page Link to comment Share on other sites More sharing options...
jhecht Posted February 3, 2008 Share Posted February 3, 2008 There's nothing immediately wrong with your code, from what I see, although you may want to change your code a bit. $book = $_POST['book']; $chapter = $_POST['chapter']; $verseid = $_POST['verse_num']; $versecontents = $_POST['verse'] $beg = $_POST['beg']; $end = $_POST['end']; $txt = $book ."/". $chapter ."/". $verseid .".txt" $file = fopen("$txt","w+");echo fwrite($file,"<h4>$beg</h4><br>$versecontents<br>$end<br><a href='#'onclick='Prev()'>Previous Verse</a> <a href='#' onclick='Next()'>NextVerse</a>");fclose($file);php echo $_POST['book'].' ,'.$_POST['chapter'].":".$_POST['verse_num']?> By the way, if you're using php 5.0 or greater, use file_get_contents() and file_put_contents(), it's much easier.oh and before the error_reporting, try this(becuase its entirely possible your host disabled this) ini_set('display_errors','1');error_reporting(E_ALL) Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 3, 2008 Author Share Posted February 3, 2008 Thanks for your help, but none of that worked, I still get a blank page. Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 3, 2008 Author Share Posted February 3, 2008 I just found out my host switched to php5.0, so I'll use put_contents and see if it works. Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 3, 2008 Author Share Posted February 3, 2008 no joy on file_put_contents()Any other suggestions? Link to comment Share on other sites More sharing options...
jhecht Posted February 3, 2008 Share Posted February 3, 2008 time to debug, bout the only thing that I can say. Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 4, 2008 Author Share Posted February 4, 2008 I don't know how to de-bug, if it comes with somesort of editor than I am out of luck. Notepad only for me.-Matt Link to comment Share on other sites More sharing options...
jhecht Posted February 4, 2008 Share Posted February 4, 2008 Basically after every function call put this after the ending parentheses, but before the semi colon:OR die('Error message for you to see here'); Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 4, 2008 Author Share Posted February 4, 2008 Still get blank page, here's what I did: <html><head></head><body><?php ini_set('display_errors','1');error_reporting(E_ALL);$book = $_POST['book']; $chapter = $_POST['chapter']; $verseid = $_POST['verse_num']; $versecontents = $_POST['verse']; $beg = $_POST['beg']; $end = $_POST['end']; $txt = "http://websiteurl.com/directory/". $book ."/". $chapter ."/". $verseid .".txt" $file = fopen("$txt","w+") OR die("Couldn't open file");echo file_put_contents($file,"<h4>$beg</h4><br>$versecontents<br>$end<br><a href='#'onclick='Prev()'>Previous Verse</a> <a href='#' onclick='Next()'>NextVerse</a>") OR die("Couldn't write to file");fclose($file) OR die("Couldn't close file");?></body></html> Still getting blank page, no error messages Link to comment Share on other sites More sharing options...
jhecht Posted February 4, 2008 Share Posted February 4, 2008 get rid of the HTML before everything, and just put <?php echo "PHP working";?> Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 4, 2008 Author Share Posted February 4, 2008 PHP works Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 4, 2008 Author Share Posted February 4, 2008 Okay, just finally got a page full of error messages:Atleast it is something, I guess it took half a day for the server to update?It says on one of them that [function.fopen] is disabled in the webserver configuration. well, I need a new host then.-Matt Link to comment Share on other sites More sharing options...
jhecht Posted February 4, 2008 Share Posted February 4, 2008 Well the only thing i could think of would be if you started doing things one line at a time. you know, rebuild the page from the beginning, then, after every line echo out the result. Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 4, 2008 Author Share Posted February 4, 2008 Do you know another function to bypass fopen? Link to comment Share on other sites More sharing options...
jhecht Posted February 4, 2008 Share Posted February 4, 2008 I do, but if fopen isn't allowed, then this function won't be either. Link to comment Share on other sites More sharing options...
Jetmatt777 Posted February 4, 2008 Author Share Posted February 4, 2008 Can I atleast try it? Link to comment Share on other sites More sharing options...
jhecht Posted February 4, 2008 Share Posted February 4, 2008 Like I said, doubt it'll work, but herehttp://us2.php.net/manual/en/function.fsockopen.php Link to comment Share on other sites More sharing options...
justsomeguy Posted February 4, 2008 Share Posted February 4, 2008 You can find out which functions are disabled with this:echo ini_get('disable_functions');It will be a comma-separated list of function names. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.