/    Sign up×
Community /Pin to ProfileBookmark

HTTP 406 Not Acceptable

Hi,
I have suddenly started to received http 406 not acceptable error.
This is my code:

[code=php]<?php
//update query here
if ($query) {
echo “<div align=center>Record Updated Successfully</div>”;
echo “<meta http-equiv=”Refresh” content=”3;url=index.php”>”;
} else {
echo “<div align=center>Error in updating. <br>MySql Said: “.mysql_error().”<br>sql:<br>$sql</div>”;
}
?>[/code]

I was told to specify the content type in my file although I have this
in my header,

[code]
<META http-equiv=Content-Type content=’text/html; charset=windows-1256′>
[/code]

but still reciving this error whenever i click on update button to update a record in my db.

how can i resolve this ? ? The strange thing is that it works sometimes and sometimes doesn’t work at all. the Page hangs and give the http 406 error.
Any guide appreciate it.
Thanks

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@flannSep 11.2007 — what is the 3; in the following line? Could that be your problem.

echo "<meta http-equiv="Refresh" content="[B]3;[/B]url=index.php">";
Copy linkTweet thisAlerts:
@bokehSep 11.2007 — what is the 3; in the following line? Could that be your problem.

echo "<meta http-equiv="Refresh" content="[B]3;[/B]url=index.php">";[/QUOTE]
There's nothing wrong there.

Meta Refresh
Copy linkTweet thisAlerts:
@HuevoosSep 11.2007 — I think that the meta tag should go inside the head element.

Maybe that's causing your problem
Copy linkTweet thisAlerts:
@svidgenSep 11.2007 — META tags are supposed to go in the head, yes. However, the 406 response isn't generally sent by the server. It's generally "generated" by the browser when the content-type, as you said, doesn't match the returned content.

If you're sending plain-text/html, as indicated below, first try simply removing the specifying META tag. If that doesn't solve the problem, please supply more code for us to look at and indicate what browser and server versions you're using.
Copy linkTweet thisAlerts:
@themoonauthorSep 11.2007 — I think it only works in IE 7.

It didn't work in other browsers.

However, it works on my local pc in which iam using win xp.

But in my site, i am using Linux OS.

Here is the full page code:
[code=php]<?
if (eregi("editable_profiles.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: index.php");
die();
}
?>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" class="tables">
<tr >
<td colspan="5" bgcolor=#FCDAE4 height=20 class=Header>&nbsp;<img src='..images/mesiar_73.gif'>&nbsp;
<b>Profile Management</b>
</td>
</tr>
</table>

