Reply not working
5 posts
Page 1 of 1
Hello,
For some reason my reply.php files won't insert the data in to my database can anyone help please
It says ts been inserted but the data don't go in to the table.
Reply.php
For some reason my reply.php files won't insert the data in to my database can anyone help please
It says ts been inserted but the data don't go in to the table.
Reply.php
Code: Select all
This is my view pm.php file <?php $title = "MBAPPZ.com - Reply"; ?>
<?php require("styles/top.php"); ?>
<div id='full'>
<?php
if($username){
echo "<b>Reply To Message</b><br /><br />";
if ($_POST['replybutton']){
$subject = $_POST['replysubject'];
$content = $_POST['replycontent'];
$replyid = $_POST['replyid'];
if ($subject && $content){
require('scripts/connect.php');
$date = date("F d, Y");
$query = mysql_query("SELECT * FROM messages WHERE content='$content' AND date='$date'");
$numrows = mysql_num_rows($query);
if ($numrows == 0){
$query = mysql_query("SELECT * FROM messages WHERE id='$replyid' AND to_user='$username'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$to_id = $row['from_id'];
$to_user = $row['from_user'];
mysql_query("INSERT INTO messages VALUES('', '$to_user', '$to_id', '$username', '$userid', '$subject', '$content', '$date')");
echo "Your reply has been sent thank you. <a href='inbox.php'>Click Here</a> to return to your inbox.";
}
else
echo "No message was sent. An error has occured!!!.";
}
else
echo "You can NOT resend the same messages.";
}
else
echo "You did not supply a subject and / or content.";
}
else
echo "You must submit a response to a message.";
}
else
echo "You must be logged in to view this page sorry.";
?>
</div>
<?php require("styles/bottom.php"); ?>
Code: Select all
<?php $title = "MBAPPZ.com - Viewing Private Message"; ?>
<?php require("styles/top.php"); ?>
<div id='full'>
<?php
if($username){
$msg_id = $_GET['id'];
require('scripts/connect.php');
$query = mysql_query("SELECT * FROM messages WHERE id=$msg_id");
$numrows = mysql_num_rows($query);
if ($numrows > 0){
while($row = mysql_fetch_assoc($query)){
$msg_id = $row['id'];
$msg_to_user = $row['to_user'];
$msg_to_id = $row['to_id'];
$msg_from_user = $row['from_user'];
$msg_from_id = $row['from_id'];
$msg_subject = $row['subject'];
$msg_content = nl2br($row['content']);
$msg_date = $row['date'];
echo "<div id='profile'>
<div id='leftside'>
Some Information Goes Here
</div>
<div id='rightside'>
<div>
<b class='corners'>
<b class='corners1'><b></b></b>
<b class='corners2'><b></b></b>
<b class='corners3'></b>
<b class='corners4'></b>
<b class='corners5'></b></b>
<div class='cornersfg'>
<div class='top'>$msg_subject</div>
</div>
<div class='bottom'>
<table cellpadding='5px' cellspacing='5px'>
<tr>
<td><b>Date Sent:</b></td>
<td>$msg_date</td>
</tr>
<tr>
<td><b>Sent From:</b></td>
<td><a href='profile.php?id=$msg_from_id'>$msg_from_user</a></td>
</tr>
<tr>
<td><b>Sent To:</b></td>
<td><a href='profile.php?id=$msg_to_id'>$msg_to_user</a></td>
</table>
<hr>
<table cellpadding='5px' cellspacing='5px'>
<tr>
<td><b>Message:</b</td>
<td>$msg_content</td>
</tr>
</table>";
echo "</div>
<b class='corners'>
<b class='corners5'></b>
<b class='corners4'></b>
<b class='corners3'></b>
<b class='corners2'><b></b></b>
<b class='corners1'><b></b></b></b>
</div>";
echo"<a name='comments'></a><div style='margin-top: 15px;'>
<b class='corners'>
<b class='corners1'><b></b></b>
<b class='corners2'><b></b></b>
<b class='corners3'></b>
<b class='corners4'></b>
<b class='corners5'></b></b>
<div class='cornersfg'>
<div class='top'>Send A Reply To $msg_from_user's Message</div>
</div>
<div class='bottom'>
<form action='reply.php' method='POST'>
<input type='hidden' value='$msg_id' name='replyid'>
<input text='text' name='replysubject' value='RE: $msg_subject'><br />
<textarea name='replycontent' style='width: 400px; height: 75px;'></textarea><br /><br />
<input type='submit' name='replybutton' value='Send Reply' class='button'>
</form>
";
echo "</div></div>
<b class='corners'>
<b class='corners5'></b>
<b class='corners4'></b>
<b class='corners3'></b>
<b class='corners2'><b></b></b>
<b class='corners1'><b></b></b></b>
</div>";
// end comments stuff
echo "</div>";
}
}
else
echo "There has been an error please try again.";
}
else
echo "You must be logged in to view this page sorry.";
?>
</div>
<?php require("styles/bottom.php"); ?>
Not sure what the problem is.
Try changing part of the insert code to this:
Try changing part of the insert code to this:
Code: Select all
OR: if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$to_id = $row['from_id'];
$to_user = $row['from_user'];
mysql_query("INSERT INTO messages VALUES('', '$to_user', '$to_id', '$username', '$userid', '$subject', '$content', '$date')")or die(mysql_error());
echo "Your reply has been sent thank you. <a href='inbox.php'>Click Here</a> to return to your inbox.";
}
Code: Select all
Also have you checked the database through phpmyadmin to see if the record has actually been added? :?if ($numrows == 1){
$row = mysql_fetch_assoc($query);
$to_id = $row['from_id'];
$to_user = $row['from_user'];
$check = mysql_query("INSERT INTO messages VALUES('', '$to_user', '$to_id', '$username', '$userid', '$subject', '$content', '$date')");
if($check)
{
echo "Your reply has been sent thank you. <a href='inbox.php'>Click Here</a> to return to your inbox.";
}
else
{
echo "Ooops!.";
}
}
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
i'm getting this error now.
Column count doesn't match value count at row 1
Column count doesn't match value count at row 1
Make sure you lock your topic and pick the correct answer if it was given.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023