I'm following a private messaging system tutorial.
In the inbox page I have a script to delete messages.
But when I click on delete button after selecting a message to delete,
it takes a while and after that a windows error appears
"Apache HTTP Server
Apache HTTP Server has encountered a problem and
needs to close. We are sorry for the inconvenience.
.................................
Send Error Report Don't Send"
And in browser it gives a message after a while
" This webpage is not available. "
But it deletes message from mysql table.
Means the query is working properly but where is the error?
I couldn't understand it.
Please tell me if any one can..
pm_inbox.php code is here.
<?php
session_start();
require_once 'connect_i.php';
$myConnection = mysqli_connect
("$db_host","$db_username",
"$db_pass","$db_name")
or die("Could Not Connect to MySQL");
$sqlCommand = " SELECT id, email FROM users
WHERE email='" . $_SESSION['email'] . "' ";
$query = mysqli_query($myConnection,
$sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)){
$pid = $row["id"];
$email = $row["email"];
}
mysqli_free_result($query);
$sqlCommand = " SELECT COUNT(id)
AS numbers FROM pm_inbox WHERE userid = '$pid' ";
$query = mysqli_query($myConnection,
$sqlCommand) or die (mysql_error());
$result = mysqli_fetch_assoc($query);
$inboxMessages = $result['numbers'];
?>
<html>
<head></head>
<body>
<table width="800" border="0">
<tr>
<td>PHP Private message tutorial</td>
</tr>
</table><br>
<?php if ($_SESSION['email']) { ?>
<table width="800" border="0">
<tr>
<td>Welcome back <?php print $email; ?></td>
</tr>
<tr>
<td>Welcome back
<?php require_once "pm_check.php"; ?></td>
</tr>
</table>
<br>
<?php
require_once "connect.php";
$sql = " SELECT * FROM pm_inbox WHERE userid = '$pid'
ORDER by id DESC ";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
?>
<table width="800" border="0">
<form name="form1" method="post" action="pm_inbox.php">
<tr>
<td width="41" align="center">#</td>
<td width="490">Title:</td>
<td width="255">From:</td>
</tr>
<?php
while($rows = mysql_fetch_array($result)){
?>
<?php if ($rows['viewed'] == 0){ // show messages in bold ?>
<tr>
<td width="41" align="center">
<input type="checkbox" name="checkbox[]" id="checkbox[]"
value="<?php echo $rows['id']; ?>"></td>
<td width="490"><a href="pm_view_in.php?in=
<?php echo $rows['id']; ?>"><b><?php echo $rows['title']; ?>
</b></a></td>
<td width="255"><?php echo $rows['from_email']; ?></td>
</tr>
<?php } else if ($rows['viewed'] == 1) { ?>
<tr>
<td width="41" align="center">
<input type="checkbox" name="checkbox[]" id="checkbox[]"
value="<?php echo $rows['id']; ?>"></td>
<td width="490"><a href="pm_view_in.php?in=<?php echo $rows['id']; ?>">
<?php echo $rows['title']; ?></a></td>
<td width="255"><?php echo $rows['from_email']; ?></td>
</tr>
<?php } ?>
<?php } ?>
<tr>
<td colspan="3" align="center"><?php if ($inboxMessages > 0) { ?>
<input type="submit" name="delete" id="delete" value="Delete Selected Messages">
<?php } else { print "There are no messages in your inbox"; } ?> </td>
</tr>
<?php
if ($_POST['delete']){
$checkbox = $_POST['checkbox'];
$delete = $_POST['delete'];
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM pm_inbox WHERE id='$del_id'";
$result = mysql_query($sql);
}
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=pm_inbox.php\">";
}
}
mysql_close();
}
else
{
}
?>
</form>
</table>
<?php } else { ?>
<table width="800" border="0
In the inbox page I have a script to delete messages.
But when I click on delete button after selecting a message to delete,
it takes a while and after that a windows error appears
"Apache HTTP Server
Apache HTTP Server has encountered a problem and
needs to close. We are sorry for the inconvenience.
.................................
Send Error Report Don't Send"
And in browser it gives a message after a while
" This webpage is not available. "
But it deletes message from mysql table.
Means the query is working properly but where is the error?
I couldn't understand it.
Please tell me if any one can..
pm_inbox.php code is here.
<?php
session_start();
require_once 'connect_i.php';
$myConnection = mysqli_connect
("$db_host","$db_username",
"$db_pass","$db_name")
or die("Could Not Connect to MySQL");
$sqlCommand = " SELECT id, email FROM users
WHERE email='" . $_SESSION['email'] . "' ";
$query = mysqli_query($myConnection,
$sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)){
$pid = $row["id"];
$email = $row["email"];
}
mysqli_free_result($query);
$sqlCommand = " SELECT COUNT(id)
AS numbers FROM pm_inbox WHERE userid = '$pid' ";
$query = mysqli_query($myConnection,
$sqlCommand) or die (mysql_error());
$result = mysqli_fetch_assoc($query);
$inboxMessages = $result['numbers'];
?>
<html>
<head></head>
<body>
<table width="800" border="0">
<tr>
<td>PHP Private message tutorial</td>
</tr>
</table><br>
<?php if ($_SESSION['email']) { ?>
<table width="800" border="0">
<tr>
<td>Welcome back <?php print $email; ?></td>
</tr>
<tr>
<td>Welcome back
<?php require_once "pm_check.php"; ?></td>
</tr>
</table>
<br>
<?php
require_once "connect.php";
$sql = " SELECT * FROM pm_inbox WHERE userid = '$pid'
ORDER by id DESC ";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
?>
<table width="800" border="0">
<form name="form1" method="post" action="pm_inbox.php">
<tr>
<td width="41" align="center">#</td>
<td width="490">Title:</td>
<td width="255">From:</td>
</tr>
<?php
while($rows = mysql_fetch_array($result)){
?>
<?php if ($rows['viewed'] == 0){ // show messages in bold ?>
<tr>
<td width="41" align="center">
<input type="checkbox" name="checkbox[]" id="checkbox[]"
value="<?php echo $rows['id']; ?>"></td>
<td width="490"><a href="pm_view_in.php?in=
<?php echo $rows['id']; ?>"><b><?php echo $rows['title']; ?>
</b></a></td>
<td width="255"><?php echo $rows['from_email']; ?></td>
</tr>
<?php } else if ($rows['viewed'] == 1) { ?>
<tr>
<td width="41" align="center">
<input type="checkbox" name="checkbox[]" id="checkbox[]"
value="<?php echo $rows['id']; ?>"></td>
<td width="490"><a href="pm_view_in.php?in=<?php echo $rows['id']; ?>">
<?php echo $rows['title']; ?></a></td>
<td width="255"><?php echo $rows['from_email']; ?></td>
</tr>
<?php } ?>
<?php } ?>
<tr>
<td colspan="3" align="center"><?php if ($inboxMessages > 0) { ?>
<input type="submit" name="delete" id="delete" value="Delete Selected Messages">
<?php } else { print "There are no messages in your inbox"; } ?> </td>
</tr>
<?php
if ($_POST['delete']){
$checkbox = $_POST['checkbox'];
$delete = $_POST['delete'];
if($delete){
for($i=0;$i<$count;$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM pm_inbox WHERE id='$del_id'";
$result = mysql_query($sql);
}
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=pm_inbox.php\">";
}
}
mysql_close();
}
else
{
}
?>
</form>
</table>
<?php } else { ?>
<table width="800" border="0