<br>
<table border='0' align=center cellspacing='1' cellpadding='0' width='98%' >
<form method="POST" action="index.php?func=editable_profiles">
<tr>
<td valign="top" colspan="8" dir="ltr">
<input type="checkbox" name="all" onClick="checkAll('multi_ok[]',this)">Select All &#1575;&#1604;&#1603;&#1604;<br>
</td>
</tr>
<tr bgcolor=#FCDAE4 class=HedinnerTxt height=25 >
<td align=center><b>Username </font></strong></td>
<td align=center><b>City</font></strong></td>
<td align=center><b>Occupation</font></strong></td>
<td align=center><b>About Me</font></strong></td>
<td align=center><b>About Other</font></strong></td>
<td align=center><b>Approve</font></strong></td>
<td align=center><b>Reject</font></strong></td>
</tr>
<?php
if (isset($_POST['take_action'])) {
if (isset($_POST['multi_ok']) && !isset($_POST['multi_delete'])) {
foreach ($_POST['multi_ok'] as $value) {
//$db_username = $_POST[db_username_.$value];
$fullname = $_POST[fullname_.$value];
$tell = $_POST[tell_.$value];
$mobileno = $_POST[mobileno_.$value];
$email = $_POST[email_.$value];
$nationality = $_POST[nationality_.$value];
$reside_city = $_POST[reside_city_.$value];
$reside_country = $_POST[reside_country_.$value];
$height = $_POST[height_.$value];
$weight = $_POST[weight_.$value];
$skin_color = $_POST[skin_color_.$value];
$eyes_color = $_POST[eyes_color_.$value];
$hair_color = $_POST[hair_color_.$value];
$hair_type = $_POST[hair_type_.$value];
$beauty_level = $_POST[beauty_level_.$value];
$education = $_POST[education_.$value];
$smoking = $_POST[smoking_.$value];
$health = $_POST[health_.$value];
$marital_status = $_POST[marital_status_.$value];
$income = $_POST[income_.$value];
$currency = $_POST[currency_.$value];
$occupation = $_POST[occupation_.$value];
$about_me = $_POST[about_me_.$value];
$about_others = $_POST[about_others_.$value];
$theage = $_POST[theage_.$value];

$sql="UPDATE users
SET fullname='$fullname',
tell='$tell',
mobileno='$mobileno',
email='$email',
nationality='$nationality',
reside_city='$reside_city',
reside_country='$reside_country',
height='$height',
weight='$weight',
skin_color='$skin_color',
eyes_color='$eyes_color',
hair_color='$hair_color',
hair_type='$hair_type',
education='$education',
smoking='$smoking',
health='$health',
marital_status='$marital_status',
income='$income',
currency='$currency',
occupation='$occupation',
about_me='$about_me',
about_others='$about_others',
theage='$theage',
editProfile ='1'
WHERE username ='$value'"; //
//$s_this_username = get_user_dbname_admin($value);
//echo "sql = <br>$sql<br><br>";
//echo "this = $value<br>";
//exit;
$query_11=@mysql_query($sql) or die(mysql_error());
$the_sql = "update users_temp
set editProfile='0'
where username ='$value'
";
$query_22=@mysql_query($the_sql) or die(mysql_error());
}

if ($query_11 && $query_22) {
foreach ($_POST['multi_ok'] as $value) {
unset($_SESSION['db_username']);
}

echo "<div align=center>Record Updated Successfully</div>";
echo "<meta http-equiv="Refresh" content="3;url=index.php?func=editable_profiles">";
} else {
echo "<div align=center>Error in updating. <br>MySql Said: ".mysql_error()."<br>sql:<br>$sql</div>";
}

} else if (!isset($_POST['multi_ok']) && isset($_POST['multi_delete'])) {
foreach ($_POST['multi_delete'] as $value) {
$del=@mysql_query("delete from users_temp where username = '$value'") or die(mysql_error());
}

if ($del) {
echo "<div>Rejected</div>";
echo "<meta http-equiv="Refresh" content="3;url=index.php?func=editable_profiles">";

} else {
echo "<div align=center>Error in updating. <br>MySql Said: ".mysql_error()."<br>sql:<br>$sql</div>";
}

} else {

echo "Please check a field to edit";
echo "<meta http-equiv="Refresh" content="1;url=index.php?func=editable_profiles">";
}


} else {

// how many rows to show per page
$rowsPerPage = 50;

// by default we show first page
$pageNum = 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}

// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;

$query=mysql_query("select * from users_temp where editProfile='1' order by id desc LIMIT $offset, $rowsPerPage");
if (!$query) {
echo "Error in selecting pending profiles".mysql_error();
}

$num_rows=mysql_num_rows($query);
if ($num_rows <=0) {
echo "<div align=center>No Members at the moment</div>";
}
$count=0;
$self = $_SERVER['PHP_SELF']."?func=editable_profiles";

