Copy link to clipboard
Copied
I have created a comments section in which there is only one field comment here is the code of the form:
<form id="frmComment" name="frmComment" method="POST" action="<?php echo $editFormAction; ?>">
<h3>
<label for="namegd"></label>Comment:</h3>
<p>
<label for="comment2"></label>
<textarea name="comment" id="comment2" cols="60" rows="10" ></textarea>
</p>
<p>
<label for="submit">
</label>
<input type="submit" name="submit" id="submit" value="Submit" />
<label for="reset"></label>
<input type="reset" name="reset" id="reset" value="Clear" />
</p>
<input type="hidden" name="MM_insert" value="frmComment" />
</form>
and the insert into code applied to the form is this
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmComment")) {
$insertSQL = sprintf("INSERT INTO comments (`comment`, ) VALUES (%s)",
GetSQLValueString($_POST['comment'], "text"));
mysql_select_db($database_my_connection, $my_connection);
$Result1 = mysql_query($insertSQL, $my_connection) or die(mysql_error());
}
Adding the extra values to the insert query is easy:
$insertSQL = sprintf("INSERT INTO comments (`comment`, commented_by, post_id) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['comment'], "text"),
GetSQLValueString($_SESSION['Username'], "text"),
GetSQLValueString($row_recordset1['id'], "int"));
You need to make sure that the code for recordset1 comes before the insert query. By default, Dreamweaver places recordset code immediately above the DOCTYPE declaration, and belo
...Copy link to clipboard
Copied
Posting three separate threads about the same issue is a sure way to make yourself unpopular in any web forum, particularly when you start using garish colours, bold font, and unhelpful subject lines. I have locked your duplicate threads.
Copy link to clipboard
Copied
Sorry for that but I was not sure how to put the whole situation in front of the reader so I tried to explain in different ways in all the different threads and by the way can u help me with this plz sir
Copy link to clipboard
Copied
Adding the extra values to the insert query is easy:
$insertSQL = sprintf("INSERT INTO comments (`comment`, commented_by, post_id) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['comment'], "text"),
GetSQLValueString($_SESSION['Username'], "text"),
GetSQLValueString($row_recordset1['id'], "int"));
You need to make sure that the code for recordset1 comes before the insert query. By default, Dreamweaver places recordset code immediately above the DOCTYPE declaration, and below other server behaviors. So, you need to move the code. Otherwise, this insert query won't work.
Copy link to clipboard
Copied
Hey it isn't working the problem is that when ever is use the above code and preview it in the browser I just get a blank page but the address in the address bar is correct
Copy link to clipboard
Copied
If you're getting a blank page, it means there's an error somewhere in the PHP code, but you have display_errors turned off. Change your php.ini to display errors, and restart Apache. Then you should see an error message that helps identify where the problem is.
Copy link to clipboard
Copied
well m testing on a server that I plan to host my site on so will it have this option
Copy link to clipboard
Copied
It depends on your hosting company. Some hosting companies let you change the configuration options by giving you access to your own php.ini. Others don't.
One thing you can try is to add the following at the top of the script:
<?php ini_set('display_errors', '1'); ?>
That turns on the display of errors for that particular script. However, it won't work if it's a parse error (missing semicolon, unmatched quote, etc).
Copy link to clipboard
Copied
Well I don't know what the problem was but I just took the backup of my page and inserted the code in it and it works fine now thanks man I can't express how much I owe you
Thanks a lot man
Copy link to clipboard
Copied
Glad you got it working.
Copy link to clipboard
Copied
Nope not working