Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/
Share on other sites

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
?>

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-426419
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-427888
Share on other sites

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."; 

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428607
Share on other sites

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.'; 

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428614
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428633
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-428672
Share on other sites

  • 2 weeks later...

$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?

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-444112
Share on other sites

$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

Link to comment
https://forums.phpfreaks.com/topic/83807-parse-errors-galore/#findComment-444129
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.