while ($row=mysql_fetch_array($query)) {
$count++;
$_SESSION['db_username'] = $row['username'];
$_SESSION['fullname'] = $row["fullname"];
$_SESSION['email'] = $row["email"];
$_SESSION['reside_city'] = $row["reside_city"];
$_SESSION['reside_country'] = $row["reside_country"];

$_SESSION['nationality'] = $row["nationality"];

if ($count%2==0)
$color="FEF2F4";
else
$color= "FFFBFC";
echo "
<tr bgcolor=$color>
<td class=UsrLoginTxt align=center valign=top><a href='index.php?func=editable_profile_details&db_username=".$_SESSION['db_username']."&id=$db_id' title='&#1573;&#1590;&#1594;&#1591; &#1607;&#1606;&#1575; &#1604;&#1605;&#1588;&#1575;&#1607;&#1577; &#1578;&#1601;&#1575;&#1589;&#1610;&#1604; &#1575;&#1604;&#1593;&#1590;&#1608; &#1608;&#1575;&#1604;&#1605;&#1608;&#1575;&#1601;&#1602;&#1607; &#1593;&#1604;&#1610;&#1607;'>".$_SESSION['db_username']."</a></td>
<td class=UsrLoginTxt align=center valign=top><input type='text' name='reside_city_".$_SESSION['db_username']."' value='".$_SESSION['reside_city']."'></td>
<td class=UsrLoginTxt align=center valign=top><input type='text' name='occupation_".$_SESSION['db_username']."' value='".$_SESSION['occupation']."'></td>
<td class=UsrLoginTxt align=center><textarea cols='21' rows='6' name='about_me_".$_SESSION['db_username']."'>".$_SESSION['about_me']."</textarea></td>
<td class=UsrLoginTxt align=center><textarea cols='21' rows='6' name='about_others_".$_SESSION['db_username']."'>".$_SESSION['about_others']."</textarea></td>
<td class=UsrLoginTxt align=center>
<input type=checkbox class=inputbordr name='multi_ok[]' value='".$_SESSION['db_username']."'>
</td>
<td class=UsrLoginTxt align=center>
<input type=checkbox class=inputbordr name='multi_delete[]' value='".$_SESSION['db_username']."'>
<input type='hidden' class=inputbordr name='fullname_".$_SESSION['db_username']."' value='".$_SESSION['fullname']."'>
<input type='hidden' class=inputbordr name='email_".$_SESSION['db_username']."' value='".$_SESSION['email']."'>
<input type='hidden' class=inputbordr name='reside_country_".$_SESSION['db_username']."' value='".$_SESSION['reside_country']."'>
<input type='hidden' class=inputbordr name='nationality_".$_SESSION['db_username']."' value='".$_SESSION['nationality']."'>

</td>
</tr>

";
}
//print page navigation here

} //closing if isset

$action = $_GET['action'];
$id = $_GET['id'];
if ($action=="delete_profile") { //delete the profile
$query=mysql_query("delete from users_temp where editProfile='1' and id='$id'");
if ($query) {
echo "<div align=center>";
echo "<br><br>";
echo "Deleted Successfully";
echo "<meta http-equiv="Refresh" content="2;url=$self">";
echo "</div>";
} else
echo "Error in deleting members ".mysql_error();
}
?>

<tr>
<td align="center" colspan="6">
<input type="submit" class=inputbordr name="take_action" value="Execute" Onclick='return confirm("&#1607;&#1604; &#1571;&#1606;&#1578; &#1605;&#1578;&#1571;&#1603;&#1583; &#1578;&#1585;&#1610;&#1583; &#1578;&#1606;&#1601;&#1610;&#1583; &#1575;&#1604;&#1593;&#1605;&#1604;&#1610;&#1577;&#1567;&#1567;&#1567;");' >
</td>
</tr>
</form>


</table>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%">
<?
// print the page navigation link

echo "</table>";[/code]
Copy linkTweet thisAlerts:
@svidgenSep 12.2007 — Is the script above being included from another? Is the request this script is handling an asynchronous (sp?) request?
Copy linkTweet thisAlerts:
@themoonauthorSep 12.2007 — yes, this file is being included in my index file in this way:

[code=php]<?php
include_once("include/session.php");
include_once("header.php");
if ($_GET['func']=="editable_profiles") {
include("editprofile.php");
}
include_once("footer.php");
?>[/code]


and in my header i have this:

[code=html]<META http-equiv=Content-Type content='text/html; charset=windows-1256'>[/code]

And the script that i have given in my first post is the content of editable_profiles.php file.

Any clue ?

thanks
Copy linkTweet thisAlerts:
@themoonauthorSep 13.2007 — any solutions guys ?

is there anything wrong in my code ? ?
Copy linkTweet thisAlerts:
@bokehSep 13.2007 — Is there a URL and browser combination that is reliably returning the 406? If so can you post it?
Copy linkTweet thisAlerts:
@themoonauthorSep 25.2007 — Is there a URL and browser combination that is reliably returning the 406?[/QUOTE]
actually, no.

as i said before that it sometimes works and sometimes it doesn't. And incase it doesn't work, means that the page hang and i only see a blank white page, with a title of http://406 not acceptable. And on that case it deletes all fields instead of updating them.

I have provided all necessary related codes.

And i am still confused ? how to resolve this issue.

Thanks all.

M
Copy linkTweet thisAlerts:
@MrCoderSep 25.2007 — 406 normally means the web server terminated the communication with the client in the final stages of sending.

I would contact your web hosting provider.
×

Success!

Help @themoon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...