datalee100 Posted December 31, 2007 Share Posted December 31, 2007 Below is the snippet of coding that I am working with. // Fetch and Display the Results from the Database $result = mysql_query("select name, email, v_comment from guest_book ORDER BY id",$dbi); while ($myrow = mysql_fetch_array($result)) { echo "<b>name:</b> $myrow[0]<br> <b>email: </b>$myrow[1]<br> <b>message:</b> $myrow[3] <br><br><hr><br><br>"; } <form name="form1" method="post" action="store_comment.php"> Your Name: <input name="name" type="text" size="15"><br> Your Email ID: <input name="email" type="text" size="15"> Comments : <textarea name="comments" cols="15" rows="3"></textarea> <input type="submit" name="Submit" value="Submit"></form> ?> The first echo calls from the database and displays that- that's working fine. Whenever I try to echo the next part, it gets all weird and parses out on me. The form variables seem to mess with the echoing. In the middle of this php code, what should I do to echo to keep this from parsing and get everything shown? Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/ Share on other sites More sharing options...
MadTechie Posted December 31, 2007 Share Posted December 31, 2007 your not echoing it at all! try <?php // Fetch and Display the Results from the Database $result = mysql_query("select name, email, v_comment from guest_book ORDER BY id",$dbi); while ($myrow = mysql_fetch_array($result)) { echo "<b>name:</b> $myrow[0]<br> <b>email: </b>$myrow[1]<br> <b>message:</b> $myrow[3] <br><br><hr><br><br>"; } echo '<form name="form1" method="post" action="store_comment.php"> Your Name: <input name="name" type="text" size="15"><br> Your Email ID: <input name="email" type="text" size="15"> Comments : <textarea name="comments" cols="15" rows="3"></textarea> <input type="submit" name="Submit" value="Submit"></form>'; ?> or <?php // Fetch and Display the Results from the Database $result = mysql_query("select name, email, v_comment from guest_book ORDER BY id",$dbi); while ($myrow = mysql_fetch_array($result)) { echo "<b>name:</b> $myrow[0]<br> <b>email: </b>$myrow[1]<br> <b>message:</b> $myrow[3] <br><br><hr><br><br>"; } echo "<form name=\"form1\" method=\"post\" action=\"store_comment.php\"> Your Name: <input name=\"name\" type=\"text\" size=\"15\"><br> Your Email ID: <input name=\"email\" type=\"text\" size=\"15\"> Comments : <textarea name=\"comments\" cols=\"15\" rows=\"3\"></textarea> <input type=\"submit\" name=\"Submit\" value=\"Submit\"></form>"; ?> or <?php // Fetch and Display the Results from the Database $result = mysql_query("select name, email, v_comment from guest_book ORDER BY id",$dbi); while ($myrow = mysql_fetch_array($result)) { echo "<b>name:</b> $myrow[0]<br> <b>email: </b>$myrow[1]<br> <b>message:</b> $myrow[3] <br><br><hr><br><br>"; } ?> <form name="form1" method="post" action="store_comment.php"> Your Name: <input name="name" type="text" size="15"><br> Your Email ID: <input name="email" type="text" size="15"> Comments : <textarea name="comments" cols="15" rows="3"></textarea> <input type="submit" name="Submit" value="Submit"></form> <?php //....other code ?> Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-426419 Share on other sites More sharing options...
datalee100 Posted January 2, 2008 Author Share Posted January 2, 2008 Thanks... I think it worked- something odd is wrong with the page but I'm checking something else out... Another error though: Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/www/terrify.awardspace.com/store_comment.php on line 31 On and around that line is the following code: //Check if a name & comment have been entered if ($name=="") { die " Please go back and enter you name."; } if ($comment=="") { die " You never entered a comment..."; } What is wrong now? Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-427888 Share on other sites More sharing options...
Malevolence Posted January 2, 2008 Share Posted January 2, 2008 Shouldn't it be: if ($name==null) { die " Please go back and enter you name."; } if ($comment==null) { die " You never entered a comment..."; } I'm rookie at this stuff but I'm pretty sure that's correct. Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-427910 Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2008 Share Posted January 2, 2008 it should be <?php if ($name=="") { die (" Please go back and enter you name."); } if ($comment=="") { die (" You never entered a comment..."); } ?> die is a function you have to use parentess Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-427934 Share on other sites More sharing options...
datalee100 Posted January 2, 2008 Author Share Posted January 2, 2008 Thanks for that... I'm relatively new to coding, so I guess I'm learning a bunch from this project. I hope this'll be the last one: Parse error: parse error, unexpected '/' in /home/www/terrify.awardspace.com/store_comment.php on line 45 echo "<center> Your comment has been added to the system. Congratulations!<br> Click <a href="./guestbook.php">HERE</a> to return to the Guestbook."; Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428607 Share on other sites More sharing options...
hitman6003 Posted January 2, 2008 Share Posted January 2, 2008 you have to escape double quotes inside of double quotes: echo "... <a href=\"./guestbook.php\" ..."; Or wrap the whole thing in single quotes rather than double: echo '<center> Your comment has been added to the system. Congratulations!<br> Click <a href="./guestbook.php">HERE</a> to return to the Guestbook.'; Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428614 Share on other sites More sharing options...
datalee100 Posted January 2, 2008 Author Share Posted January 2, 2008 I didn't think that this would be an issue.... I've written a file require in many different ways and all of them work exept this one. When I say: require 'ROOT./config.php'; I get: Warning: main(ROOT./config.php): failed to open stream: No such file or directory in /home/www/terrify.awardspace.com/store_comment.php on line 18 Fatal error: main(): Failed opening required 'ROOT./config.php' (include_path='.:/usr/local/php4/share/pear') in /home/www/terrify.awardspace.com/store_comment.php on line 18 When I say: require './config.php'; I get: Not allowed to run this file directly. Last, I have it like this in the file that DOES work: require ROOT.'config.php'; But I'm still getting this: Warning: main(ROOTconfig.php): failed to open stream: No such file or directory in /home/www/terrify.awardspace.com/store_comment.php on line 18 Fatal error: main(): Failed opening required 'ROOTconfig.php' (include_path='.:/usr/local/php4/share/pear') in /home/www/terrify.awardspace.com/store_comment.php on line 18 What is it expecting me to do if it works EVERYWHERE else? Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428633 Share on other sites More sharing options...
hitman6003 Posted January 2, 2008 Share Posted January 2, 2008 You need a directory separator for your "ROOT" constant and the file name: change: require ROOT.'config.php'; to require ROOT.'/config.php'; Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428649 Share on other sites More sharing options...
datalee100 Posted January 2, 2008 Author Share Posted January 2, 2008 That got me: Warning: main(ROOT/config.php): failed to open stream: No such file or directory in /home/www/terrify.awardspace.com/store_comment.php on line 18 Fatal error: main(): Failed opening required 'ROOT/config.php' (include_path='.:/usr/local/php4/share/pear') in /home/www/terrify.awardspace.com/store_comment.php on line 18 Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428672 Share on other sites More sharing options...
hitman6003 Posted January 2, 2008 Share Posted January 2, 2008 No such file or directory It tells you what the problem is. is "ROOT" defined as a constant somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428686 Share on other sites More sharing options...
datalee100 Posted January 2, 2008 Author Share Posted January 2, 2008 That is a good suggestion... On my other page, the header is called in because it's a viewable file, but this one doesn't call in the header- how do I define the directory without going in and adding the exact loaction of my file? Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428693 Share on other sites More sharing options...
datalee100 Posted January 6, 2008 Author Share Posted January 6, 2008 Bumping the Thread for, what I hope, is the last bit of support that I will need... Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-431671 Share on other sites More sharing options...
Ken2k7 Posted January 6, 2008 Share Posted January 6, 2008 $_SERVER['DOCUMENT_ROOT']? Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-431723 Share on other sites More sharing options...
datalee100 Posted January 20, 2008 Author Share Posted January 20, 2008 $sql = "INSERT INTO guestbook (name,email,v_comment,) VALUES ('$name','$email','$comment')"; $result = mysql_query($sql,$dbi); If ($result) I'm getting a random error when I run that part of the code: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/www/terrify.awardspace.com/store_comment.php on line 43 I've been staring at this for an hour- what have I done wrong now? Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-444112 Share on other sites More sharing options...
datalee100 Posted January 20, 2008 Author Share Posted January 20, 2008 NVM- Fixed that. May have more... I'll edit in a sec. Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-444113 Share on other sites More sharing options...
Nhoj Posted January 20, 2008 Share Posted January 20, 2008 $sql = "INSERT INTO guestbook (name,email,v_comment,) VALUES ('$name','$email','$comment')"; $result = mysql_query($sql,$dbi); If ($result) You have an extra comma after 'v_comment' in INSERT INTO statement... also... Is $dbi a valid link? Edit... too slow lol Quote Link to comment https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-444129 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.